Extending ext3 partition
Sat, 12/19/2009 - 14:09 — sandip*** Make sure you have a back up prior to proceeding. ***
- Boot into rescue mode.
- Unmount partition if mounted and check disk:
umount /dev/sda1
e2fsck -vn /dev/sda1 - Delete /dev/sda1 partition and create a bigger one with fdisk:
fdisk /dev/sda
- Recreate the partition /dev/sda1 with the starting point at the default location and the ending point at highest possible cylinder. (Note: if you are extending by merging two partitions, the data in the second partition is lost so make sure to backup data you need.)
- Run partprobe and resize2fs utility with no size arguments:
partprobe /dev/sda
resize2fs /dev/sda1 - Reboot and check everything in file-system is intact.
- sandip's blog
- Login or register to post comments
Shrinking ext3 partition
Sat, 12/19/2009 - 00:59 — sandip*** Make sure you have a back up prior to proceeding. ***
- Boot into rescue mode.
- Unmount partition if mounted and check disk:
umount /dev/sda1
e2fsck -vn /dev/sda1 - Remove journaling from ext3 partition and revert to ext2, as resize2fs does not work on ext3 partition. (Note: This step should not be necessary in recent kernels.)
tune2fs -O ^has_journal /dev/sda1
- Force check the partition:
e2fsck -vf /dev/sda1
- Resize the partition making sure that you don't shrink it lesser than the disk space currently used else you may lose data.
resize2fs /dev/sda1 6000M
- Make a note of the blocks and block size. You can also run:
dumpe2fs /dev/sda1
- Delete /dev/sda1 partition and create a smaller one with fdisk:
fdisk /dev/sda
- Recreate the partition /dev/sda1 with the starting point at the default location and the ending point at number of blocks from the resize2fs output (1536000) multiplied by the size of a block (4K). So, the end point would be 1536000 * 4 = 6144000K.
- Run partprobe and resize2fs utility with no size arguments:
partprobe /dev/sda
resize2fs /dev/sda1Note: If resize2fs errors out, you may need to further increase the block size by a small percentage (3 to 5%).
- Run a disk check for the final time before restoring the journal.
e2fsck -vn /dev/sda1
tune2fs -j /dev/sda1 - Reboot and check everything in file-system is intact.
- sandip's blog
- Login or register to post comments