Resize an LVM disk and FS
Resize the partition using LVM:
sudo lvextend -L30G /dev/mapper/VolGroup00-LogVol05
Unmount the partition (hopefully it isn’t the root!):
sudo umount /dev/mapper/VolGroup00-LogVol05
Check the FS for errors
sudo e2fsck -f /dev/mapper/VolGroup00-LogVol05
Adjust the FS to the new size
sudo resize2fs /dev/mapper/VolGroup00-LogVol05
Remount the disk
sudo mount /dev/mapper/VolGroup00-LogVol05 /home
Resizing Ext3 Partitions
These were the basic steps I had to go through to resize a partition inside of a DRBD disk device. I think a similar procedure would be needed to resize the disk inside a file based disk image.
- Check the partition info using parted’s “print” command
Number Start End Size Type File system Flags
1 32.3kB 107MB 107MB primary ext3
2 107MB 625MB 518MB primary linux-swap
3 625MB 6926MB 6301MB primary ext3
In this case I wanted to resize partition #3, since it was on a 10GB device with free space behind it.
- Use kpartx to make the individual partitions in the device accessible: kpartx -a /dev/drbd1
- This makes it so you can access the partitions at: /dev/mapper/drbd1p#
- Check the file system: e2fsck -f -v /dev/mapper/drbd1p3
- Convert to ext2 FS: tune2fs -O ^has_journal /dev/mapper/drbd1p3
- Resize the partition — I couldn’t use the resize command in parted properly, so instead I deleted the partition, then recreated it. Make sure you write down the start point!
- Convert back to ext3: tune2fs -j /dev/mapper/drbd1p3
- Rerun the e2fsck command to double check it
- I think that’s it