Home > linux > Resizing partitions: The forgotten resize2fs

Resizing partitions: The forgotten resize2fs

So you want to resize one of your partitions. If you’re using ext2/ext3, and the FS is larger than usual (mine was 170 GB), parted (otherwise a pretty neat tool) may fail on you with this message:

1
No Implementation: This ext2 file system has a rather strange layout!  Parted can't resize this (yet)

This happens with parted 1.6.25.1 (the current stable version). The parted FAQ says that new code has been added in 1.7 to address this; however 1.7.0rc5 fails with a creepy error message, and an apology for me having run into a bug :)

Not more than a Google search away, I found the venerable resize2fs, which did the job perfectly.

When using resize2fs however, there is some additional work that you have to do. More specifically, resize2fs will resize the filesystem itself, not the underlying partitions. You must use fdisk (or equivalents) to enlarge the partition before growing the fs, or to cut the partition after shrinking the fs.

You should also NOT run resize2fs (or any other fs manipulation tool, for that matter) except on a CLEAN and consistent filesystem. Run e2fsck before and after resizing.

And finally, you may want to make sure that what you’re resizing is an ext2 filesystem, and not the newer ext3. As a reminder, to convert from ext3 to ext2, use

1
 # tune2fs -O^has_journal /dev/sdaX

And, after you’ve grown/shrunk your partition, you can go back to ext3 with:

1
 # tune2fs -j /dev/sdaX

Don’t forget to update your fstab.

Good luck!

Categories: linux
  1. No comments yet.
  1. No trackbacks yet.