LXC change VM ID

serverx

Active Member
Mar 3, 2017
8
1
43
54
Hello, i need to move some LXC vm between hosts but the destination host have already some vm with same IDs..... somebody know how to change the lxc vm ids ?
Thanks
 
via Backup/Restore.
 
hello, i tried to move the vm 107 to different host, but the ID 107 do not change..... how to do ?
Thanks
 
you have to do a backup of your container, then transfer the vzdump-lxc-* file to the new host, and there you have to restore it under a different id
 
try under the storage -> content -> backup file
instead
 
I know it's an old topic but this could help someone :


EXAMPLE : rename an LXC container from 100 to 101
1- Be sure there are NO VM with the target id (here 101)
2- Please be CARREFUL, be sure you know what you are doing and check every line and name that it is correct (do not use the names in my example)
3- Stop the container
4- Open host shell
5- Rename the disks :
Code:
zfs rename tank/subvol-100-disk-0 tank/subvol-101-disk-0
and so on for each disk
6- Edit the configuration file in /etc/pve/lxc/100.conf to correct the disks names (eg 100 to 101)
7- Rename the configuration file :
Code:
mv /etc/pve/lxc/100.conf /etc/pve/lxc/101.conf
8- Go to the web UI, the change should be seen soon

Tested on PVE 5.4
Also consider that I have not tested with a VM that has snapshots for replication, but I GUESS it only needs to rename the disks AND snapshots on all the nodes involved, then edit the configuration file in /etc/pve/replication.cfg.
 
For future reference, Benoît's guide still works with PVE 8.1. One minor addition as I experienced this myself:

6a. If existing, move the relevant firewall config file too:
Code:
mv /etc/pve/firewall/100.fw /etc/pve/firewall/101.fw

Regards
 
  • Like
Reactions: KarolTheGuy

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!