Lab Setup
Cloning a windows to a physical computer
- Boot the physical computer into a linux system.
- Export the disk device via nbd
- First make sure that nbd server will not try to set
user and group to nbd by editing
/etc/nbd-server/config
and removing the relevant lines.
- Then export the block device on port
2000
:
nbd-server 2000 /dev/sda -d
- Now into your image server, make sure you have both source and
destination nbd devices connected:
- Connect the local source disk as
nbd2
with:
qemu-nbd --read-only -n --connect=/dev/nbd2 /mnt/data/virt-storage/lakatkft-win10.qcow2
- Connect the target disk as
nbd3
with:
nbd-client 192.168.222.85 2000 /dev/nbd3
- Understand the size of required target partition and create
the partition:
- In my case size is
51607MiB
in my case
- and partition is
/dev/nbd2p4
- Create the partition on target with at least the same size
mkpart WIN NTFS 40960MiB 94000MiB
- copy data between the two partitions
dd if=/dev/nbd2p4 of=/dev/nbd3p3 bs=64K conv=noerror,sync status=progress
- Do a sync so that data is flushed:
sync
- Disconnect source block device
qemu-nbd --disconnect /dev/nbd2
- Start a VM with windows 10 install cd that has
/dev/nbd3
as a SCSI block device.
- Fix boot partition from within windows
- Start the fixer VM
- Once booted up, press Shift+F10 to get a command prompt
diskpart
select volume 2
(The EFI Partition)
assign letter R
exit
bcdboot c:\windows /s r: /f UEFI
- Exit the installer and shut down the VM
- disconnect target block device
nbd-client -d /dev/nbd3
- reboot target machine