Categories
Uncategorized

Proxmox migrate VM’s from one PVE to another PVE with LVM-thin

I recently acquired a new Proxmox PVE host and wanted to migrate my existing VM’s without doing anything too crazy with PBS (proxmox back up service) or other storage devices. I also only have local storage, no SAN/NAS setup for the proxmox host. It is a single host, nothing clustered at home right now. So I wanted a simple solution to just lift and migrate. The quickest way I came up with is to use SSHFS to mount on the new box, and then copy the disk and config file over, done. Nothing complicated about it.

Some pre-requisites. The hosts are on the same LAN, configured to use the same subnet and VLAN already. Both PVE are already updated and ready to go on Proxmox 8.4.12.

TL;DR Commands for LVM-Thin

Step-by-Step Instructions


1. On the destination PVE (10.10.5.250), create the VM shell

qm create 100 --name migrated-vm --memory 2048 --cores 2 --net0 virtio,bridge=vmbr0

Adjust CPU, memory, and bridge as needed. I compare it to my old one, I am sure options are missing, as this is very basic setup. I like to change QEMU Guest Agent enabled, OS type and enable start at boot.


2. On the source PVE (10.10.5.5), check the VM disk path

qm config 100

Find the disk name, e.g.:

scsi0: local-lvm:vm-100-disk-0

Then confirm actual device path:

lvs

You’ll see something like:

  vm-100-disk-0  pve Vwi-aotz-- 32.00g data

Device path is:

/dev/pve/vm-100-disk-0

Now make sure the VM is off via GUI or CLI:

qm shutdown 100


3. On the destination PVE (10.10.5.250), stream and convert the disk

Run this from the destination, which will SSH into the source, read the raw disk, and import it. Make sure the VM is stopped before, you can do it via gui or command line:

apt install pv -y
ssh root@10.10.5.5 "cat /dev/pve/vm-100-disk-0" | pv > /var/lib/vz/vm-100-disk-0.raw

4. Attach the disk to the new VM

After import completes, attach the new disk:

qm importdisk 100 /var/lib/vz/vm-100-disk-0.raw data --format raw

If the imported disk has a different name (check with lvs), adjust the name accordingly.


5. Set the disk on the VM on the new pve

You can either import the disk like this, or go down to the optional section to grab the config on the source pve and get the correct configuration.

qm set 100 --scsi0 data:vm-100-disk-0
qm set 100 --scsihw virtio-scsi-pci

Before you start the vm on the new pve, double check your hardware specs for your Hard Disk compared to your old host. I like to make sure iothread = 1 and discard = on for mine, as they are on nvme drives.

You also want to make sure you go to options and enable the disk boot under boot order.

Once you are done, you can go ahead and delete your .raw file. Or leave it as a back up.

rm /var/lib/vz/vm-100-disk-0.raw

Optional: Copy VM Config Instead of Rebuilding

If you want the original VM config from the source, copy it like this:

scp root@10.10.5.5:/etc/pve/qemu-server/100.conf /etc/pve/qemu-server/

Then attach the disk:

qm set 100 --scsi0 local-lvm:vm-100-disk-0

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x