resize

Resizing ext3 partitions with parted

A while ago I wanted to enlarge my /home partition (hda6), as it was getting full. After that partition I had another (unused) one, which I intended to merge with hda6 and thereby increase the amount of free disk space on /home.

Here's parts of the disk layout:

hda6 Logical Linux ext3 30848.00
hda7 Logical Linux ext3 8848.00

So, merging hda7 into hda6 should be as simple as removing hda7, and then resizing hda6 to swallow up the 8 gig from the former hda7. Basically, that's how it worked, but I had a few problems. First, at that time is seemed impossible to simply resize ext3 partitions. Neither ext2resize, nor QtParted, nor parted worked for me for some reasons (maybe that has changed recently).

After some googling I finally found a way to do it (which I'll document here, maybe it'll be helpful for others):

  1. Boot from Knoppix, not mounting any partition
  2. Run fsck on both, hda6 and hda7 (optional?)
  3. Remove hda7 (e.g. using cfdisk)
  4. Remove the ext3 journal from hda6 (effectively turning it into an ext2 partition):
    # tune2fs -O^has_journal /dev/hda6
  5. Resize hda6 using parted. The xxxx is the original start of hda6 (you may not change that) and yyyy is the end of the disk:
    # parted
    (parted) resize 6 xxxxx yyyyy
  6. Enable the ext3 journal again on the now enlarged hda6:
    tune2fs -j /dev/hda6
  7. Reboot

But this didn't work from the beginning either — for some strage reason parted didn't believe me that the space after hda6 was free. It did display it as free space, but the "resize" operation complained.

So what I did was this (instead af the above step 3):

  1. Re-add the hda7 partition using, e.g., cfdisk
  2. Start parted, and remove hda7 again from within parted(!):
    # parted
    (parted) rm 7

It seems parted didn't like the way cfdisk removed the hda7 partition... very strange...

Syndicate content