Ubuntu 18.04 - root filesystem full

6,423

Solution 1

i have a 256GB M2 drive on which i had installed boot, root, and swap, with leftover space mounted under /m2. then i have a 1TB drive on which i installed /home. snap filled up my /var directory.

i think the correct solution would have been to move /var to /home/var but i couldn't get that to work.

then i zapped swap and /m2, increased the size of root, and added back swap and /m2. but then i got errors relating to invalid sectors or corrupt disk, i can't remember exactly.

so then i stopped using the M2 drive altogether. i tried to shrink /home and to put boot, root, and swap at the end of the 1TB drive. but this got corrupted too. in the end i did a bare metal reinstall to the 1TB drive.

Solution 2

Boot from a live distro, shrink p4 partition, move p3 next to p4, resize p2

Share:
6,423
erik
Author by

erik

Updated on September 18, 2022

Comments

  • erik
    erik over 1 year

    My root filesystem is full. how can I fix the problem? I allocated 15G to root which I understand should be sufficient, I wonder if I have configured the partitions correctly. there might be a problem with the /snap directory.

    Here is the output of selected commands:

    df -h /

    $ df -h /
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/nvme0n1p2   15G   13G  498M  97% /
    

    df -h

    $ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev             16G     0   16G   0% /dev
    tmpfs           3.2G  2.1M  3.2G   1% /run
    /dev/nvme0n1p2   15G   13G  498M  97% /
    tmpfs            16G  4.0M   16G   1% /dev/shm
    tmpfs           5.0M  4.0K  5.0M   1% /run/lock
    tmpfs            16G     0   16G   0% /sys/fs/cgroup
    /dev/loop0       88M   88M     0 100% /snap/core/5662
    /dev/loop1      173M  173M     0 100% /snap/spotify/21
    /dev/loop2       15M   15M     0 100% /snap/gnome-logs/45
    /dev/loop5      141M  141M     0 100% /snap/gnome-3-26-1604/74
    /dev/loop7       13M   13M     0 100% /snap/gnome-characters/124
    /dev/loop3       89M   89M     0 100% /snap/core/5897
    /dev/loop4      141M  141M     0 100% /snap/gnome-3-26-1604/70
    /dev/loop6       13M   13M     0 100% /snap/gnome-characters/139
    /dev/loop8      174M  174M     0 100% /snap/spotify/24
    /dev/loop10     130M  130M     0 100% /snap/postman/73
    /dev/loop9      484M  484M     0 100% /snap/libreoffice/90
    /dev/loop11      18M   18M     0 100% /snap/pdftk/9
    /dev/loop12      15M   15M     0 100% /snap/gnome-logs/40
    /dev/loop13     3.8M  3.8M     0 100% /snap/gnome-system-monitor/57
    /dev/loop15     2.3M  2.3M     0 100% /snap/gnome-calculator/222
    /dev/loop14      88M   88M     0 100% /snap/core/5742
    /dev/loop16      13M   13M     0 100% /snap/gnome-characters/117
    /dev/loop17     174M  174M     0 100% /snap/spotify/26
    /dev/loop18     3.8M  3.8M     0 100% /snap/gnome-system-monitor/51
    /dev/loop20     479M  479M     0 100% /snap/libreoffice/86
    /dev/loop19      35M   35M     0 100% /snap/gtk-common-themes/808
    /dev/loop21     2.3M  2.3M     0 100% /snap/gnome-calculator/260
    /dev/loop22      43M   43M     0 100% /snap/gtk-common-themes/701
    /dev/loop23     3.8M  3.8M     0 100% /snap/gnome-system-monitor/54
    /dev/loop24      35M   35M     0 100% /snap/gtk-common-themes/818
    /dev/loop26     2.3M  2.3M     0 100% /snap/gnome-calculator/238
    /dev/loop25     479M  479M     0 100% /snap/libreoffice/85
    /dev/loop27      15M   15M     0 100% /snap/gnome-logs/43
    /dev/sda1       1.8T  434G  1.3T  25% /home
    /dev/nvme0n1p4  215G   61M  204G   1% /m2
    /dev/nvme0n1p1  975M  6.1M  968M   1% /boot/efi
    tmpfs           3.2G   16K  3.2G   1% /run/user/121
    tmpfs           3.2G   36K  3.2G   1% /run/user/1000
    

    sudo du -h --max-depth=1 / | grep '[0-9]G\>'

    $ sudo du -h --max-depth=1 / | grep '[0-9]G\>'
    434G    /home
    11G /snap
    4.2G    /usr
    2.0G    /tmp
    5.6G    /var
    du: cannot access '/proc/7893/task/7893/fd/4': No such file or directory
    du: cannot access '/proc/7893/task/7893/fdinfo/4': No such file or directory
    du: cannot access '/proc/7893/fd/3': No such file or directory
    du: cannot access '/proc/7893/fdinfo/3': No such file or directory
    du: cannot access '/run/user/1000/gvfs': Permission denied
    459G    /
    

    dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n (an alternative could be wajig sizes | tail -30)

    $ dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n
    [snip]
    132042  libreoffice-core
    134299  libgl1-mesa-dri
    147486  libgl1-mesa-dri
    161309  thunderbird
    166969  linux-modules-extra-4.15.0-29-generic
    166997  linux-modules-extra-4.15.0-34-generic
    167001  linux-modules-extra-4.15.0-33-generic
    167039  linux-modules-extra-4.15.0-39-generic
    174305  firefox
    179065  openjdk-11-jre-headless
    194447  google-chrome-stable
    236804  zoom
    271127  linux-firmware
    

    here are some things that I already tried, they didn't help:

    sudo apt-get clean
    sudo apt-get autoclean
    sudo apt-get autoremove
    sudo apt-get autoremove --purge
    sudo apt-get remove --purge linux-image-X.X.XX-XX-generic # for old versions
    
    sudo find / -xdev -name core -ls -o  -path "/lib*" -prune
    
    $ dpkg -l "linux*{tools}*" |grep ^.i
    dpkg-query: no packages found matching linux*{tools}*
    

    I would be grateful for any assistance.

    Edit: this is how my drive appears in gparted:

    screenshot

    So it looks like I have a 256G m2 drive and i installed the boot, root, and swap partitions there, with leftover space mounted at /m2. my /home directory is on a separate device.

    So if I can't fix whatever is wrong with root, I'm wondering if I could increase its size by 1) delete /m2 2) delete swap 3) resize root 4) recreate swap. Would that work?

    Edit #2:

    du -h /var/lib/snapd/snaps

    $ du -h /var/lib/snapd/snaps
    4.0K    /var/lib/snapd/snaps/partial
    2.8G    /var/lib/snapd/snaps
    
    • Bernard Wei
      Bernard Wei over 5 years
      Your snap apps are using 11GB, that's where the problem lies. These are the apps installed via Ubuntu Store. Currently, it is using the storage from your root partition.
    • Bernard Wei
      Bernard Wei over 5 years
      Check the compressed snap usage at /var/lib/snapd/snaps to see if the actual storage is taking up a lot of the root partition.
    • erik
      erik over 5 years
      many thanks for getting back to me. i edited my post to show the output of "du -h /var/lib/snapd/snaps". how should i fix the problem?
    • erik
      erik over 5 years
      could i fix it by mounting /var elsewhere? my /home directory is mounted on a different disk with loads of free space, could i mount /var there?
    • guiverc
      guiverc over 5 years
      just a FYI: 15gb is enough only if you don't install many programs, as you require a lot of space to release-upgrade to the next version (unless your plan is nuke & install [clean]), the current wiki recommendation is 25gb.
    • guiverc
      guiverc over 5 years
      Yes you can install any directory elsewhere (assuming that mount isn't encrypted differently (as /home can be decrypted later thus boot problems as it's not available), Using 'live' media you can cp -pr it there, modify your fstab to mount it, then boot & verify it works. Only if happy would I actually delete the original directory (from live) -- but note this will cause headaches if you have problems in the future (you'll likely forget it if you need to chroot into the partition to fix things etc.. or next release-upgrade`). My choice would be expand the partition (shrink /home)
    • Bernard Wei
      Bernard Wei over 5 years
      The 2.8G of compressed snap in 5.6G of var doesn't seem unreasonable. Something else is using quite a bit of spaces in var. May be lot of log files, transmission daemon files or your apt cache stuff. Try getting rid of other stuff that is clogging up the /var. Also, 2G in tmp usage seems a lot.
    • xenoid
      xenoid over 5 years
      As a stopgap measure you can likely copy /snap to your /m2 filesystem and add a soft link to it in /. Increasing the partition size is doable (much easier/safer than shrinking it), but since your own data is on another device, repartitioning and reinstalling could also be an option.