This is a modified version of the XenServer to Proxmox migration script, with specific adjustments for use with NFS storage in Proxmox. The script automates the migration of virtual machine (VM) disks from XenServer to Proxmox by exporting the disks and recreating them on the specified NFS storage backend in Proxmox.
- Supports NFS storage in Proxmox.
- Dynamically accepts the Proxmox storage backend as an argument for flexibility.
- Uses the
xcp-xe
tool to export disks from XenServer. - Verifies and migrates each disk from XenServer to Proxmox using Proxmox’s storage system.
The script requires the xcp-xe
tool to interact with XenServer. You can download the required version from the following repository:
https://github.com/hnzl62/xen-to-pve/blob/master/xcp-xe_1.3.2-5ubuntu1_amd64.deb
Once downloaded, install it on the machine where you are running the script using:
sudo dpkg -i xcp-xe_1.3.2-5ubuntu1_amd64.deb
The script also requires stunnel
for secure communications. You can install it using the following command:
sudo apt install stunnel
To use the script, run it with the following arguments:
./migrate.sh <vm-uuid> <vm-id> <host> <port> <user> <pass> <storage>
<vm-uuid>
: The UUID of the VM on XenServer.<vm-id>
: The VM ID in Proxmox.<host>
: The IP address or hostname of the XenServer.<port>
: The port to connect to on XenServer.<user>
: The XenServer username (usually root).<pass>
: The password for the XenServer user.<storage>
: The Proxmox storage name where the disks should be created (e.g., nfs_storage).
Here’s an example of how to run the script:
./migrate.sh 92dcc124-3baf-fa12-334a-d8aef0c85363 112 xcp01 443 root password nfs01
- This example migrates the VM with UUID
92dcc124-3baf-fa12-334a-d8aef0c85363
from the XenServerxcp01
(using port443
) to the Proxmox host, using the NFS storagenfs01
.
This version of the script has been specifically modified to:
- Handle NFS storage in Proxmox, dynamically constructing the file paths for VM disk images on NFS.
- Accept the Proxmox storage name as an argument for greater flexibility in environments with multiple storage backends.
This script is licensed under the GPL, in accordance with the original author’s license. See the LICENSE
file for details.
-
Take VM Snapshot on Xen/XCP
- In case things go sideways, take a snapshot of the VM on Xen or XCP.
-
Remove Xen/XCP/Citrix Programs
- On the VM, go to Add or Remove Programs.
- Search for any programs related to xen, xcp, or citrix and uninstall everything you can find.
-
Delete Xen Files via CMD
-
Launch an administrative Command Prompt and run the following command:
del /F /Q C:\Windows\System32\xen*
-
-
Run XCP-ng Windows Guest Tools Cleaner
- Download and run the XCP-ng Windows Guest Tools Cleaner.
- The result must be "No Leftover XenDrivers".
-
Install VirtIO Drivers and QEMU Guest Agent
- Install VirtIO drivers from virtio-win-gt-x64.msi.
- Install QEMU Guest Agent from virtio-win-guest-tools.exe.
-
Ensure Local Admin Password is Known
- Make sure you know the local administrator password; you will need it.
-
Shutdown the VM
- Properly shut down the VM.
-
Take Note of VM UUID in Xen
- Obtain and record the VM UUID from Xen.
-
Create New VM in Proxmox
- Create a new VM in Proxmox with the following settings:
- Guest Type: Windows
- Guest Tools: Select that guest tools are installed
- BIOS/UEFI: Select the correct BIOS/UEFI setting
- Disks: Do not attach any disks
- Network Card: Set as disconnected
- Create a new VM in Proxmox with the following settings:
-
Take Note of the VM ID
- Record the VM ID assigned in Proxmox.
-
Initiate Migration
-
Login to the Proxmox host via SSH.
-
Navigate to:
cd /mnt/pve/YOURNFSSHARE
-
Copy the migrate.sh there and launch the migration command based on your Xen VM UUID and Proxmox VM ID:
./migrate.sh XENVMUUID PROXMOXVMID SOURCEXENHOSTFQDN 443 root XENROOTPASSWORD
-
This will initiate the migration of the VHDX to a RAW disk image for Proxmox.
-
At the end, you should see something like this:
Starting migration of XenServer "92dcc124-3baf-fa12-334a-d8aef0c85363" to ProxMox #112 xvda:73ea7ece-9b39-4761-a2e4-b3a2cf7046d9:106300440576 Exporting device xvda with UUID 73ea7ece-9b39-4761-a2e4-b3a2cf7046d9. Size=99. Disk #0 update VM 112: -virtio0 YOURNFSSHARE:99,cache=writeback Formatting '/mnt/pve/YOURNFSSHARE/images/112/vm-112-disk-3.raw', fmt=raw size=106300440576 preallocation=off virtio0: successfully created disk 'YOURNFSSHARE:112/vm-112-disk-3.raw,cache=writeback,size=99G' Migrating on /mnt/pve/YOURNFSSHARE/images/112/vm-112-disk-3.raw 106259652144 bytes (106 GB, 99 GiB) copied, 2331 s, 45.6 MB/s 0+9788652 records in 0+9788652 records out 106300440576 bytes (106 GB, 99 GiB) copied, 2336.52 s, 45.5 MB/s
-
-
Configure VM in Proxmox
- In Proxmox, ensure that in the VM options:
- The restored disk is added as the boot option.
- The disk is mounted as SATA.
- In Proxmox, ensure that in the VM options:
-
Boot VM in Repair Mode
- Boot the VM in repair mode by spamming the F8 key during boot.
-
Remove Xen Drivers via Recovery Mode
-
In Recovery mode, run the following commands:
X:\> dism /Image:D:\ /Get-Drivers
- Then look for the Xen drivers—they'll be listed as something like
oem6.inf
, etc. - Remove them with:
X:\> dism /Image:D:\ /Remove-Driver /Driver:oem6.inf
- Repeat this for all entries in
Get-Drivers
that mention Xen.
- Then look for the Xen drivers—they'll be listed as something like
-
-
Shutdown the VM
- After removing the drivers, shut down the VM.
-
Attach Temporary VirtIO Disk
- Attach a small (10 GB) VirtIO disk to the VM to ensure VirtIO drivers are loaded.
-
Power On the VM
- Power on the VM in Proxmox.
- Verify it boots and test the local admin account.
- Make sure you can see the VirtIO disk.
-
Remove Temporary VirtIO Disk
- Power down the VM.
- Remove the temporary VirtIO disk.
-
Reattach the SATA Disk as VirtIO
- Detach the SATA disk.
- Reattach it as VirtIO.
- Enable the Discard checkbox.
- Ensure to set it again as the boot device in Proxmox VM options.
-
Reconnect the Network Adapter
- If everything looks OK, reconnect the network adapter.
-
Migrate VM to Other NFS Storage
- Migrate the VM to other NFS storage to convert the disk from
.raw
to.qcow2
in the process.
- Migrate the VM to other NFS storage to convert the disk from
-
Add VM to PBS Backup (If Needed)
- If needed, add the VM to the Proxmox Backup Server.
-
Disable or Remove VM in Xen
- Ensure the VM in Xen has its network adapter disconnected or is removed.
-
Add extra argument in conf file
- Navigate to /etc/pve/qemu-server and fing xxx.conf, where xxx is the VMID in Proxmox. Then add following line at the end of the file:
args: -machine smbios-entry-point-type=32
- Stop / Start the VM from Proxmox web GUI.