Disclaimer: Following my instructions will destroy all your data.
Figure out where you should be
If you are trying to resize a partition that is easily unmounted (say /mnt/something etc) then you are good to go. Unmount it. Otherwise, you will want to boot from a live cd with the tool resize2fs.
Figure out how big it should be
Run the command: df -h
Figure out what partitions you actually have
Run the command: fdisk -l
If you don’t see anything, its because you need to be root.
Turn off the journal (this step is ext3 only):
Run the command: tune2fs -O ^has_journal /dev/hda1
Replace hda1 with the device name of the partition we are resizing.
Check the filesystem:
Run the command: e2fsck -f /dev/hda1
Actually resize it:
Run the command: resize2fs /dev/hda1 2G
2G is the desired size. This could also be 2000M, 2000000K etc if you need more accuracy.
Resize the partition
Run the command: fdisk /dev/hda
First, delete the old partition, noting where it starts and stops. resize2fs will tell you how big the new size is, and multiply that times 4 to get where the partition should end (start position + (resize2fs output * 4) = end position). Also you may need to make it a touch bigger, as if the partition is too small data will be lost! Make sure to write partition data, then reboot.
Turn the journal back on
Run the command: tune2fs -j /dev/sda1
Reboot
Related posts:
Pingback: The ongoing struggle » Blog Archive » Or, just use LVM
#1 by jdong on March 27, 2007 - 11:16 pm
Quote
Turn the journal back on
Run the command: tune2fs -O ^has_journal /dev/sda1
That should be “tune2fs -j /dev/sda1″, -O ^has_journal does the opposite
#2 by Floris on March 28, 2007 - 7:32 am
Quote
I’m curious, why do you turn off the journal during the resize operation? I never do that and haven’t found any corrupt data afterwards.
#3 by admin on March 28, 2007 - 10:02 am
Quote
Actually the turning the journal part off might be a legacy provision, from when ext3 was newer. I don’t see anything in the man page of the resize2fs from feisty about turning off journals.