Accessing LVMs from CentOS Rescue

Recently, I had the fun (pain) of recovering a CentOS box with a corrupted logical volume. Below are the steps I took.

1. Boot to a CD/DVD and enter rescue mode from the menu
2. When the menu option for automatically mounting is offered, select no
3. Create a space to mount the disk. If you’re a purest, /mnt/sysimage is fine
4. Next, key in “lvm vgscan -v”
5. Now that we have the disk, we can tell the kernel about the vg, we do this with “lvm vgchange -a y”
6. You should have received a message about the vg being active now, great now we can mount the logical volumes like you would with a physical drive. Use lvm lvs –all to list all the available logical volumes.

in my case, my lv_home became corrupt. Not sure what happened, but we’ll take a look at logs later.

To remove the lv, we’ll do:

lvremove /dev/mapper/vg_name_lv_home

CentOS will prompt us if we’re sure we want to do this. You can use -an to automatically respond yes if you find yourself scripting this.

Now, we’ll recreate the logic volume.

lvcreate -L <size> -n lv_home vg_name

Don’t forget to format the new lv!

mkfs.ext4 /dev/mapper/vg_name_lv_home

Now you can mount the drive to /mnt/sysimage/home

or just reboot.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s