Ext3 file system overhead disclosed (Part 1)


In the following 3 articles (Part 2, Part 3) I will show where is free space of your freshly installed disk gone, what is the overhead of the ext3 file system, how exactly this overhead is used and how we can reduce it to maximise effective usage of the filesystem.

It doesn't matter which distribution of Linux you are using (just some defaults might be different), I would do everything on the CentOS 5.2 (everything also applies to Fedora).

So lets begin.

I have installed fresh 1T drive to the server. Labeled it by default with fdisk - just one ext3 partition.

# fdisk -l /dev/sdh

Disk /dev/sdh: 999.9 GB, 999989182464 bytes
255 heads, 63 sectors/track, 121575 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdh1               1      121575   976551156   83  Linux

And formatted it using default ext3 settings. On CentOS (as well as Fedora) these settings are located in /etc/mke2fs.conf.

# mke2fs /dev/sdh1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
122077184 inodes, 244137789 blocks
12206889 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
7451 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848

Writing inode tables: done                           
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Ok, so now I have 1T free new file system. Cool. Let's mount it and confirm how much free space do we have :)

# mount  /dev/sdh1 /usr/hosting_files8

Damn! What is it? :)

# df -h /dev/sdh1
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdh1             917G   72M  871G   1% /usr/hosting_files8

We have just 871G which is 129G lesser then we have expected. My first hard drive was about 1000 times less then we just wasted nowhere (it was more then 10 years ago).

“Aha!” - you might say, - "I know ext3 filesystem keeps 5% reserved for root by default". But this is only one part and is not the biggest. I will show you now.

We can easily tweak this reserved percentage using tune2fs to zero. So we will see all usable free space of the file system.

# tune2fs -m 0 /dev/sdh1
tune2fs 1.39 (29-May-2006)
Setting reserved blocks percentage to 0% (0 blocks)

Let's check free space again

# df -h /dev/sdh1
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdh1             917G   72M  917G   1% /usr/hosting_files8

What's important to notice is that Total Size of the filesystem now equals Available.
But what the heck is 72M used for? And where is our 93 gigs more? There are no files at all - it is fresh.

# ls -alR /usr/hosting_files8/
total 28
drwxr-xr-x  3 root root  4096 Jan 28 12:56 .
drwxr-xr-x 24 root root  4096 Jan  5 15:03 ..
drwx------  2 root root 16384 Jan 27 18:19 lost+found

total 20
drwx------ 2 root root 16384 Jan 27 18:19 .
drwxr-xr-x 3 root root  4096 Jan 28 12:56 ..

Regarding the usage of the ext3 file system overhead I will tell in the second part of this article, now I will show where and how we've been fooling all this time.

The first problem is that fdisk shows you total available bytes. We all used to count 1k as 1024 bytes, 1M as 1024k and so on... Unfortunately marketing guys (or whoever) decided to count 1 Kilo bytes not as 1024, but as 1000. They say 1Kilobyte is 1000 bytes according to the SI standard, and what you call 1K - is 1 Kibibyte. “What the heck ??? What's this kibibyte??“ I first heard this word .. now, while writing this article.

It's just a trick to say you that you have 1T = 999,989,182,464 bytes.

df counts space (if used -h option) in our normal computer language. If we would have 1T, for df it would mean 1,099,511,627,776 bytes. Not that bigger, but we could have our disk 99G more.

So let's see how big is our file system in this Gigibytes? ... damn I cannot say this... it is terrible.

df will tell us this if you will use option

       -H, --si
              likewise, but use powers of 1000 not 1024

# df -h --si /dev/sdh1
Filesystem             Size   Used  Avail Use% Mounted on
/dev/sdh1              985G    76M   985G   1% /usr/hosting_files8

This is closer to those 999G shown by fdisk, but still 14G missing.

Why would we care about those 14G? For me personally 14G could be 20 movies in not very good avi quality, or 2000 photos made in RAW quality from your moder DSLR, or it can be couple years backups of some important data... I can find where to use those 14 G.. gg.. please nooo ... these 14 Gi-gi-bytes... How about you?

Stay tuned - I have almost finished writing second part of this article and will publish it soon.

UPDATED: Here is it - Part 2


Thank you for interesting article!

Do you mean that fdisk and "df -h" use different units and we need to run "df -H" for get the same numbers?

yes, they are using different units. but which of them to use - is just the question with which values you want to compare them ;)

Your rating: None Average: 4.6 (5 votes)