How To Change the ID of a Proxmox VM
For whatever reason I find that seeing gaps in IDs between VMs annoying. I don't like seeing gaps such as:
VM100 - 100 VM101 - 101 VM103 - 103 VM104 - 104
Thankfully there's a bit of a way to adjust the IDs for VMs. I would recommend taking a backup of the VM and it's configuration file(s) beforehand. Once you're ready you can run the following command to display information about your logical volumes.
This should display something similar to:
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert vm-100-disk-0 data -wi-ao---- 120.00g vm-101-disk-0 data -wi-ao---- 80.00g vm-101-disk-1 data -wi-ao---- 120.00g vm-102-disk-0 data -wi-a----- 120.00g vm-103-disk-0 data -wi-ao---- 80.00g vm-104-disk-0 data -wi-ao---- 80.00g vm-105-disk-0 data -wi-ao---- 320.00g vm-105-disk-1 data -wi-ao---- 120.00g vm-105-disk-2 data -wi-ao---- 120.00g vm-106-disk-0 data -wi-ao---- 80.00g vm-107-disk-0 data -wi-ao---- 120.00g data pve twi-a-tz-- 59.66g 0.00 1.59 [data_tdata] pve Twi-ao---- 59.66g [data_tmeta] pve ewi-ao---- 1.00g [lvol0_pmspare] pve ewi------- 1.00g root pve -wi-ao---- 27.75g swap pve -wi-ao---- 8.00g
Next, determine which VM you're wanting to change the ID of. In the following commands I will be changing the VM ID of 101 to 100.
This command will update the name of the logical volume:
lvrename data/vm-101-disk-0 vm-100-disk-0
Next we want to update the ID in the VMs configuration file:
sed -i "s/101/100/g" /etc/pve/qemu-server/101.conf
After that we want to rename the VMs configuration file:
mv /etc/pve/qemu-server/101.conf /etc/pve/qemu-server/100.conf
Once those commands have been run you can start the VM up again.