Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm a bit puzzled about the way ext4 reports used space. On a new Debian wheezy (testing) installation, I consistently got about 1GB extra space used with a 60GB SSD, when compared to du. I then network booted that computer and mounted the SSD. The network booted OS (Debian squeeze) shows only 180MB extra space used on the SSD. The journal is 128MB, so there's not much extra beyond that anymore.

What is the extra used space reported by df, when it's not space reserved for root or deleted files? Using Google mostly results in those usual causes, which I have ruled out. And why does that amount differ on the same filesystem when mounted on different operating systems? I tested this by re-installing, and the extra usage was again ~1GB on the wheezy installation, and 180MB when I network booted and mounted that SSD.

On XFS and btrfs, the extra reported usage seems negligible. I realize that the filesystem needs some overhead, but it's inconvenient when that overhead is mixed up with the real usage.

Here are some detailed outputs.

df

$ df -m on wheezy
Filesystem              1M-blocks  Used Available Use% Mounted on
rootfs                      57132  1567     52703   3% /
udev                         7899     0      7899   0% /dev
tmpfs                        1581     1      1581   1% /run
/dev/mapper/ssd-kvmhost     57132  1567     52703   3% /
tmpfs                           5     0         5   0% /run/lock
tmpfs                        3162     0      3162   0% /tmp
tmpfs                        3162     0      3162   0% /run/shm

du

$ du -sm /
592     /

tune2fs shows Inode count to be 3670016 and size 256, which indeed explains almost all of the used space. I just don't understand why this isn't subtracted from Size, since the inodes are statically reserved. Counting it as space and then always counting it as used doesn't make much sense.

Here's the output for the very same filesystem, from the network booted Debian squeeze:

aufs                      7905        46      7859   1% /
tmpfs                     7905         0      7905   0% /lib/init/rw
udev                      7900         1      7900   1% /dev
tmpfs                     7905         1      7905   1% /dev/shm
172.17.172.127:/storage/private/tftp/debian-live-6.0.3-amd64-lxde-desktop
                         24737     17448      7289  71% /live/image
tmpfs                     7905        46      7859   1% /live/cow
tmpfs                     7905         0      7905   0% /live
tmpfs                     7905         1      7905   1% /tmp
/dev/mapper/ssd-kvmhost
                         56337       772     52703   2% /mnt

And just for confirmation, du -sm / on the network booted OS:

592     /

Maybe the older kernel wisely doesn't count the statically reserved inode space as usable, and thus doesn't have to show it as used? The difference is 795MB in both Size and Used, almost all of the space needed for the inodes. What's the 180MB then? If that is also static, wouldn't it be optimal to also subtract that from Size? Then df could actually show real usage, like other filesystems seem to do.

The way I see it, if my filesystem needs a static amount of overhead, then it just provides less usable space than some other filesystems for the same amount of absolute space. Shouldn't df reflect that, and also show how much of the usable space I have used?

share|improve this question
    
Which options are you passing to df? –  JodieC Apr 1 '12 at 21:47

2 Answers 2

ext[234] by default reserves 8192 inodes per 128 mb block group, which takes 2mb, per group, which works out to close to 1gb for a 60 gb filesystem. There should be no difference when you mount the drive in another system. It looks like they may have changed the way the kernel reports used space between wheezy and squeeze, though I have not yet found a commit indicating this was done on purpose.

share|improve this answer
    
Actually, now that I think about it, it's always been reported as 180mb used by df. Are you sure you didn't look at the used space as reported by gnome, since they do have a bug where they report a few gb used instead because the compute the used space by subtracting available from total. –  psusi Apr 1 '12 at 22:31

Your question would be easier to answer if you provided the output of df and du.

But it sounds a lot like linux free disk space confusion

Basically, your file system uses some of the disk for its own metadata, i.e. not the files itself, but for keeping track of the files, their names, their permissions, their location on the disk, etc.

As the answer I linked to above says, running tune2fs -l <device name> will show you more information. In particular, inode count x inode size should be close to the difference between df and du.

Again based on the previous answer, my system's root partition is using about 1.77% of the disk for inodes. 60 GB * 0.0177 ~= 1 GB.

I suspect the 180 MB figure is incorrect, but can't be sure without more details, e.g. the output of mount on your network booted system. For example, maybe it's due to the minixdf/bsddf mount option.

share|improve this answer
    
Thanks! I'll add some output from the commands on my post. I just don't get why the space reserved for inodes is added to Used, and not subtracted from Size instead. If the space is statically reserved, why count it towards available space and then subtract it as used? Seems pointless and confusing. –  Jayssoneer Apr 1 '12 at 22:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.