Tuesday, June 5, 2007

Cloning lvm partition and booting from it

Problem: when bit-for-bit cloning a partition with a LVM system root results in duplicate physical volume ID's, and it is not possible to select which partition to boot into.

g4l partition clone hda2 into hda3

boot, will complain of duplicate PV ID but should load one of hda2/3

use vgscan to figure out which partition is in use (my case hda2)

edit /etc/lvm/lvm.conf find filter section and change filter to the following (my case, reject hda3):
filter = [ "r/hda3/", "a/.*/" ]

that will get rid of the warnings post-boot. to gain control over which is used at boot time, have to modify initrd. google "modify initrd", when you have it extracted edit its etc/lvm/lvm.conf as above. when you repack the img, name it _ignorehda3. put it into /boot/ next to the original.

do the same for _ignorehda2

edit grub.conf, copy the default/preferred option and paste it twice. change initrd to _ignorehda3 and _ignorehda2, give them nice display names such as "Original on hda2" and"Clone on hda3" respectively.

It is actually possible to change the uuid of the physical volume of the backup using pvchange -u, so that you can mount the backup. It is unclear whether this impacts your ability to boot off the backup.

No comments: