Skip to content

Commit c69771c

Browse files
committed
WiP: rework migrate to XCP-ng documentation
Signed-off-by: Cécile - AtaxyaNetwork <[email protected]>
1 parent 8de4d13 commit c69771c

File tree

3 files changed

+119
-85
lines changed

3 files changed

+119
-85
lines changed

docs/assets/img/import-disk.png

79.9 KB
Loading

docs/assets/img/import-ova.png

131 KB
Loading

docs/installation/migrate-to-xcp-ng.md

Lines changed: 119 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,29 @@ How to migrate from VMware, KVM, etc. to XCP-ng.
88

99
This documentation will help you to make a migration to XCP-ng, from any most common other virtualization platform (VMware, KVM, etc.)
1010

11-
:::note
12-
OVA import method will miss the information if the VM is running BIOS or UEFI mode. Double check your settings on your original system, and then enable (or not) UEFI on XCP-ng side for the destination VM. You can do so in VM advanced tab in Xen Orchestra.
13-
:::
11+
## 📋 Prerequisites
12+
13+
Before migrating your VMs, make sure to check the following:
14+
15+
### Uninstall Existing Guest Tools
16+
17+
To avoid conflicts with XCP-ng guest tools, uninstall any existing VM tools (such as VMware Tools or QEMU Guest Agent) from the VM.
18+
19+
### Install Xen Drivers
20+
21+
On some systems (especially RHEL-based and SLES distributions) Xen drivers are not installed by default. Migrating a VM without these drivers can prevent the OS from detecting disks and network interfaces.
22+
23+
Before shutting down the VM, install the drivers with:
24+
25+
```
26+
dracut --add-drivers "xen-blkfront xen-netfront" --force
27+
```
28+
29+
### Install XCP-ng Guest Tools After Migration
30+
31+
Guest tools are essential for proper VM operation (especially on Windows). Be sure to install the XCP-ng guest tools after the migration.
32+
33+
See the [guest tools documentation](../vms/vms.md#%EF%B8%8F-guest-tools) for more details.
1434

1535
## 🇽 From XenServer
1636

@@ -26,10 +46,6 @@ If you are running Xen on your usual distro (Debian, Ubuntu…), you are using `
2646

2747
Check [the README](https://github.com/xcp-ng/xen2xcp/blob/master/README.md) for usage instructions.
2848

29-
## 📦 From Virtualbox
30-
31-
Export your VM in OVA format, and use Xen Orchestra to import it. If you have an issue on VM boot, check the [VMware](#-from-vmware) section.
32-
3349
## 🇻 From VMware
3450

3551
:::warning
@@ -102,48 +118,6 @@ To do this:
102118

103119
Now, you can see the transfer progress in the **Task** view of the Xen Orchestra UI. As soon it's done, you can boot the VM directly!
104120

105-
### OVA
106-
107-
You can also export an OVA from VMware and import an OVA into Xen Orchestra.
108-
109-
An OVA is a big, single file using the standard Open Virtualization Format. The OVA contains an XML describing the metadata (VM name, description, etc.) and your disks in the VMDK format.
110-
111-
:::tip
112-
To skip Windows activation if the system was already activated, collect info about the network cards used in the Windows VM (ipconfig /all) and use the same MAC address(es) when creating interfaces in XCP-ng.
113-
:::
114-
115-
:::warning
116-
117-
- **Downtime**: The OVA can only be exported while the VM is off (except if you export a clone, but all blocks written after the clone won't be on the imported VM. If you can sync after, it's fine!). This can take a while, and your VMs won't be reachable until it's fully exported AND imported on destination.
118-
- **Storage**: You need an intermediary storage where you can export then import the OVA file. If your VMs are small, it's OK.
119-
- **Manual process**: Even if it's simple to do, it can be cumbersome if you have a lot of VMs to migrate.
120-
:::
121-
122-
Importing a VMware Linux VM, you may encounter an error similar to this on boot:
123-
124-
`dracut-initqueue[227]: Warning: /dev/mapper/ol-root does not exist`
125-
126-
The fix for this is installing some xen drivers *before* exporting the VM from VMware:
127-
128-
`dracut --add-drivers "xen-blkfront xen-netfront" --force`
129-
130-
[See here](https://unix.stackexchange.com/questions/278385/boot-problem-in-linux/496037#496037) for more details. Once the imported VM is properly booted, remove any VMware related tooling and be sure to install [Xen guest tools](../../vms).
131-
132-
### CloneZilla
133-
134-
An alternative to using OVA.
135-
136-
1. Insert a CloneZilla live CD in your existing VMware VM, and boot on it. In the meantime, you also have a VM on the destination with the right metadata (same name and disks), which you'll also boot with CloneZilla.
137-
138-
2. From the VM console, you can tell the source VM running CloneZilla to send all the blocks to the destination VM, also running CloneZilla.
139-
140-
3. As soon it's done, you can safely shut down the original VM and boot the copy on destination!
141-
142-
:::warning
143-
- **Downtime**: Even if the downtime will be reduced compared to using OVA, you still need to run the export/import process while the VM is off.
144-
- **Setup time**: Not complex, but various operations are needed until you can start the replication for one VM. If you have a lot of VMs, this can take some effort.
145-
:::
146-
147121
### Local migration (same host)
148122

149123
:::tip
@@ -218,16 +192,7 @@ There's two options, both requiring to export your Hyper-V VM disk in VHD format
218192
Convert-VHD -Path <source path> -DestinationPath <destination path> -VHDType Dynamic
219193
```
220194

221-
### Import the VHD in Xen Orchestra
222-
223-
In the left menu, go for "Import" then "Disk". Select the destination SR, and then add your VHD file into it. Depending on the VHD file size, it might take some time. The upload progress can be tracked in another XO tab, in the "Task" menu.
224-
225-
When the disk is imported, you can:
226-
227-
4. Create a VM with the appropriate template, **without any disk in it**
228-
5. Attach the previously imported disk (VM/Disk/Attach an existing disk)
229-
6. Boot the VM
230-
7. Install the tools
195+
Then [import your VHD](../../installation/migrate-to-xcp-ng/#import-the-vhd)
231196

232197
### Alternative: direct VHD copy
233198

@@ -262,54 +227,123 @@ As soon you did scan the SR, the new disk is visible in the SR/disk view. Don't
262227
If you lost ability to extend migrated volume (opening journal failed: -2) You need to move disk to another storage, VM should be ON during moving process. This issue can occur when vhd files was directly copied to storage folder.
263228
:::
264229

265-
## 🇰 From KVM (Libvirt)
230+
## 🇰 From KVM (Libvirt, Proxmox and other)
266231

267-
Related forum thread: [https://xcp-ng.org/forum/topic/1465/migrating-from-kvm-to-xcp-ng](https://xcp-ng.org/forum/topic/1465/migrating-from-kvm-to-xcp-ng)
232+
First, shut down the virtual machine. If you don’t already have the `qemu-img` command available, you can install it by installing the `qemu-utils` package on your computer or server.
268233

269-
_Due the fact I have only server here, I have setup a "buffer" machine on my desktop to backup and convert the VM image file._
234+
Next, convert the QCOW2 disk to a VHD format using the following command:
270235

271-
* Install the dracut packages : yum install dracut-config-generic dracut-network
236+
```
237+
qemu-img convert -O vpc disk.qcow2 `uuidgen`.vhd
238+
```
272239

273-
`dracut --add-drivers xen-blkfront -f /boot/initramfs-$(uname -r).img $(uname -r)`
240+
Then [import your VHD](../../installation/migrate-to-xcp-ng/#import-the-vhd)
274241

275-
If your VMs are in BIOS mode :
242+
## 🔄 Alternatives
276243

277-
`dracut --regenerate-all -f && grub2-mkconfig -o /boot/grub2/grub.cfg`
244+
### OVA
278245

279-
If your VMs are in UEFI mode (OVMF Tianocore) :
246+
You can also export an OVA from your hypervisor (VirtualBox, VMWare...) and import an OVA into Xen Orchestra.
280247

281-
`dracut --regenerate-all -f && grub2-mkconfig -o /boot/efi/EFI/<your distribution>/grub.cfg`
248+
An OVA is a big, single file using the standard Open Virtualization Format. The OVA contains an XML describing the metadata (VM name, description, etc.) and your disks in the VMDK format.
282249

283-
* Shutdown the VM
250+
:::tip
251+
To skip Windows activation if the system was already activated, collect info about the network cards used in the Windows VM (ipconfig /all) and use the same MAC address(es) when creating interfaces in XCP-ng.
252+
:::
284253

285-
* Use rsync to copy VM files to the "buffer" machine using `--sparse` flag.
254+
![](../assets/img/import-ova.png)
286255

287-
* Convert the QCOW2 to VHD using QEMU-IMG :
256+
:::warning
288257

289-
`qemu-img convert -O vpc myvm.qcow2 myvm.vhd`
258+
- **Downtime**: The OVA can only be exported while the VM is off (except if you export a clone, but all blocks written after the clone won't be on the imported VM. If you can sync after, it's fine!). This can take a while, and your VMs won't be reachable until it's fully exported AND imported on destination.
259+
- **Storage**: You need an intermediary storage where you can export then import the OVA file. If your VMs are small, it's OK.
260+
- **Manual process**: Even if it's simple to do, it can be cumbersome if you have a lot of VMs to migrate.
261+
:::
290262

291-
* Use rsync to copy the converted files (VHD) to your XCP-ng host.
292263

293-
* After the rsync operation, the VHD are not valid for the XAPI, so repair them :
264+
:::note
265+
OVA import method will miss the information if the VM is running BIOS or UEFI mode. Double check your settings on your original system, and then enable (or not) UEFI on XCP-ng side for the destination VM. You can do so in VM advanced tab in Xen Orchestra.
266+
:::
294267

295-
`vhd-util repair -n myvm.vhd`
268+
### CloneZilla
296269

297-
`vhd-util check -n myvm.vhd` should return `myvm.vhd is valid`
270+
Clonezilla is a free and open-source disk imaging and cloning tool used for system backups, recovery, and deployment.
298271

299-
* For each VM, create a VDI on Xen Orchestra with the virtual size of your VHD + 1GB (i.e the virtual size of myvm is 21GB, so I create a VDI with a size of 22GB).
272+
1. Insert a CloneZilla live CD in your existing VM, and boot on it. In the meantime, you also have a VM on the destination with the right metadata (same name and disks), which you'll also boot with CloneZilla.
300273

301-
* Get the UUID of the VDI (on Xen Orchestra or CLI) and use the CLI on the XCP-ng host to import the VHD content into the VDI :
274+
2. From the VM console, you can tell the source VM running CloneZilla to send all the blocks to the destination VM, also running CloneZilla.
302275

303-
`xe vdi-import filename=myvm.vhd format=vhd --progress uuid=<VDI UUID>`
276+
3. As soon it's done, you can safely shut down the original VM and boot the copy on destination!
304277

305-
* Once the import is done, create a virtual machine using XO or XCP-ng Center, delete the VM disk that has been created and attach your newly created VDI to the VM. Don't forget to set the VM boot mode to UEFI if your VMs was in UEFI mode.
278+
:::warning
279+
- **Downtime**: Even if the downtime will be reduced compared to using OVA, you still need to run the export/import process while the VM is off.
280+
- **Setup time**: Not complex, but various operations are needed until you can start the replication for one VM. If you have a lot of VMs, this can take some effort.
281+
:::
306282

307-
* Boot the VM and find a way to enter in the virtual UEFI of the VM. Here, I type the Escape and F9,F10,F11,F12 keys like crazy. Select Boot Manager, you should see this window :
283+
## 📥 Import the VHD
308284

309-
![](../../assets/img/migrate-to-xcp-ng_bootloader.png)
285+
### With Xen Orchestra
310286

311-
* Select `UEFI QEMU HARDDISK`, the screen should be black for seconds and you should see the GRUB. Let the machine worked for minutes and you should see the prompt finally 👍
287+
In the left menu, go for "Import" then "Disk". Select the destination SR, and then add your VHD file into it. Depending on the VHD file size, it might take some time. The upload progress can be tracked in another XO tab, in the "Task" menu.
312288

313-
* Install Guest Tools and reboot. The reboot shouldn't take long, you don't have to redo step 13, the OS seems to have repair the boot sequence by itself.
289+
![](../assets/img/import-disk.png)
314290

315-
Done !
291+
When the disk is imported, you can:
292+
293+
- Create a VM with the appropriate template, **without any disk in it**
294+
- Attach the previously imported disk (VM/Disk/Attach an existing disk)
295+
- Boot the VM
296+
- Install the tools
297+
298+
### Via the CLI
299+
300+
You can transfer the VHD file directly to your XCP-ng storage repository (SR) using SCP:
301+
302+
```
303+
scp thegenerateduuid.vhd ip.xcp-ng.server:/run/sr-mount/uuid-of-your-SR
304+
```
305+
306+
:::warning
307+
The name of your VHD MUST BE an uuid (e.g. 44ad36fc-e9f1-4d74-9090-2d9bffddbee2.vhd).
308+
309+
You can generate one with the command `uuidgen` on Linux.
310+
:::
311+
312+
You need to rescan the SR where you new VHD file is, so it can be detected. It will appear in the disk list, without a name or description though. You can use `xe sr-scan` or use the scan button on the storage in Xen Orchestra.
313+
314+
In Xen Orchestra, create a new VM without a disk, and make sure to uncheck the "Boot VM after creation" option under advanced settings. Then, go to the "Disks" tab, click on "Attach disk", select the VHD you just uploaded, and attach it.
315+
316+
317+
## 🛠️ Troubleshooting
318+
319+
### My imported VM is not booting
320+
321+
- Check if the Boot firmware (in advanced setting) is on the correct type (BIOS or UEFI)
322+
- Check if the boot disk is the first in the VM disk tab
323+
- Check [here](../../installation/migrate-to-xcp-ng/#error-dracut-initqueue227-warning-devmapperol-root-does-not-exist-or-no-bootable-device)
324+
325+
### Error "dracut-initqueue[227]: Warning: /dev/mapper/ol-root does not exist" (or no bootable device)
326+
327+
This error means Xen driver are not present in the kernel (see [here](../../installation/migrate-to-xcp-ng/#install-xen-drivers))
328+
329+
You can boot an live CD, and mount root and boot partition
330+
```
331+
mount <root device> /mnt/
332+
mount <boot device> /mnt/boot/
333+
334+
for x in sys proc run dev tmp; do mount --bind /$x /mnt/$x; done
335+
```
336+
Check your fstab to see the exact layout of your partition !
337+
If you have LVM partition, you can enable them with `vgchange -ay`
338+
339+
Chroot in your mounted partition
340+
```
341+
chroot /mnt
342+
```
343+
Find your initrd files (if you have several file, use the more recent version), usualy in /boot or /boot/efi
344+
Then add the xen drivers:
345+
```
346+
dracut --kver <version> -f /boot/initrd<version> --add-drivers "xen-blkfront xen-netfront" --force
347+
```
348+
Exit the chroot, unmount all your partition, and you can reboot, or detach the disk if you used your XO
349+
You VM should be booting now !

0 commit comments

Comments
 (0)