This happens to me quite often. Sometimes I just need to move some large data files such as all the video that is getting shot with my Droid to my external storage. Other times I need the files I am working on but still need some extra space. What can I do?
This is the question I was asking myself this morning. I pondered this for a few seconds and realized that I recently did a clean install of Ubuntu 10.04 and haven’t needed to tune much of the system. One parameter I quite often tune is the reserved blocks for the root file system. This parameter dates back to when Unix systems were running on 10MB or 40MB drives and reserving 5% for root didn’t really add up to a lot of space. These reserved blocks allow the system daemons to continue to run and the root user to login and clean up the file system if for example a process throws out lots of tmp files and fills the drive. When the drive is full it prevents the system from being able to create files to keep track of a users session and so the user can’t login.
The issue is that on modern systems hard drives aren’t measured in MB anymore. The root partition I am working on is 16GB and recently manufacturers are pumping out 3 TB drives. Reserving 5% of multi-gigabyte drives is overkill but on multi-terabyte drives it’s a huge amount of wasted space coming in at 50GB per TB. I hear your thoughts why not just turn off the reserve. Linux/Unix is still based on an architecture that uses files for user sessions so if on the off chance the drive fills nobody would be able to login and fix it.
The middle ground is to reduce the number of reserved blocks to something in the middle. If it was only the root user that needed the blocks you could take it down to 0.1% or maybe even smaller. Unfortunately it isn’t just the root user that needs the blocks in the event a drive fills. It is also all the daemons that would choke and even the file system itself in order to prevent fragmentation. So what should a user set this parameter to?
It is obviously more complicated on a multi-user or server system than a single-user system. On a single-user system you can turn off the reserved blocks on non-root partitions as long as they don’t contain /var or /tmp directories. On a root partition it comes down to how large you made the partition and the size of files you will use and if your running any daemons/servers that might need that reserved space. For my 16GB partition and my use I chose 2%. If I wasn’t working with large files I would have dropped it to 1% because I am pretty good at keeping the space cleaned up and not running any critical daemons/servers.
The command on an EXT 1-4 file system to modify the reserved space is:sudo tune2fs -m % /dev/partition
So in my case of 2% the command looked like sudo tune2fs -m 2 /dev/sda4
To turn off the reserved blocks:sudo tune2fs -m 0 /dev/partition
As with any command that requires superuser privileges you can really mess up your system so use at your own risk.
Experienced Linux hackers probably already figured out that I am running a multi-boot system and choose to keep my partitions simple I have a swap and root partition for Linux and a partition for Windows. If this was a dedicated Linux client I would have done the math and figured out how much space I needed for my root partition, then calculated the space I anticipated for /usr, /var, /tmp, /boot, etc and dedicated the rest to a /home partition. So that is one other variable you need to consider before messing with your reserved blocks. If your setup is using actual drive partitions for each folder then keeping the default 5% or even giving it a little extra on the partitions containing the logs and tmp files makes a lot of sense based on the size of the partition.
Mark Finch - Plan Design Develop Repeat