April 23, 2009
by Tobias McNulty
0 comments
Categories:
Technical
Tags:
linux, lvm, mdadm, raid

Downsizing an LVM/RAID root partition

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.

  1. First, install mdadm and lvm2 on the LiveCD:
    apt-get update
    apt-get install lvm2 mdadm
    
  2. Next, scan for and load your RAID drives:
    mdadm -A -s
    cat /proc/mdstat
    
    You should see all your RAID drives listed.
  3. Then, load the device-mapper kernel module and volume group backup configuration:
    modprobe dm-mod
    vgcfgrestore vg00
    vgscan
    vgdisplay
    
    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.
  4. Now, I'll run fsck and downsize the partition:
    e2fsck -f /dev/vg00/root
    resize2fs /dev/vg00/root 10G
    
blog comments powered by Disqus