Re: [Xen-users] How to Backup and Restore MBR within Logical Volumes?

2009-11-12 Thread Mr. Teo En Ming (Zhang Enming)
On Thu, Nov 12, 2009 at 6:18 PM, Geert Janssens  wrote:

> On Thursday 12 November 2009, you wrote:
> > > 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.
>
> I did some tests just to be sure. As far as I can tell, dd interacts with
> lvm
> in exactly the same way as with a physical disk or a loop device.
>
> In the test I copied the first sector directly from the lvm partition or
> via
> the loop device. It results in exactly the same sector being copied.
>
> Also, if you try fdisk -l on the lvm disk or the loop device, it results in
> the same output.
>
> Below is the output from my tests:
>
> [r...@aragorn:~]# losetup /dev/loop1 /dev/base/kobaltwit_f11_disk
>
> [r...@aragorn:~]# fdisk -l /dev/base/kobaltwit_f11_disk
>
> Disk /dev/base/kobaltwit_f11_disk: 10.7 GB, 10737418240 bytes
> 255 heads, 63 sectors/track, 1305 cylinders
> Units = cylinders of 16065 * 512 = 8225280 bytes
>
>Device Boot  Start End  Blocks   Id
> System
> /dev/base/kobaltwit_f11_disk1   *   1130510482381   83
> Linux
> [r...@aragorn:~]# fdisk -l /dev/base/kobaltwit_f11_disk
>
> Disk /dev/base/kobaltwit_f11_disk: 10.7 GB, 10737418240 bytes
> 255 heads, 63 sectors/track, 1305 cylinders
> Units = cylinders of 16065 * 512 = 8225280 bytes
>
>Device Boot  Start End  Blocks   Id
> System
> /dev/base/kobaltwit_f11_disk1   *   1130510482381   83
> Linux
>
> [r...@aragorn:~]# dd if=/dev/base/kobaltwit_f11_disk of=mbr.lvm bs=512
> count=1
> 1+0 records in
> 1+0 records out
> 512 bytes (512 B) copied, 7.6e-05 seconds, 6.7 MB/s
>
> [r...@aragorn:~]# dd if=/dev/loop1 of=mbr.loop bs=512 count=1
> 1+0 records in
> 1+0 records out
> 512 bytes (512 B) copied, 0.000151 seconds, 3.4 MB/s
>
> [r...@aragorn:~]# diff mbr.l*
> [r...@aragorn:~]#
>
> These test seem to indicate to me that the lvm layer in completely
> transparent
> to userland tools such as fdisk or dd.
>
> So I still think the losetup step is superfluous and possibly causing
> unnecessary overhead.
>
> Geert
>
> --
> Kobalt W.I.T.
> Web & Information Technology
> Brusselsesteenweg 152
> 1850 Grimbergen
>
> Tel  : +32 479 339 655
> Email: i...@kobaltwit.be
>
>
Thank you!

I will omit the losetup step.

-- 
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: space.time.unive...@gmail.com
Mobile Phone (Starhub Prepaid): +65-8369-2618
Street: Bedok Reservoir Road
Country: Singapore
-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Re: [Xen-users] How to Backup and Restore MBR within Logical Volumes?

2009-11-12 Thread Bryn M. Reeves
On Thu, 2009-11-12 at 09:45 +, Mr. Teo En Ming (Zhang Enming) wrote:
> > 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.

That *is* the MBR (it's the 0th sector of the disk image).

Take a look at the sector on the device (or an image of it) with e.g.
file or a hexdump tool:

[...@hex ~]$ sudo dd if=/dev/mapper/vg_hex-lv_win7 bs=512 count=1 | file
-
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.0184184 s, 27.8 kB/s
/dev/stdin: x86 boot sector; partition 1: ID=0x7, active, starthead 1,
startsector 63, 125821017 sectors, code offset 0xc0, OEM-ID "  ΠΌ",
Bytes/sector 190, sectors/cluster 124, reserved sectors 191, FATs 6,
root entries 185, sectors 64514 (volumes <=32 MB) , Media descriptor
0xf3, sectors/FAT 20644, heads 6, hidden sectors 309755, sectors
2147991229 (volumes > 32 MB) , physical drive 0x7e, dos < 4.0 BootSector
(0x0)

[...@hex ~]$ sudo dd if=/dev/mapper/vg_hex-lv_win7 bs=512 count=1 | xxd
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.00285548 s, 179 kB/s
000: 33c0 8ed0 bc00 7c8e c08e d8be 007c bf00  3.|..|..
010: 06b9 0002 fcf3 a450 681c 06cb fbb9 0400  ...Ph...
020: bdbe 0780 7e00 007c 0b0f 850e 0183 c510  ~..|
030: e2f1 cd18 8856 0055 c646 1105 c646 1000  .V.U.F...F..
040: b441 bbaa 55cd 135d 720f 81fb 55aa 7509  .A..U..]r...U.u.
050: f7c1 0100 7403 fe46 1066 6080 7e10 0074  t..F.f`.~..t
060: 2666 6800  0066 ff76 0868  6800  &fhf.v.h..h.
070: 7c68 0100 6810 00b4 428a 5600 8bf4 cd13  |h..h...B.V.
080: 9f83 c410 9eeb 14b8 0102 bb00 7c8a 5600  |.V.
090: 8a76 018a 4e02 8a6e 03cd 1366 6173 1cfe  .v..N..n...fas..
0a0: 4e11 750c 807e 0080 0f84 8a00 b280 eb84  N.u..~..
0b0: 5532 e48a 5600 cd13 5deb 9e81 3efe 7d55  U2..V...]...>.}U
0c0: aa75 6eff 7600 e88d 0075 17fa b0d1 e664  .un.vu.d
0d0: e883 00b0 dfe6 60e8 7c00 b0ff e664 e875  ..`.|d.u
0e0: 00fb b800 bbcd 1a66 23c0 753b 6681 fb54  ...f#.u;f..T
0f0: 4350 4175 3281 f902 0172 2c66 6807 bb00  CPAu2r,fh...
100: 0066 6800 0200 0066 6808  0066 5366  .fhfhfSf
110: 5366 5566 6800  0066 6800 7c00 0066  SfUfhfh.|..f
120: 6168  07cd 1a5a 32f6 ea00 7c00 00cd  ah.Z2...|...
130: 18a0 b707 eb08 a0b6 07eb 03a0 b507 32e4  ..2.
140: 0500 078b f0ac 3c00 7409 bb07 00b4 0ecd  ..<.t...
150: 10eb f2f4 ebfd 2bc9 e464 eb00 2402 e0f8  ..+..d..$...
160: 2402 c349 6e76 616c 6964 2070 6172 7469  $..Invalid parti
170: 7469 6f6e 2074 6162 6c65 0045 7272 6f72  tion table.Error
180: 206c 6f61 6469 6e67 206f 7065 7261 7469   loading operati
190: 6e67 2073 7973 7465 6d00 4d69 7373 696e  ng system.Missin
1a0: 6720 6f70 6572 6174 696e 6720 7379 7374  g operating syst
1b0: 656d  0063 7b9a 998c 3463  8001  em...c{...4c
1c0: 0100 07fe  3f00  59e0 7f07   ..?...Y.
1d0:          
1e0:          
1f0:        55aa  ..U.

Regards,
Bryn.


-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: [Xen-users] How to Backup and Restore MBR within Logical Volumes?

2009-11-12 Thread Mr. Teo En Ming (Zhang Enming)
> 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: space.time.unive...@gmail.com
Mobile Phone (Starhub Prepaid): +65-8369-2618
Street: Bedok Reservoir Road
Country: Singapore

On Thu, Nov 12, 2009 at 9:36 AM, Geert Janssens  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: i...@kobaltwit.be
>
>
> ___
> Xen-users mailing list
> xen-us...@lists.xensource.com
> http://lists.xensource.com/xen-users
>
-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines