My solutions to some not-so-common problems

How to gain couple of Gigabytes of free space on Linux?

Posted: October 8th, 2010 | Author: | Filed under: Linux | Tags: , , , | No Comments »

Lately I have problems with free space on my /home partition on my laptop. The problem is that I have nothing else to delete. The only option would be to buy a additional USB hard disc (I find it cumbersome) or buy a new, bigger hard drive for my laptop and exchange it with my current one.

When I was checking space left on my hard drive (using df command) I’ve noticed that

lukas@acer:~$ df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sda3 126G 117G 2,5G 98% /home

sum of Used and Avail column does not equal to Size of the partition. The difference was about 6Gb. Weird…

Reserved Block Count on partition

I found an explanation (using Google ofcors) that some percent of blocks on each partition is being reserved to reduce system defragmentation, allow root login for maintenance and to allow Linux system logging facility to function properly in case of lack of free space on partition. It is called Reserved Block Count and it is set to 5% of partition size by default.

You can check current Reserved Block Count value using dumpe2fs command

lukas@acer:~$ sudo dumpe2fs /dev/sda3 | grep "Reserved block count"
dumpe2fs 1.41.12 (17-May-2010)
Reserved block count: 1653590

Block size of my partition is 4096 (it can be checked using dumpe2fs command). So reserved space on my partition is about 6,3 Gb and equal missing size from hd command.

How to change Reserved Block Count
Reserved Block Count for given partition can be changed using tune2fs command

sudo tune2fs -m 0 /dev/sda3

where /dev/sda3 is your file system identifier

-m option sets the percentage of reserved file system blocks (in this case it is being set to 0%)

Then I’ve checked again free space in my system:

lukas@acer:~$ df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sda3 126G 117G 8,8G 94% /home

I have additional 6Gb on my home partition!

Is it safe?

You can disable Reserved Block Count (by setting the percentage of reserved filesystem blocks to 0%) safely on not-system partitions (such as /home partitions). You shouldn’t do this on partitions used by root (especially / and /root) and on partitions used by OS for logging and storing temporary files (e.g. /var and /tmp).

Share and Enjoy:
  • DZone
  • Digg
  • Slashdot
  • Reddit
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Facebook


Leave a Reply

You must be logged in to post a comment.