What you’re trying to do is called a P2V (Physical to Virtual). You want to directly copy the partition as going through a file share via Linux will definitely strip some metadata Windows wants on those files.
First, make a disk image that’s big enough to hold the whole partition and 1-2 GB extra for the ESP:
qemu-img create -f qcow2 YourDiskImageName.qcow2 300G
Then you can make the image behave like a real disk using qemu-nbd:
sudo modprobe nbd
sudo qemu-nbd -c /dev/nbd0 YourDiskImageName.qcow2
At this point, the disk image behaves like any other disk at /dev/nbd0
.
From there create a partition table, you can use cgdisk
or parted
or even the GUI GParted will work on it.
And finally, copy the partition over with dd
:
sudo dd if=/dev/sdb3 of=/dev/nbd0p2 bs=4M status=progress
You can also copy the ESP/boot partition as well so the bootloader works.
Finally once you’re done with the disk image, unload it:
sudo qemu-nbd -d /dev/nbd0
I also wanted to put an emphasis on how working with virtual disks is very much the same as real ones. Same well known utilities to copy partitions work perfectly fine. Same cgdisk/parted and dd dance as you otherwise would.
Technically if you install the
arch-install-scripts
package on your host, you can even install ArchLinux into a VM exactly as if you were in archiso with the comfort of your desktop environment and browser. Straight uppacstrap
it directly into the virtual disk.Even crazier is, NBD (Network Block Device) is generic so it’s not even limited to disk images. You can forward a whole ass drive from another computer over WiFi and do what you need on it, even pass it to a VM boot it up.
With enough fuckery you could even wrap the partition in a fake partition table and boot the VM off the actual partition and make it bootable by both the host and the VM at the same time.