Shrinking ext3 partition

*** Make sure you have a back up prior to proceeding. ***

  1. Boot into rescue mode.
  2. Unmount partition if mounted and check disk:
    umount /dev/sda1
    e2fsck -vn /dev/sda1
  3. 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
  4. Force check the partition:
    e2fsck -vf /dev/sda1
  5. 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
  6. Make a note of the blocks and block size. You can also run:
    dumpe2fs /dev/sda1
  7. Delete /dev/sda1 partition and create a smaller one with fdisk:
    fdisk /dev/sda
  8. 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.
  9. Run partprobe and resize2fs utility with no size arguments:
    partprobe /dev/sda
    resize2fs /dev/sda1

    Note: If resize2fs errors out, you may need to further increase the block size by a small percentage (3 to 5%).

  10. Run a disk check for the final time before restoring the journal.
    e2fsck -vn /dev/sda1
    tune2fs -j /dev/sda1
  11. Reboot and check everything in file-system is intact.
Comment