In this guide, I will be exporting the VM to my desktop as a *.xva, moving the file to the /home directory in Proxmox via my NAS, then converting it to a *.raw VMfile to be imported into a Proxmox VM as the virtual disk. Be sure you have a large enough main drive to perform this task. If you don’t you may need to use your data store drive or install an extra drive to perform this work on. You will need a drive that 3.5 times the size of your largest VM.
Step 1
A few things we need to install. We will use sshfs to mount network shares manually in Proxmox. Mounting SMB shares in the UI didn’t work out the way I wanted them to so I used sshfs. The package xva-img needs CMake, g++ libssl-dev, & libxxhash-dev as dependtances. Xva-img is our converter.
apt install sshfs CMake g++ libssl-dev libxxhash-dev
git clone https://github.com/eriklax/xva-img
Step 2
We are going to navagate to /home. This is where this guide will do most of the work.
cd /home/
Step 3
We need to build xva-img from the source we pulled off git.
cd xva-img/
cmake .
sudo make install
cd ../
Step 4
We need to mount our network share inside proxmox to move the VM into proxmox to work with it.
Navigate to the /mnt directory, make a share directory, then mount your share to that directory.
cd /mnt
mkdir share
sshfs -o allow_other,default_permissions <NAS IP>:/<network share path> /share
Step 5
At this point we need to get our VM. Log into XCP-NG most people will use the default XOA VM. Export the VM as a *.xva file to your desktop. Then move that over to an open share on your NAS.
Step 6
Copy the VMfrom the share to the /home directory.
cp /mnt/share/virtual_machine.xva /home/
Step 7
Back in the /home directory we are going to make a temp directory to uncompress the *.xva file to and uncompress it
cd /home
mkdir xva_uncompressed
tar -xf 'virtual_machine.xva' -C xva_uncompressed
Step 8
Now that we have a uncompressed VM we are going to convert that to a *.raw file. You need to go into the xva_uncompressed directory and check the name number of the Ref\: directory. You will need the number to use in the next step.
cd /xva_uncompressed
ls
Step 9
Take the number from th Ref\: directory in the last step and use it in this commond to make a *.raw virtual disk. In the example command I used 22
xva-img -p disk-export xva_uncompressed/Ref\:22/ virtual_machine.raw
Step 10
We need to make new VM in proxmox to import our virtual disk into. Using the Create: Virtual Machine Wizard create a new VM. During the Wizard on the OS tab select “Do not use any media” and on the Disks tab delete the disk that it creates.
Step 11
Time to import our virtual disk.
qm importdisk 102 virtual_machine.raw local-ssd
Step 12
We need to make a few changes to the setting before we can start the VM. Under the Hardware tab of the VM add the unused disk to the VM. Under the Options tab adjust the boot order to the newly added disk. You will need to add a network interface and any pass-throughs (IE: Video Card, USB). If the VM was originally a EFI BIOS you will need to run the following command to change from SeaBIOS to EFI
qm set 130 --bios ovmf
Power on VM
Clean up
If you want to do this again run the following command and start over at Step 5
rm -rf virtual_machine.xva xva_uncompressed virtual_machine.raw
Sources: