본문 바로가기

Linux

Rescue mode 에서 LVM 인식하기

이전 홈피의 글을 백업 차원에서 옮깁니다. LVM 복구에 관한 질문을 보고 찾아봤던 내용입니다.

2007.08.21 Recovery of RAID and LVM2 Volumes 
오래전부터 정리한다는 것이 LVM 를 사용 안 하다보니 ... 우선 링크만 추가합니다. ^^

출처: http://samfw.blogspot.com/2005/12/lvm-in-rescue-mode.html
LVM in rescue mode

I've had to deal with LVM in rescue mode a few times lately, which has given me some new insight into this stuff:

e2fsck:

  • Boot into rescue mode (in RHEL/Fedora this means putting in CD 1 and typing "linux rescue" at the boot prompt -- but it's essentially any minimal live CD). Rescue mode does not do anything with LVM by defualt: to activiate the volume groups, you need to issue these:

    #lvm vgscan
    #lvm vgchange -ay
    #lvm lvs

  • lvs will simply display your volume group and logical volume names, use this output to issue the e2fsck command: e2fsck /dev/volumegroupname/logicalvolumename. Of course, pass what ever options ot e2fsck you normally would (like -y or -c).
Re-name the / volume group:

  • I never thought I'd have a legitimate reason to do this, until I found myself wanting to back up data from one disc (from a dead system) on to another system. I always choose the default names for VGs and LVs, so when I put my extra disc into my live system it choked finding two volume groups named "VolumeGroup00".


    Take out that second disc, then boot into rescue mode (do not mount anything and do not run the lvm commands from the previous example):

    #vgrename VolumeGroup00 newname

    Where VolumeGroup00 is the old name, and "newname" is the newname. If this was not the root filesystem we would be done and could happily reboot as normal. But, since this IS the root file system, we need to remake the initial ramdisk first (if you don't have one of those, you're off the hook):


    #mount /dev/newname/LogVol00 /mnt/sysimage
    #mount /dev/sda1 /mnt/sysimage/boot
    #chroot /mnt/sysimage
    #cp /boot/initrd-kernelversion.img /boot/kernelversion.img.old
    #mkinitrd -v -f /boot/initrd-kernelversion.img kernelversion

    Don't forget to change all references to the old VG name. Typically this would be in grub.conf and fstab. After that, reboot with that second disc added and you should be fine