Monday, September 22, 2014

Where is my space on Linux filesystem?

Not Often, I checked about my space after made filesystem on Linux. Today, I have made Ext4 filesystem around 460GB, I found it 437GB only. Some path should be 50GB, but it was available only 47GB.
Thank You @OracleAlchemist and @gokhanatil for good information about it.
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup0-U01LV   50G   52M   47G   1% /u01

Reference  - It's for 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 prevented from writing to the  filesystem. The default percentage is 5%.
After I found out more information. Look like we can set it to zero, but we should not set it to zero for /,/var,/tmp or which path has lots of file creates and deletes.
If you set the reserved block count to zero, it won't affect
performance much except if you run for long periods of time (with lots
of file creates and deletes) while the filesystem is almost full
(i.e., say above 95%), at which point you'll be subject to
fragmentation problems.  Ext4's multi-block allocator is much more
fragmentation resistant, because it tries much harder to find
contiguous blocks, so even if you don't enable the other ext4
features, you'll see better results simply mounting an ext3 filesystem
using ext4 before the filesystem gets completely full.
If you are just using the filesystem for long-term archive, where
files aren't changing very often (i.e., a huge mp3 or video store), it
obviously won't matter.
- Ted
Example: Changed reserved-blocks-percentage 
[root@mytest01 u01]# df -h /u01
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup0-U01LV   50G   52M   47G   1% /u01
[root@mytest01 u01]# tune2fs -m 1 /dev/mapper/VolGroup0-U01LV
tune2fs 1.43-WIP (20-Jun-2013)
Setting reserved blocks percentage to 1% (131072 blocks)
[root@mytest01 u01]# df -h /u01
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup0-U01LV   50G   52M   49G   1% /u01
[root@mytest01 u01]# tune2fs -m 5 /dev/mapper/VolGroup0-U01LV
tune2fs 1.43-WIP (20-Jun-2013)
Setting reserved blocks percentage to 5% (655360 blocks)
[root@mytest01 u01]# df -h /u01
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup0-U01LV   50G   52M   47G   1% /u01
Finally, I knew it was reserved for super-user. Checked more for calculation.
[root@ottuatdb01 ~]# df -m /u01
Filesystem                  1M-blocks  Used Available Use% Mounted on
/dev/mapper/VolGroup0-U01LV     50269    52     47657   1% /u01
[root@ottuatdb01 ~]#  tune2fs -l /dev/mapper/VolGroup0-U01LV |egrep  'Block size|Reserved block count'
Reserved block count:     655360
Block size:               4096

Available = 47657MB
Used = 52M
Reserved Space = (655360 x 4096) / 1024 /1024 = 2560MB 
Total = 47657 + 2560 + 52 = 50269 

OK.. I felt good after it cleared for me. Somehow, I believe On Hug space, 5% of the filesystem blocks reserved that's too much. We can reduce it.

Other Links:
https://www.redhat.com/archives/ext3-users/2009-January/msg00026.html
http://unix.stackexchange.com/questions/7950/reserved-space-for-root-on-a-filesystem-why
http://linux.die.net/man/8/tune2fs
https://wiki.archlinux.org/index.php/ext4#Remove_reserved_blocks

No comments: