Hi All,<br><br>I have several Xen virtual machines within logical volumes using LVM2. I did not use disk images for performance reasons.<br><br>Conventionally, if I want to clone my virtual machines, I have to dd the LV to an image file. But this consumes a lot of time and harddisk space.<br>
<br>So, instead of doing that, I want to use losetup and kpartx with my logical volumes, which contain operating systems of virtual machines.<br><br>I can backup the filesystems of a virtual machine in this way:<br><br># losetup /dev/loop1 /dev/virtualmachines/windows7-x64<br>
<br>virtualmachines is the name of my volume group.<br><br>windows7-x64 is the logical volume.<br><br># kpartx -av /dev/loop1<br><br>Then I would see the partitions of the virtual machine within a logical volume, like so:<br>
<br>/dev/mapper/loop1p1<br>/dev/mapper/loop1p2<br>/dev/mapper/loop1p3<br><br>Now that I can access the partitions of the virtual machine within a logical volume, I can use partimage or fsarchiver to backup the partitions (provided the filesystem is supported by the archiver).<br>
<br>But the problem is that I can only backup/clone the filesystems of my virtual machine within a logical volume. I can't backup the Master Boot Record (MBR) of the virtual machine within a logical volume. For example, <br>
<br>dd if=/dev/hda of=mbr.hda bs=512 count=1<br><br>Because /dev/hda resides in a logical volume. The logical volume is a virtual harddisk for my virtual machine.<br><br>I would like to know how to backup and also restore the MBR of my virtual machine/guest operating system/domU within a logical volume because the losetup and kpartx procedure only allows me access to the partitions, not the MBR. A complete backup of a virtual machine (and also a bare metal machine) includes the MBR and all filesystems.<br>
<br>If there is a catastrophic failure with my logical volumes containing domUs, I would like to<br><br>1) re-create the physical volume (PV)<br><br>2) re-create the volume group<br><br>3) assign the PV to the volume group<br>
<br>4) restore the LVM metadata, i.e. the configuration files for all the logical volumes<br><br>5) restore the MBR of my domU<br><br>6) restore the filesystems of my domU<br><br>Please advise.<br><br>Thank you very much.<br clear="all">
<br>-- <br>Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics) BEng(Hons)(Mechanical Engineering)<br>Alma Maters:<br>(1) Singapore Polytechnic<br>(2) National University of Singapore<br>My Primary Blog: <a href="http://teo-en-ming-aka-zhang-enming.blogspot.com">http://teo-en-ming-aka-zhang-enming.blogspot.com</a><br>
My Secondary Blog: <a href="http://enmingteo.wordpress.com">http://enmingteo.wordpress.com</a><br>My Youtube videos: <a href="http://www.youtube.com/user/enmingteo">http://www.youtube.com/user/enmingteo</a><br>Email: <a href="mailto:space.time.universe@gmail.com">space.time.universe@gmail.com</a><br>
Mobile Phone (Starhub Prepaid): +65-8369-2618<br>Street: Bedok Reservoir Road<br>Country: Singapore<br>