Hardware, HowTo’s, and the Haps of a Texan!

Kevin Blalock

September 16, 2008

Reclaiming ext3 disk space

No Gravatar

The other day while working on my GPT article, I had noticed that there was alot of space being used with a clean partition and zero data on the drive. What is this about? So, I hit up Google. I found the following:

The most likely reason is reserved space. When an ext2/3 file system is formated by default 5% is reserved for root. Reserved space is supposed to reduce fragmentation and allow root to login in case the file system becomes 100% used. You can use tune2fs to reduce the amount of reserved space.

So, let’s put some real numbers into play here. Going back to my previous post, I had setup an array with roughly 2.25TB of raw storage. While formatting it with the ext3 file system, and considering it reserves 5% of space, I have roughly 112.5GB of space used. In the grand scheme of things, 112GB is nothing in comparison to 2.25TB, yet 112GB is not a small amount in my book. This brings me to my next question; can I and should I reduce that amount of reserved space? More information from my google quest:

The reserved blocks are there for root’s use. The reason being that the system gets really narky if you completely run out of room on / (specifically /var, or /tmp, I think). Programs won’t start, wierd errors will pop up, that sort of thing. With some room reserved for root, you can at least be sure to be able to run the really important programs, like sudo and rm .

So, in short, if the drive doesn’t contain /var or /tmp, then there’s not much point in having space reserved for root.

It sounds pretty cut and dry to me. Give me my precious storage back! The general consensus around the internet is to go ahead and resize but to be safe, use 1%. I spoke to one of my fellow co-workers  about this and he told me the same as my google findings, and that if it is just a pure storage drive, don’t worry about reserving any space. I have yet to try this out on my personal file server at home. I need to do a full backup first. It would be interesting to see the results however as I have 4.5TB of raw storage with about 4.2TB of actual space available.

Enough theory, let’s get down to the command line!

First, let’s unmount the drive (assuming the drive is recognized as /dev/sdb):

umount /dev/sdb1

Here comes the meat and potato’s! For ext2 and ext3 file system’s, we must use tune2fs.

tune2fs -m 1 /dev/sdb1

From the tune2fs man page, it tells us that the -m flag set’s the reserved-blocks-percentage. Simple enough. Now,  just to be on the safe side, I would suggest running a fsck (file system check) after this operation is complete before re-mounting the file system. I would read up on the man pages, but something to the effect of this command line should work well:

fsck.ext3 -pcfv /dev/sdb1

As always, I recommend you to do some google searching and read up on the man pages for any further information not presented in my post here!

Leave a Reply