SOLVED Cloning VM Boot Drive - Passthrough To ZVol

Roxanna

Cadet
Joined
Mar 9, 2023
Messages
9
Not sure if anyone can help with this.

I have a VM with a PCIe passthrough to a 2.5" SSD booting Windows 10. This was the easiest thing for me to move an existing physical PC to a VM. I'd like to change this now so that the drive contents are on a Zvol disk in my pool and not on the separate SSD. I have a separate TN scale box with a different VM where I did successfully make a similar transition. But with this VM it just boots into the Windows Recovery environment at best.

Process;
- Create a 500 GB ZVol (Size of the SSD)
- Add the new Zvol as a Disk to the VM along with the existing PCI passthrough to the SSD
- Boot the VM
- Go to Disk Administrator and mark the ZVol disk as GPT (as that is what the SSD is)
- Use Paragon Hard Disk Manager to copy the entire structure and content of the SSD disk to the ZVol disk
- Shut Down the VM
- Remove the PCI Passthrough SSD device
- Start the VM

Sometimes on reboot I am left at the UEFI BIOS Shell prompt and need to Exit and select a different boot drive. Also, I have tried both AHCI and VirtIO setting for the ZVol disk. The VM has VirtIO drivers installed.

Should I do something in diskpart after cloning the drive?

I do have backup from within the VM via Macrium Reflect and could alternately try to put together some sort of recovery disk to boot the VM to and restore from, but I'm concerned I'll be in the same boat about Windows not liking something about the restored boot drive.

TrueNAS-SCALE-23.10.1.3
AMD Ryzen 5 7600
B650 Motherboard
 

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
My process was done on Scale. It was something like:

Shut down VM, umount the SSD
Create zvol
dd if=/dev/whatevertheSSDdriveletterislikesdj of=/dev/zvol/poolname/zvolpath bs=1m
Now get rid of the SSD in the VM config and add the zvol
Start

Hopefully I am remembering correctly though no harm should come from this as long as you get the zvol path right. So, if your zvol was ZFS dataset tank/virtual/myzvol (according to zfs list) then of=/dev/zvol/tank/virtual/zvol, just make sure that file exists before doing the dd
 

Roxanna

Cadet
Joined
Mar 9, 2023
Messages
9
DD does not work for Windows because it isn't really UEFI aware and Windows does other stuff to try to defeat multiple OS boot partitions on the same computer. I eventually got this working using Paragon for the clone, but I'm not sure exactly what the critical change(s) I made were.

I think what ended up working was after booting the clone, in the Windows Recovery UI, first selecting Startup Repair (which still failed but may have changed something) and then selecting Continue To Windows 10. Two other things of note in the working config that may play a factor; 1) in this case my source drive was a 500GB 2.5-inch SATA attached SSD and I selected AHCI for the ZVOL drive's Mode, 2) I used Paragon to convert the ZVOL drive from MBR to GPT instead of Disk Administrator.
 

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
I don't see why it wouldn't work, dd doesn't copy partitions, it copies byte for byte the drive. I've always used dd to convert to zvols. But glad you got it working!
 

Roxanna

Cadet
Joined
Mar 9, 2023
Messages
9
I
.
I don't see why it wouldn't work, dd doesn't copy partitions, it copies byte for byte the drive. I've always used dd to convert to zvols. But glad you got it working!
I'm not sure either. As I said in the first post, I converted to Zvol on another very similar system without a problem. In more reading, it might have something to do with GPT and I might have been able to fix it by doing a gdisk after the dd. But, ¯\_(ツ)_/¯
 

Roxanna

Cadet
Joined
Mar 9, 2023
Messages
9
I got a few minutes to test following dd with gdisk and that seems to work. So, I went to the TrueNAS Shell and cloned the SSD to the Zvol with;

sudo dd if=... of=... bs=1M

and then did;

sudo gdisk

After entering the Zvol device path, gdisk reported "The protective MBR's 0xEE partition is oversized! Auto-repairing."

I then selected w(rite) at the gdisk Command prompt and it reported "Warning! Secondary header is placed too early on the disk! Do you want to correct this problem?" to which I responded Y(es).

After writing, gdisk gave a warning that the kernel still had the old partition table cached, but I ignored it. I closed the SHell and was able to start the VM from the Zvol disk.
 

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
Did the SSD origjnally start as Win 8 per chance? There were some Windows partitioning bugs that violated the GPT spec. Not completely sure which versions.
 

Roxanna

Cadet
Joined
Mar 9, 2023
Messages
9

I never ran win 8. It's possibly an upgrade from Win 7 Pro, but I wouldn't remember at this point. Doesn't matter though, your dd suggestion was very helpful. Simple and no additional software required within the vm.
 
Top