Hello all,
Lately I was searching for a solution to live / online migrate KVM VMs with block device backend (DISK / LVM / SAN ) to Proxmox ( any kind of storage that is supported / configured ).
Because there are users that have huge VMs in production and downtime is not an option ( so dd is not a workable scenario ), I tried to put together a solution so I can migrate also this clients to Proxmox.
Of course, this approach depends on your current setup, but with this information I think that you can adapt to your environment.
Without further introduction, the steps are this:
0. Backup
1. On source physical server where you have KVM, install nbd-server or nbdkit.
2. Shutdown the VM.
3. Export the VM backing device (or devices) with something like: nbdkit -p 9999 file /dev/vgname/lvname
You can export multiple disks, but with different ports. You can export /dev/mapper/sandisk or local raw disk or any raw block device.
Secure transfer between the hosts or any other security measures is in your hand. My recommendation is at least setup some iptables rules on the source host so there will be no traffic with those ports from any other host except the destination Proxmox.
4. On target Proxmox, install nbd-client or nbdkit. It's up to you which version of NBD better suites your need.
apt install nbd-client
5. Map the remote disk locally:
nbd-client remoteip 9999 /dev/nbd0
6. Create a temporary storage if your current Proxmox does not support file based VM disk images.
Something like: create /tmpfs folder , Datacenter -> Storage -> Add Directory -> /tmpfs ...
7. Create the VM that you want to migrate, but without backing disk. I recommend to clone also the MAC address from the source VM.
Get the VM ID.
8. In Proxmox CLI:
Create a folder like /tmpfs/images/vmid
in this folder:
ln -s /dev/nbd0 transfer0.raw
chmod 666 /dev/nbd0 (adapt to your specific needs)
qm rescan
9. In Proxmox GUI, go to your VM, double click on the unused disk and set it up accordingly, In hardware change the boot order to boot from this disk.
10. I didn't mention anything about drivers or other problems with the migration, because this are self explanatory that they are needed.
11. Boot the VM
12. Disk actions -> Move storage
13. TEST
14. Clean up: remove unusued disk, Remove Storage tmpfs, nbd-client -d /dev/nbd0
15. Enjoy and give a reply if you noticed a problem.
Lately I was searching for a solution to live / online migrate KVM VMs with block device backend (DISK / LVM / SAN ) to Proxmox ( any kind of storage that is supported / configured ).
Because there are users that have huge VMs in production and downtime is not an option ( so dd is not a workable scenario ), I tried to put together a solution so I can migrate also this clients to Proxmox.
Of course, this approach depends on your current setup, but with this information I think that you can adapt to your environment.
Without further introduction, the steps are this:
0. Backup
1. On source physical server where you have KVM, install nbd-server or nbdkit.
2. Shutdown the VM.
3. Export the VM backing device (or devices) with something like: nbdkit -p 9999 file /dev/vgname/lvname
You can export multiple disks, but with different ports. You can export /dev/mapper/sandisk or local raw disk or any raw block device.
Secure transfer between the hosts or any other security measures is in your hand. My recommendation is at least setup some iptables rules on the source host so there will be no traffic with those ports from any other host except the destination Proxmox.
4. On target Proxmox, install nbd-client or nbdkit. It's up to you which version of NBD better suites your need.
apt install nbd-client
5. Map the remote disk locally:
nbd-client remoteip 9999 /dev/nbd0
6. Create a temporary storage if your current Proxmox does not support file based VM disk images.
Something like: create /tmpfs folder , Datacenter -> Storage -> Add Directory -> /tmpfs ...
7. Create the VM that you want to migrate, but without backing disk. I recommend to clone also the MAC address from the source VM.
Get the VM ID.
8. In Proxmox CLI:
Create a folder like /tmpfs/images/vmid
in this folder:
ln -s /dev/nbd0 transfer0.raw
chmod 666 /dev/nbd0 (adapt to your specific needs)
qm rescan
9. In Proxmox GUI, go to your VM, double click on the unused disk and set it up accordingly, In hardware change the boot order to boot from this disk.
10. I didn't mention anything about drivers or other problems with the migration, because this are self explanatory that they are needed.
11. Boot the VM
12. Disk actions -> Move storage
13. TEST
14. Clean up: remove unusued disk, Remove Storage tmpfs, nbd-client -d /dev/nbd0
15. Enjoy and give a reply if you noticed a problem.
Last edited: