Get back that disk space from linux


Linux is a cool operating system to work with but at times it can play smart tricks with you, like when you format a drive, you won’t get 100% of the available space. Now why is that you may ask, so the answer is linux reserves about 5% space for privileged processes by default. The reason behind this, linux does not rely on us to free up space in case your filesystem gets full, the system processes can continue to work properly. So, in a way this smart little trick is a good idea and you should not mess up with this space.

However if you are creating some large partitions just like I do for my oracle data-files, then it would result in loss of storage. Lets take an example, if you have 2TB Partition, then it’s not really needed to waste 100GB just for this. In scenarios like these, you can pull out this space out of the reserved section and use for your own purposes.

Squeeze that extra space

So, to get back this space you have to use tune2fs. To reduce the reserved percentage from 5% to 2%, fire the command

# tune2fs -m 2 /dev/sda1

You can replace /dev/sda1 with any filesystem whose reserved space you would like to squeeze.
Make sure you don’t run this command while the filesystem is mount. First un-mount the filesystem and then only fire this command. To check whether it worked, mount the filesystem, and use df command like this:

# umount /opt/oradata1

# tune2fs -m 2 /dev/sda1

# mount /dev/sda1 /opt/oradata1

# df -h /dev/sda1

It should now show you the increase in the usable space in the filesystem.

Do note that this command only works on ext* filesystems say ext2/ext3/ext4.