Proxmox node name change

Thanks @DvdNwk for the very helpful information!

This is what it took for me on a single node PVE 8.4.14 non-subscription, minus bunny trails:

1. Back up the entire pve config: cp -r /etc/pve /root/pve_backup
2. Set the new hostname: hostnamectl hostname NEW
3. Update the hostname in /etc/hosts – replace OLD with NEW, might be a good idea to leave an entry with the old hostname though.
4. Update the Postfix config in /etc/postfix/main.cf – replace OLD with NEW
5. Disable starting guests on reboot: systemctl disable pve-guests
6. Reboot: reboot
7. Stop the cluster filesystem: systemctl stop pve-cluster (DON'T do it if you're connected via the web gui - you will probably lose access and be forced to gain shell access some other way.) Not 100% sure if it is necessary but I did it.
8. Run pmxcfs -l - should succeed without lock errors
9. Go into the nodes config dir: cd /etc/pve/nodes
10. Delete the NEW dir that was created after the hostname changed: rm -rf NEW
11. Copy the node folder over: cp -r OLD NEW This will print a bunch of cp: cannot create regular file 'NEW/qemu-server/XXXX.conf': File exists Don't worry, the rest of the files should have been copied with no problems. This is because /etc/pve is actually a virtual file system that doesn't like to have duplicate VM/container configuration files.
12. Copy over the VMs configuration using different IDs: for file in OLD/qemu-server/*.conf; do cp "$file" "NEW/qemu-server/9$(basename $file)"; done This command will prefix everything with an extra 9, so make sure none of your VMs have an ID starting with 9 to avoid issues later.
13, Do similar for any containers in OLD/lxc.
14. Remove the old files: rm -rf OLD
15. Rename the files back to the original IDs: for file in NEW/qemu-server/9*.conf; do mv $file NEW/qemu-server/${file##*/9}; done
16. Do similar for any containers in NEW/lxc.
17. Go into the rrdcached folder: cd /var/lib/rrdcached/db/pve2-node/
18. Copy the old folder into the new: cp -r OLD NEW
19. Remove the old folder: rm -rf OLD
20. Do the same in /var/lib/rrdcached/db/pve2-storage
21. Re-enable starting guests on reboot: systemctl enable pve-guests
22. Reboot: reboot
23. Once you are confident everything is working, you can remove the backup: rm -rf /root/pve_backup
 
Last edited: