13

I've just had a message today from Ubuntu 11.04 that I have only 100 MB left, so I cleaned up some files, and I got 200 MB. Then, after a couple of hours, suddenly I have only 26 MB?! I tried df, du via mount --bind, /forcefsck with reboot - nothing could should what the culprit is - finally I searched big files, realized /var/log/syslog is 100MB+ and /var/log/kern.log is 200MB+ - blanked them with sudo bash -c 'echo > ...' and rebooted, and now I have some spare MB.

But now, I realize I have another problem with df:

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5             9,7G  8,8G  385M  96% /
none                  963M  696K  962M   1% /dev
none                  969M   12K  969M   1% /dev/shm
none                  969M  252K  969M   1% /var/run
none                  969M     0  969M   0% /var/lock
/dev/sda6             9,7G  8,1G  1,1G  89% /media/disk

$ df -h --block-size M
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda5                9845M     8960M      385M  96% /
none                      963M        1M      962M   1% /dev
none                      969M        1M      969M   1% /dev/shm
none                      969M        1M      969M   1% /var/run
none                      969M        0M      969M   0% /var/lock
/dev/sda6                9845M     8235M     1110M  89% /media/disk

Note so for /, it says there are 9845M total; and Used 8960M - then remaining would be 9845-8960 = 885 M, however, here I have only 385M Available.

Also, for /media/disk, it says total 9845M, Used 8235M - then remaining would be 9845-8235 = 1610, however, here I have only 1110M Available.

In both cases, there is exactly 500 MB difference.

Where did this difference come from - and can I reclaim it?

Here is also lsof | grep 'deleted' - can't see nothing suspicious here:

$ lsof | grep 'deleted'
nautilus  1911 user   21u      REG        8,5   142760     260562 /home/user/.local/share/gvfs-metadata/home (deleted)
nautilus  1911 user   22w      REG        8,5    32768     268807 /home/user/.local/share/gvfs-metadata/home-fe882154.log (deleted)
python    1919 user    8u      REG        8,5     4096     392258 /tmp/ffiqRK968 (deleted)
python    2165 user    5w      REG        8,5        0     132261 /home/user/.[SNIP].lock (deleted)
python    2166 user    5w      REG        8,5        0     132261 /home/user/.[SNIP].lock (deleted)
python    2185 user   21r      REG        8,5   142760     260562 /home/user/.local/share/gvfs-metadata/home (deleted)
python    2185 user   22r      REG        8,5    32768     268807 /home/user/.local/share/gvfs-metadata/home-fe882154.log (deleted)
gnome-ter 2279 user   27u      REG        8,5      640     392575 /tmp/vte5KDX2X (deleted)
gnome-ter 2279 user   28u      REG        8,5     4936     392605 /tmp/vteKRDX2X (deleted)
gnome-ter 2279 user   29u      REG        8,5      648     392947 /tmp/vteMZDX2X (deleted)
ubuntuone 2544 user   17u      REG        8,5     4096     392335 /tmp/ffiMErq0V (deleted)
bamfdaemo 3235 user   12r      REG        8,5   143868     269077 /home/user/.local/share/gvfs-metadata/root (deleted)
bamfdaemo 3235 user   13r      REG        8,5    32768     272310 /home/user/.local/share/gvfs-metadata/root-18092a02.log (deleted)
firefox   5291 user   59u      REG        8,5    33288     132262 /var/tmp/etilqs_YdeZiWSd5iQwJ4U (deleted)
firefox   5291 user   60w      REG        8,5    32768     132271 /var/tmp/etilqs_MNLXhEaEqoXMm9b (deleted)
firefox   5291 user   70u      REG        8,5    34952     132297 /var/tmp/etilqs_yXDdwVeMxmmdpNz (deleted)
jimmij
  • 47,140
sdaau
  • 6,778

2 Answers2

21

Most probably this is ext2, ext3 or ext4 file system which reserve a few percent of disk space (by default 5%) to be used only by specified users (usually root).

If you create file system with mke2fs then -m option is what you are looking for:

   -m reserved-blocks-percentage
          Specify the percentage of the filesystem blocks reserved for the  super-user.
          This avoids fragmentation, and allows root-owned daemons, such as syslogd(8),
          to continue to function correctly after  non-privileged  processes  are  pre‐
          vented from writing to the filesystem.  The default percentage is 5%.

You can change this value on already existing ext file system with tune2fs -m.

jimmij
  • 47,140
  • 1
    Thanks for that, @jimmij - indeed, sudo tune2fs -l /dev/sda5 | grep '[Bb]lock \(count\|size\)' gives me "Reserved block count: 128017" and "Block size: 4096", and 128017*4/1024 is indeed 500 MB, so this seems to solve the mystery. Cheers! – sdaau Aug 08 '15 at 15:39
4

du and df do not count the same things so it is rare from them to give the same results, though the differences are usually attributable to administrative overheads and areas reserved for special purposes. However, with 89% and 96% used you have much larger, and more urgent, problems to deal with.