[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Xen-users] Can you convert Windows LVM domU to sparse img file?


  • To: <xen-users@xxxxxxxxxxxxxxxxxxx>
  • From: "Dustin Henning" <Dustin.Henning@xxxxxxxxxxx>
  • Date: Thu, 15 Jan 2009 10:21:26 -0500
  • Delivery-date: Thu, 15 Jan 2009 07:22:14 -0800
  • List-id: Xen user discussion <xen-users.lists.xensource.com>
  • Thread-index: Acl3HTL9N7vrUuV8RqOfhW9R6FCHlQAA7uOw

        Ross's solution below is probably the easiest and most practical.  
However, I believe I once saw a utility to create sparse files with DD.  The 
first problem with attacking from that angle would be that you would first need 
to boot your Windows system and use some utility to zero out all blank space.  
The second problem would be that legitimate 0s might be treated sparsely, and 
of course, I could be making this up completely, as such a utility may not even 
exist anyway.
        As MÄris suggested, the MFT will have to be clean (or you may be able 
to get away with a --force in ntfsclone), and you may need kpartx as well, 
depending on how your lvm is set up.
        Regarding Ross's step 3, you can do the same thing with mkfs.ntfs 
instead of booting to something for fdisk.  Additionally I'm not certain you 
need to do that step at all with ntfsclone anyway, as I believe it will 
"reformat" the destination sparse file (by copying the original MFT) when you 
run ntfsclone (I suggest this because I used ntfsclone Saturday and couldn't go 
from a 20GB drive to a 10GB one on account of the destination being too small 
even though only 6 or 7 GB was in use, and I know the MFT isn't 3+ GB, but I 
don't remember if I did a --force).  However, if I am correct, it would imply 
that you also need to keep in mind that 1) it would be necessary to ntfsresize 
if the destination sparse file was bigger than the source partition and 2) it 
would be necessary to ntfsresize before ntfsclone in order to get to a smaller 
destination safely (supposing a --force did work, the thing is, a --force could 
technically copy to a smaller destination even if it copied the MFT, and that 
would certainly upset Windows, if not other systems, mounting the file after 
the fact).
        Also, and this is untested theory (in that I don't know whether or not 
you can write directly to a physical/loop device over scp), but you may be able 
to mount the loop device on the destination machine and use scp://<mnt/loop> 
for the destination file instead of copying the file after the fact.
        Finally, keep in mind that this sparse file will be just like a MS 
Virtual PC vhd file, it will grow as you write and delete.  In order to bring 
it back down, you would have to do something like my first paragraph suggests, 
or follow Ross's steps again from one loop device to another.  This is why I 
think I recall seeing a utility to do that, though, I believe a sparse file 
mounted loop with ext3 on it would have the same problem growing with writes 
and deletes otherwise, though not necessarily to the same degree, and it seems 
like I saw such a solution for that a long time ago.
        Dustin

-----Original Message-----
From: xen-users-bounces@xxxxxxxxxxxxxxxxxxx 
[mailto:xen-users-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf Of Ross Walker
Sent: Thursday, January 15, 2009 09:25
To: Fajar A. Nugraha
Cc: Xen Users Mailing List
Subject: Re: [Xen-users] Can you convert Windows LVM domU to sparse img file?

On Jan 15, 2009, at 3:15 AM, "Fajar A. Nugraha" <fajar@xxxxxxxxx> wrote:

> MÄris Ruskulis wrote:
>> You can do this by dd.
>> for example:
>> dd if=/dev/vg/winpart of=/home/myuser/winimage.img bs=4096
>> bs set to your block size, as i remember ntfs has 4096 by default.
>>
> bs=32M (or whatever "PE Size" that pvdisplay shows) will probably be  
> faster.
> dd won't give you SPARSE img file though. Then again, your LV could be
> "dirty" (e.g contain deleted data) so that any "normal" attempt to
> create sparse file will not be effective.
>
> I'd suggest you just accept the full,non-sparse file that dd gives  
> you.
> An alternative would be to use ntfsresize and ntfsclone, but it  
> requires
> a lot more effort (including using kpartx,fdisk, and having a "good"  
> MBR
> handy).

1) create a sparse file the size needed

2) add it as a loop device

3) fdisk the loop device

4) ntfsclone the lv to the loop device.

That should do it in theory.

-Ross


>
>> James Pifer wrote:
>>> I have a Windows 2000 domU running in an LVM partition. I need to  
>>> move
>>> it to another host, but none of my other xen servers have lvm or  
>>> free
>>> space to create an lvm. So I'd like to convert it to a sparse img  
>>> file.
>>> The file system in the domU is ntfs.
>>> Can anyone suggest how to do this?
>>>
>>> Thanks,
>>> James
>>>
>
>
> _______________________________________________
> Xen-users mailing list
> Xen-users@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-users

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users



_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.