At Caktus we use LVM2 on a RAID1 device to ease disk management on a number of our servers. Recently I needed to downsize the root partition of one of the servers, so I rebooted onto an Ubuntu 8.10 LiveCD and attempted to load the RAID/LVM info.
The procedure was slightly more complicated than I would have imagined, so I'll document it here in case anyone else finds it useful.
- First, install mdadm and lvm2 on the LiveCD:
apt-get update apt-get install lvm2 mdadm
- Next, scan for and load your RAID drives:
You should see all your RAID drives listed.
mdadm -A -s cat /proc/mdstat
- Then, load the device-mapper kernel module and volume group backup configuration:
Hopefully at this point you will see your volume groups and logical volumes! If the volume group backup is not available, you may have to recover it using dd to read the first few blocks on the underlying device. Google is your friend.
modprobe dm-mod vgcfgrestore vg00 vgscan vgdisplay
- Now, I'll run fsck and downsize the partition:
e2fsck -f /dev/vg00/root resize2fs /dev/vg00/root 10G