Page Actions
Wiki Actions
User Actions
Submit This Story

linux_lvm_rescue

Couple days before I updated my kernel, and edited my grub.cfg(yes,grub2 -_-!). I found that my lvm is no longer activated on boot. I just fixed it by inserting -doivm param into the grub kernel line. But this gives me a chance to toying with lvm that I never had any interest to do.

Activate By Hand And Tuning

On boot failure about can't find boot dirs, one can enter a simple ash Linux Kernel provided.Then I can do some lvm commands, like:

lvm vgscan
# .or.
lvscan

Will get your lvm scanned:

Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2

This will get vg activated:

lvm vgchange -aly

Checking the activated lvs

lvm lvs
# .or.
lvdisplay

This will display sth like:

LV VG Attr LSize Origin Snap% Move Log Copy%
LogVol00 VolGroup00 -wi-a- xx.xxG
...

Now we have infomations, we can do fsck, resizefs, lvresize in case we need resizing.

Rescue

On a rescue scene, i.e. removed lvm2 package by accident. Any rescue disk with lvm can help us bring up the LVs and mount/chroot to perform tasks. A typical procedure:

cd /mnt
mkdir lvm
vgscan  --ignorelockingfailure --mknodes
lvchange -ay --ignorelockingfailure /dev/VolGroup00/LogVol00
mount /dev/VolGroup00/LogVol00 /mnt/lvm

Now we have LVs up, we can then do chrooting, note that device info and procs should be provided to chrooted enviroment, say in my Gentoo:

cp -L /etc/resolv.conf /LVM/<your_lvm_name>/etc/resolv.conf
mount -t proc none /LVM/<your_lvm_name>/proc
mount -o bind /dev /LVM/<your_lvm_name>/dev
chroot /LVM/<your_lvm_name> /bin/bash
env-update
source /etc/profile

Discussion

Enter your comment
 
 
blog/2011/01/linux_lvm_rescue.txt · Last modified: 2011/01/31 02:01 (external edit)     Back to top
Recent changes RSS feed Creative Commons License Powered by PHP Driven by DokuWiki