Wednesday, December 7, 2011

Free up space on your hard drive.

ext2/ext3 and ext4, file systems automatically reserve space for themselves. (5% by default)
This is necessary for your root partition, so that  if you fill up the hard drive, Linux will still have space to write to the log files and to allow privileged processes to run so that they can avoid file system fragmentation.
However, if your hard disk is say a 650GB or bigger hard drive, that 5% amounts to a significant amount of disk space, and is a total overkill.
Additionally, you do not need this reserved space on hard drives that are only used for storage (ie are not part of your root partition)
so, how do we take back this valuable hard disk real estate ?
We use tune2fs.

so as an example,  type

tune2fs -m 1 /dev/sda2
to change the 5% to 1% on /dev/sda2

if /dev/sda was a 650GB hard drive this would give you an additional 26 GB Free!

tune2fs -m 0 /dev/sda2
will  reduce the 5% to 0%

to add reserved space for privileged processes back to a  drive
tune2fs -r 20000 /dev/sda2
will give back 20000 blocks, which should be more than sufficient

you can run tune2fs on  Logical volumes as well.

tune2fs -m 1 /dev/mapper/vg-lv_home 
will reclaim space from your logical volume

Just change /dev/mapper/vg/-lv_home to the name of your logical volume.
you can see all your volumes and partitions by typing df -h

No comments: