Free Disk Space by Reducing Reserved Blocks
I use a one terabyte external hard drive for backing up data. The drive came formatted with a FAT filesystem, which I immediately replaced with the more reliable ext3. After formatting the drive as ext3 I noticed that the storage capacity had dropped considerably.
Why did this happen? Linux filesystems such as ext3 reserve a percentage of their capacity for privileged processes. In the case that the filesystem fills up, important processes with be able to continue functioning and writing to the disk.
By default 5% of a filesystem will be reserved. For modern high-capacity disks, this is much higher than necessary. On my 1 TB disk, this 5% works out to be 50 GB! If you’ve got a large filesystem, or a filesystem which does not store your Linux system files, it’s safe to reduce the percentage of reserved blocks to free up that disk space.
Use the tune2fs utility to do this. The command below would set the percentage
of reserved blocks on the partition /dev/sdf1
to 1%:
sudo tune2fs -m 1 /dev/sdf1
Be sure to replace /dev/sdf1
with your own path; you can use the df
command
to get a listing of your filesystem device paths and their mount points.
I freed 37 GB of space by changing the reserved blocks to 1% on my TB drive.
Archived Comments
Tom
Scott Wegner:
Yes, reserved blocks are only needed on filesystems that contain OS files.
I haven’t played with ext4 yet, but I’d assume that this will work the same way with it.
ulysess
“The drive came formatted with a FAT filesystem”
is it possible? I thought NTFS is the only way to HD up to a determinated size.
yungchin
I’ve heard that the reserved blocks matter on ext3 to keep your disk from fragmenting too fast, but haven’t been able to find reliable info about this so far… would you know how that works by any chance?
Benoe
Hi!
Is it safe to issue this command on a disk with full of data, without losing them?
And if it is a raid array, I should issue it for /dev/md0, right?
brandonban6
Thanks Tom,
I love your site and am really excited to see you posting again.
take care!
Emil Begtrup-Bright
When I use the command like this:
sudo tune2fs -m 1 /dev/sdb1
I get this error message:
tune2fs: Bad magic number in super-block while trying to open /dev/sdb1
Couldn’t find valid filesystem superblock.
It’s a 1 TB external HDD, filesystem is JFS. strange!
leeph
“I get this error message:
tune2fs: Bad magic number in super-block while trying to open /dev/sdb1
Couldn’t find valid filesystem superblock.
It’s a 1 TB external HDD, filesystem is JFS. strange!“
Well no wonder, tune2fs is for ext filesystems, not JFS, you idiot!
kcbanner
I just tried this on my ext4 /home partition and it works fine! Great article.
Vadim P.
Hold on the ext4 rush: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/317781 [Ext4 data loss] (and no, it’s not a ubuntu-specific bug, it’s a gnome/kde problem on all distros)
Pete
In gigabytes, what would you recommend as a reasonable amount of space to be kept as reserved?
the_maplebar
Thanks, very handy. I also have a 1TB storage drive and was and was a little bothered at how much space was used when formated to ext3. Now I know why and how to fix it.
Tom
ulysess:
The drive came with a text file recommending that it be reformatted to NTFS.
FAT32 filesystems work up to 2 TB but the maximum file size is pretty small.
yungchin:
If the filesystem gets too full fragmentation could become a problem. AFAIK,
keeping some free space, whether it’s reserved or not, is a good idea.
Benoe:
The command should be safe even with a full disk. I’m not familiar with RAID
arrays.
Emil Begtrup-Bright:
That error sounds like tune2fs doesn’t recognize the filesystem type.
Pete:
I’m only guessing, but 1 GB reserved should be more than enough to keep your
system working in case the disk fills up.
Jesse Taylor
Thanks - very useful tip. I saved about 20 gigs with this!
scott
Works for LVM as well:
~]# tune2fs -m 1 /dev/mapper/SysVolGroup-LogVolRoot
tune2fs 1.39 (29-May-2006)
Setting reserved blocks percentage to 1% (609894 blocks)
Scott Wegner
Nice tip! I recently purchased a 1 TB drive as well, for backups. Assuming I have other disks with “reserved space”, is it safe to drop the reserved space on this drive to 0?
Also, is this tip still relevant if I later reformat to ext4 (when Jaunty is released)?