Friday, February 19, 2010

Rename Volume Group and then mount LVM on another host

From:

https://bugzilla.redhat.com/show_bug.cgi?id=230190

The only modification I had to make was to pass /bin/bash in for the shell with chroot since zsh wasn’t installed by default on my Red Hat 5 image.

Daryl Hochhalter 2007-12-30 12:52:51 EST
LVM VGRENAME FEDORA 8 SYSTEM ROOT THE FOLLOWING STEPS: (WORKED FOR ME!)

1. boot from Fedora livecd logon as root
2. /sbin/swapoff -a
3. Deactivate with: /sbin/lvm vgchange -a n
4. Rename VG's and LV's with /sbin/lvm [vg | lv]rename oldname newname
5. Reactive with: /sbin/lvm vgchange -a y
6. umount /media/_boot
7. mkdir /mnt/sysimage
8. mount /dev/newname/newname /mnt/sysimage
9. mount /dev/sdaX /mnt/sysimage/boot
10. Make /dev/root with: mknod /dev/root b lv_kernel_major lv_kernel_minor
(You might try $(/sbin/lvm lvs --noheadings --separator " " --options
lv_kernel_major,lv_kernel_minor)
as a variable for mknod or just use /sbin/lvm lvs -v to first get the
major,minor values.
11. Bind /dev with: mount -o bind /dev /mnt/sysimage/dev
12. chroot /mnt/sysimage [/bin/bash – dave had to add this]
13. umount {proc,sys} (probably not even mounted)
14. mount -t proc proc /proc
15. mount -t sysfs sysfs /sys
16. Open /mnt/sysimage/boot/grub/grub.conf & /mnt/sysimage/etc/fstab with gedit
and change oldnames to newnames. (ie. VolGroup00 to NewVolGroup and LogVol00
to NewLogVol) You could cd to directories under newroot and use VI to.
17. Make New initrd for each kernel: mkinitrd -f -v /boot/initrd-XVERX.img XVERX
18. umount {proc,sys,dev}
19. exit
20. umount /mnt/sysimage/boot
21. umount /mnt/sysimage
22. reboot (remove CD from Drive)

I was then able to shut down the VM Guest and mount the LVM on the host with the following commands:

kpartx –a /dev/VolGroup00/LVGuest00 (or whatever the logical volume of the guest vm is) – this adds the correct device maps for the volume group

vgchange –ay VM_VG_00 (or whatever the guest’s volume group name is)

mount /dev/VM_VG_00/LogVol00 /mnt/test (works now… if you want boot, you have to boot the device associated with partition 1 of the LVGuest00 LVM of the host which exists in /dev/mapper/LVGuest00p1 – not sure if it exists before or after the kpartx command)

Message

No comments:

Post a Comment