You are not logged in.

#1 2015-03-02 17:26:22

belette
Member
Registered: 2014-11-17
Posts: 121

Partition Disk cloning using dd to KVM with UEFI

Hi,

I have read the good documentation from https://wiki.archlinux.org/index.php/QE … inear_RAID which explain how to use a physical disk/partition and clone it to KVM image.

I am wondering if someone has some how-to with an UEFI partition?

My objective is to clone a partition of Windows 7 from a physical disk. (not the entire disk as it is a 256GB disk and my disk on my host is as well a 256GB so I would not get a byte of free space doing that! only need to clone the root partition of Windows which is around 80GB).

When I plug the disk into my host, it is recognized, I tried a

dd if=/dev/sda2 of=image.raw bs=512

(where /dev/sda2 is my 80GB Windows Partition).

If I tried to do a

qemu-system-x86_64 -enable-kvm -vnc :0 -k fr image.raw 

But my KVM is told me

Booting from Hard Disk...

and nothing more!

I have installed OVMF (pacman -S ovmf) but I don't know what type of command I would need to append to qemu?

Many thanks for your help!

belette

Offline

#2 2015-03-05 09:50:26

belette
Member
Registered: 2014-11-17
Posts: 121

Re: Partition Disk cloning using dd to KVM with UEFI

A little up

Offline

#3 2015-03-05 11:20:24

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,523

Re: Partition Disk cloning using dd to KVM with UEFI

Turning a windows machine into Virtual it's a nightmare. It will end up with BSOD and many corrections are needed to remove hardware graphic drivers and some other drivers that aren't used in a VM.

What Arch should do with that ?

Last edited by TheSaint (2015-03-05 11:22:26)


do it good first, it will be faster than do it twice the saint wink

Offline

#4 2015-03-05 13:29:11

belette
Member
Registered: 2014-11-17
Posts: 121

Re: Partition Disk cloning using dd to KVM with UEFI

Thanks for your reply.
I agree that it is not ideal but I get a computer with my company and I would like to clone the Windows image to a VM if in case I need to use something from this image..
I only see one interesting article but base on MBR (I got a UEFI) : http://fds-team.de/cms/articles/2013-12 … yer-u.html

Posting here because I am in Arch and would like to see if somebody has some experience dealing with this situation..

Offline

#5 2015-03-06 00:54:51

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,523

Re: Partition Disk cloning using dd to KVM with UEFI

I think that virtualbox forum would be more suited for the case. See here in particular.
I tried to convert a real machine into virtual but it's often difficult, but not impossible.


do it good first, it will be faster than do it twice the saint wink

Offline

#6 2015-03-09 01:38:14

Lekensteyn
Member
From: Netherlands
Registered: 2012-06-19
Posts: 192
Website

Re: Partition Disk cloning using dd to KVM with UEFI

TheSaint wrote:

Turning a windows machine into Virtual it's a nightmare. It will end up with BSOD and many corrections are needed to remove hardware graphic drivers and some other drivers that aren't used in a VM.

Actually it is pretty doable. Windows XP was quirky, but since Windows 7 things have actually improved a bit. The BSOD you are mentioning comes from incompatible storage drivers. Most machines use IDE or AHCI while the default QEMU system uses IDE. You can do some registry hacks to change the driver, but it is easier to change the QEMU device instead:

qemu-system-x86_64
...
-machine q35,accel=kvm
-drive if=none,file=your.image
-device ahci,id=ahci
-device ide-drive,bus=ahci.0,drive=d1

(append aio=native to the -drive option for better performance)

I am not familiar with booting using EFI, but you can try this nice trick to see whether QEMU can boot from the image:

sudo setfacl -m u:$USER:r /dev/sda
qemu-system-x86_64 ... -drive if=none,file=/dev/sda,aio=native,snapshot=on

This makes QEMU boot from your disk in a "read-only" fashion (on shutdown, all changes are gone).

Behind the scenes it works by creating a qcow2 image in /var/tmp/ with the backing image set to /dev/sda. If this works, you can convert your disk to qcow2 (put the result on a different disk!):

qemu-img convert -c -p -O qcow2 /dev/sda output.qcow2

(-c for compression, -p for progress, -O qcow2 for qcow output format, /dev/sda is the input, output.qcow the output).

Offline

#7 2015-03-09 03:31:11

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,523

Re: Partition Disk cloning using dd to KVM with UEFI

My intents were virtualbox oriented. I don't know much the use of qemu.
Anyways once it gets a vmdk probably it might turn into VDI as well.


do it good first, it will be faster than do it twice the saint wink

Offline

#8 2015-03-09 11:06:47

Lekensteyn
Member
From: Netherlands
Registered: 2012-06-19
Posts: 192
Website

Re: Partition Disk cloning using dd to KVM with UEFI

Vbox uses AHCI (and can probably emulate others as well), so the same reasoning applies. To my knowledge, VBox does not support compressed qcow2 images though.

Offline

Board footer

Powered by FluxBB