Howto resize an ext2/3 filesystem on a partition or an image of a partition

Unmount disk or image
umount /dev/sda1
fsck -n /dev/sda1

Next we remove the journal from /dev/sda1, thus turning it into an ext2 partition:
tune2fs -O ^has_journal /dev/sda1

And fsck again..
e2fsck -f /dev/sda1

Now we resize our file system with resize2fs. resize2fs can resize ext2 file systems, but not ext3 file systems, that’s why we had to turn /dev/sda1 to ext2. Currently, 4.1GB are used on /dev/sda1 (see the df -h output above), So it’s safe to shrink it from 10GB to about 6GB (if you make it smaller than 4.1GB, you will lose data!). Therefore we run
resize2fs /dev/sda1 6000M

Aaaaand fsck again…
fsck -n /dev/sda1

Then we create the journal on our new /dev/sda1, thus turning it into an ext3 partition again:
tune2fs -j /dev/sda1

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

Tags: , , , , , , ,

Leave a Reply