On Fri, Nov 13, 2009 at 9:17 PM, Dustin Henning <[email protected]>wrote:
> As you are running Windows, I will assume that you are using HVM, > and therefore that /dev/virtualmachines/windows7-x64 is a hard disk image. > As such, the command you listed will back up the MBR, including the > partition table. That isn't to say that Windows 7 doesn't have additional > boot information outside of the MBR, but that information would be included > in a file system backup. Wikipedia has the structure of the MBR in a table > at http://en.wikipedia.org/wiki/Master_boot_record. On that note, I often > use bs=446 when I want the MBR without the partition table, but if you are > backing up the partition as opposed to the file structure, then you might > as > well keep the partition table (or even just back up the image). > Dustin > > From: [email protected] [mailto:[email protected]] > On Behalf Of Mr. Teo En Ming (Zhang Enming) > Sent: Thursday, November 12, 2009 04:45 > To: Geert Janssens > Cc: Community assistance, encouragement, and advice for using Fedora.; > [email protected]; Fedora Xen > Subject: [Fedora-xen] Re: [Xen-users] How to Backup and Restore MBR within > Logical Volumes? > > > dd if=/dev/virtualmachines/windows7-x64 of=mbr.w7-x64 bs=512 count=1 > > I think if you do this, you are only backing up the first 512 bytes of the > logical volume, not the MBR. > > Someone correct me if I am wrong. > > -- > Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics) BEng(Hons)(Mechanical > Engineering) > Alma Maters: > (1) Singapore Polytechnic > (2) National University of Singapore > My Primary Blog: http://teo-en-ming-aka-zhang-enming.blogspot.com > My Secondary Blog: http://enmingteo.wordpress.com > My Youtube videos: http://www.youtube.com/user/enmingteo > Email: [email protected] > Mobile Phone (Starhub Prepaid): +65-8369-2618 > Street: Bedok Reservoir Road > Country: Singapore > On Thu, Nov 12, 2009 at 9:36 AM, Geert Janssens <[email protected]> wrote: > On Thursday 12 November 2009, Mr. Teo En Ming (Zhang Enming) wrote: > > Hi All, > > > > I have several Xen virtual machines within logical volumes using LVM2. I > > did not use disk images for performance reasons. > > > > 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. > > > > So, instead of doing that, I want to use losetup and kpartx with my > logical > > volumes, which contain operating systems of virtual machines. > > > > I can backup the filesystems of a virtual machine in this way: > > > > # losetup /dev/loop1 /dev/virtualmachines/windows7-x64 > > > Are you sure you need to call losetup first ? > > I remember I used kpartx directly on the lvm containing my vbd. > > Also, I think you can treat the lvm based vbd as a real disk. > > So > dd if=/dev/virtualmachines/windows7-x64 of=mbr.w7-x64 bs=512 count=1 > > should backup your mbr. > > Anyone correct me if I'm wrong please. > > Geert > > -- > Kobalt W.I.T. > Web & Information Technology > Brusselsesteenweg 152 > 1850 Grimbergen > > Tel : +32 479 339 655 > Email: [email protected] > > > _______________________________________________ > Xen-users mailing list > [email protected] > http://lists.xensource.com/xen-users > > > > > > Hi Dustin, The MBR backup guide that I was following is this one: Article: MBR tricks with LinuxLink: http://www.tuxation.com/mbr-tricks-with-linux.htmlHere is the final version of my data restore script. Could you check if there are mistakes in it? <SCRIPT> #!/bin/sh ############################################################################################################### ############################################################################################################### # Script to Restore Xen Host/Dom0 and all DomUs which are using Logical Volumes as Virtual Hard Disks ############################################################################################################### ############################################################################################################### # Written by: # Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics) BEng(Hons)(Mechanical Engineering) # Alma Maters: # (1) Singapore Polytechnic # (2) National University of Singapore # Primary Blog: http://teo-en-ming-aka-zhang-enming.blogspot.com # Secondary Blog: http://enmingteo.wordpress.com # Youtube Videos: http://www.youtube.com/user/enmingteo # Xen Tutorials and Video Demos: http://www.xen.org/support/tutorial.html # Email: [email protected] # MSN: [email protected] # Mobile Phone (Starhub Prepaid): +65-8369-2618 # Street: Bedok Reservoir Road # Country: Singapore # First written: 13 November 2009 Friday 6:49 P.M. Singapore time # Last updated: 13 November 2009 Friday 8:25 P.M. Singapore time # Last updated: 13 November 2009 Friday 8:59 P.M. Singapore time # Last updated: 13 November 2009 Friday 9:40 P.M. Singapore time # REFERNCE: "Geek Sheet: Bare-metal backup and recovery", May 7th, 2008, Jason Perlow # URL: http://blogs.zdnet.com/BTL/?p=8759 # Usage Instructions: # Boot up your desktop/server with System Rescue CD version 1.3.2 for i386/amd64. # Then execute this restore script. You need to adapt this script to work for your environment. # Download System Rescue CD from http://www.sysresccd.org/Main_Page # No. of QC Checks Performed on this restore script: 1 ############################################################################################################### # Declare Variables ############################################################################################################### HARDDISK=/dev/sda SOURCE=/media/hitachi/test ############################################################################################################### ############################################################################################################### # Restoring Xen Host/Dom0 ############################################################################################################### ############################################################################################################### # Restore the Master Boot Record dd if=$SOURCE/f11-xen-dom0-sda.mbr of=$HARDDISK bs=512 count=1 # Restore the Partition Geometry sfdisk $HARDDISK < $SOURCE/f11-xen-dom0-partition-geometry-sda.sfdisk # Re-create the LVM2 PV containing the host operating system/dom0 pvcreate --uuid ??? /dev/sda2 # Re-create the LVM2 PV containing all the virtual machines pvcreate --uuid ??? /dev/sda3 # Restore the LVM2 metadata for the volume group containing the host operating system/dom0 vgcfgrestore --file $SOURCE/vg_fedora11_host-vgcfg.lvm2.metadata vg_fedora11_host # Restore the LVM2 metadata for the volume group containing all the virtual machines vgcfgrestore --file $SOURCE/virtualmachines-vgcfg.lvm2.metadata virtualmachines # Activate all the volume groups vgchange -ay # Restore all filesystems for the host operating system/dom0 fsarchiver restfs -v $SOURCE/f11-xen-dom0-filesystems.fsa id=0,dest=/dev/sda1 \ id=1,dest=/dev/vg_fedora11_host/lv_home \ id=2,dest=/dev/vg_fedora11_host/lv_root \ id=3,dest=/dev/vg_fedora11_host/lv_var # Re-create the swap partition mkswap /dev/vg_fedora11_host/lv_swap ############################################################################################################### ############################################################################################################### # Restoring Xen-based Virtual Machines/DomUs/Guest Operating Systems/VMs ############################################################################################################### ############################################################################################################### ### NOTE: Check for swap partitions in each virtual machine and do a mkswap. # VM 1: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center) ############################################################################################################### zcat $SOURCE/virtualmachines-f11-pv-hpc-node0001.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0001 # VM 2: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center) ############################################################################################################### zcat $SOURCE/virtualmachines-f11-pv-hpc-node0002.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0002 # VM 3: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center) ############################################################################################################### zcat $SOURCE/virtualmachines-f11-pv-hpc-node0003.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0003 # VM 4: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center) ############################################################################################################### zcat $SOURCE/virtualmachines-f11-pv-hpc-node0004.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0004 # VM 5: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center) ############################################################################################################### zcat $SOURCE/virtualmachines-f11-pv-hpc-node0005.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0005 # VM 6: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center) ############################################################################################################### zcat $SOURCE/virtualmachines-f11-pv-hpc-node0006.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0006 # VM 7: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center) ############################################################################################################### zcat $SOURCE/virtualmachines-f11-pv-hpc-node0007.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0007 # VM 8: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center) ############################################################################################################### zcat $SOURCE/virtualmachines-f11-pv-hpc-node0008.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0008 # VM 9: FreeBSD 8.0 RC2 UNIX amd64 HVM domU ############################################################################################################### zcat $SOURCE/virtualmachines-freebsd.img.gz | dd of=/dev/virtualmachines/freebsd # VM 10: OpenSolaris 2009.06 UNIX amd64 PV domU ############################################################################################################### zcat $SOURCE/virtualmachines-opensolaris.img.gz | dd of=/dev/virtualmachines/opensolaris # VM 11: Rocks 5.1 x86_64 HPC Compute Cluster HVM domU (based on CentOS 5.2) ############################################################################################################### # Add partition mappings in /dev/mapper kpartx -av /dev/virtualmachines/rocks0001 # Restore MBR dd if=$SOURCE/virtualmachines-rocks0001.mbr of=/dev/virtualmachines/rocks0001 bs=512 count=1 # Restore partition geometry sfdisk /dev/virtualmachines/rocks0001 < $SOURCE/virtualmachines-rocks0001.sfdisk # Restore all filesystems partimage -e -b restore /dev/mapper/virtualmachines-rocks0001p1 $SOURCE/virtualmachines-rocks0001p1.img.000 partimage -e -b restore /dev/mapper/virtualmachines-rocks0001p2 $SOURCE/virtualmachines-rocks0001p2.img.000 partimage -e -b restore /dev/mapper/virtualmachines-rocks0001p5 $SOURCE/virtualmachines-rocks0001p5.img.000 # Re-create swap mkswap /dev/mapper/virtualmachines-rocks0001p3 # Delete partition mappings in /dev/mapper kpartx -dv /dev/virtualmachines/rocks0001 # VM 12: Rocks 5.1 x86_64 HPC Compute Cluster HVM domU (based on CentOS 5.2) ############################################################################################################### # Add partition mappings in /dev/mapper kpartx -av /dev/virtualmachines/rocks0002 # Restore MBR dd if=$SOURCE/virtualmachines-rocks0002.mbr of=/dev/virtualmachines/rocks0002 bs=512 count=1 # Restore partition geometry sfdisk /dev/virtualmachines/rocks0002 < $SOURCE/virtualmachines-rocks0002.sfdisk # Restore all filesystems partimage -e -b restore /dev/mapper/virtualmachines-rocks0002p1 $SOURCE/virtualmachines-rocks0002p1.img.000 partimage -e -b restore /dev/mapper/virtualmachines-rocks0002p2 $SOURCE/virtualmachines-rocks0002p2.img.000 partimage -e -b restore /dev/mapper/virtualmachines-rocks0002p5 $SOURCE/virtualmachines-rocks0002p5.img.000 # Re-create swap mkswap /dev/mapper/virtualmachines-rocks0002p3 # Delete partition mappings in /dev/mapper kpartx -dv /dev/virtualmachines/rocks0002 # VM 13: Rocks 5.1 x86_64 HPC Compute Cluster HVM domU (based on CentOS 5.2) ############################################################################################################### # Add partition mappings in /dev/mapper kpartx -av /dev/virtualmachines/rocks0003 # Restore MBR dd if=$SOURCE/virtualmachines-rocks0003.mbr of=/dev/virtualmachines/rocks0003 bs=512 count=1 # Restore partition geometry sfdisk /dev/virtualmachines/rocks0003 < $SOURCE/virtualmachines-rocks0003.sfdisk # Restore all filesystems partimage -e -b restore /dev/mapper/virtualmachines-rocks0003p1 $SOURCE/virtualmachines-rocks0003p1.img.000 partimage -e -b restore /dev/mapper/virtualmachines-rocks0003p2 $SOURCE/virtualmachines-rocks0003p2.img.000 partimage -e -b restore /dev/mapper/virtualmachines-rocks0003p5 $SOURCE/virtualmachines-rocks0003p5.img.000 # Re-create swap mkswap /dev/mapper/virtualmachines-rocks0003p3 # Delete partition mappings in /dev/mapper kpartx -dv /dev/virtualmachines/rocks0003 # VM 14: Rocks 5.1 x86_64 HPC Compute Cluster HVM domU (based on CentOS 5.2) ############################################################################################################### # Add partition mappings in /dev/mapper kpartx -av /dev/virtualmachines/rocks0004 # Restore MBR dd if=$SOURCE/virtualmachines-rocks0004.mbr of=/dev/virtualmachines/rocks0004 bs=512 count=1 # Restore partition geometry sfdisk /dev/virtualmachines/rocks0004 < $SOURCE/virtualmachines-rocks0004.sfdisk # Restore all filesystems partimage -e -b restore /dev/mapper/virtualmachines-rocks0004p1 $SOURCE/virtualmachines-rocks0004p1.img.000 partimage -e -b restore /dev/mapper/virtualmachines-rocks0004p2 $SOURCE/virtualmachines-rocks0004p2.img.000 partimage -e -b restore /dev/mapper/virtualmachines-rocks0004p5 $SOURCE/virtualmachines-rocks0004p5.img.000 # Re-create swap mkswap /dev/mapper/virtualmachines-rocks0004p3 # Delete partition mappings in /dev/mapper kpartx -dv /dev/virtualmachines/rocks0004 # VM 15: Rocks 5.1 x86_64 HPC Compute Cluster HVM domU (based on CentOS 5.2) ############################################################################################################### # Add partition mappings in /dev/mapper kpartx -av /dev/virtualmachines/rocks0005 # Restore MBR dd if=$SOURCE/virtualmachines-rocks0005.mbr of=/dev/virtualmachines/rocks0005 bs=512 count=1 # Restore partition geometry sfdisk /dev/virtualmachines/rocks0005 < $SOURCE/virtualmachines-rocks0005.sfdisk # Restore all filesystems partimage -e -b restore /dev/mapper/virtualmachines-rocks0005p1 $SOURCE/virtualmachines-rocks0005p1.img.000 partimage -e -b restore /dev/mapper/virtualmachines-rocks0005p2 $SOURCE/virtualmachines-rocks0005p2.img.000 partimage -e -b restore /dev/mapper/virtualmachines-rocks0005p5 $SOURCE/virtualmachines-rocks0005p5.img.000 # Re-create swap mkswap /dev/mapper/virtualmachines-rocks0005p3 # Delete partition mappings in /dev/mapper kpartx -dv /dev/virtualmachines/rocks0005 # VM 16: Slackware64 13.0 amd64 HVM domU ############################################################################################################### # Add partition mappings in /dev/mapper kpartx -av /dev/virtualmachines/slackware64 # Restore MBR dd if=$SOURCE/virtualmachines-slackware64.mbr of=/dev/virtualmachines/slackware64 bs=512 count=1 # Restore partition geometry sfdisk /dev/virtualmachines/slackware64 < $SOURCE/virtualmachines-slackware64.sfdisk # Restore all filesystems partimage -e -b restore /dev/mapper/virtualmachines-slackware64p1 $SOURCE/virtualmachines-slackware64p1.img.000 partimage -e -b restore /dev/mapper/virtualmachines-slackware64p2 $SOURCE/virtualmachines-slackware64p2.img.000 # Re-create swap mkswap /dev/mapper/virtualmachines-slackware64p3 # Delete partition mappings in /dev/mapper kpartx -dv /dev/virtualmachines/slackware64 # VM 17: Ubuntu 9.10 Karmic Koala Linux HVM domU ############################################################################################################### # Add partition mappings in /dev/mapper kpartx -av /dev/virtualmachines/ubuntu910 # Restore MBR dd if=$SOURCE/virtualmachines-ubuntu910.mbr of=/dev/virtualmachines/ubuntu910 bs=512 count=1 # Restore partition geometry sfdisk /dev/virtualmachines/ubuntu910 < $SOURCE/virtualmachines-ubuntu910.sfdisk # Restore all filesystems partimage -e -b restore /dev/mapper/virtualmachines-ubuntu910p1 $SOURCE/virtualmachines-ubuntu910p1.img.000 # Re-create swap mkswap /dev/mapper/virtualmachines-ubuntu910p5 # Delete partition mappings in /dev/mapper kpartx -dv /dev/virtualmachines/ubuntu910 # VM 18: Windows XP Home Edition SP3 32-bit HVM domU with VGA passthrough (requires Intel VT-d) ############################################################################################################### # Add partition mappings in /dev/mapper kpartx -av /dev/virtualmachines/winxphome32 # Restore MBR dd if=$SOURCE/virtualmachines-winxphome32.mbr of=/dev/virtualmachines/winxphome32 bs=512 count=1 # Restore partition geometry sfdisk /dev/virtualmachines/winxphome32 < $SOURCE/virtualmachines-winxphome32.sfdisk # Restore all filesystems partimage -e -b restore /dev/mapper/virtualmachines-winxphome32p1 $SOURCE/virtualmachines-winxphome32p1.img.000 # Delete partition mappings in /dev/mapper kpartx -dv /dev/virtualmachines/winxphome32 ############################################################################################################### ############################################################################################################### # Deactivate Logical Volume Manager vgchange -an # Sync filesystems sync # Reboot the machine reboot ############################################################################################################### # EOF ############################################################################################################### </SCRIPT> -- Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics) BEng(Hons)(Mechanical Engineering) Alma Maters: (1) Singapore Polytechnic (2) National University of Singapore My Primary Blog: http://teo-en-ming-aka-zhang-enming.blogspot.com My Secondary Blog: http://enmingteo.wordpress.com My Youtube videos: http://www.youtube.com/user/enmingteo Email: [email protected] Mobile Phone (Starhub Prepaid): +65-8369-2618 Street: Bedok Reservoir Road Country: Singapore
-- fedora-list mailing list [email protected] To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
