Change the new hostname in the following 3 files:
nano /etc/hosts
nano /etc/hostname
nano /etc/postfix/main.cf
Make a Backup of all the files and folder below before beginning …
mkdir /home/pve2-node/yourhostname
mkdir /home/pve2-storage/yourhostname
mkdir /etc/pve/nodes/yourhostname
Now lets begin
Next, copy the VMs and configuration to the new hostname folder:
cd /etc/pve/nodes/
cp -r old_hostname/ new_hostname/
rm -r old_hostname
Also copy the contents of /var/lib/rrdcached/db/pve2-{node,storage}/old-hostname to /var/lib/rrdcached/db/pve2-{node,storage}/new-hostname and remove the old directory.
cd /var/lib/rrdcached/db/pve2-node/
cp -r old_hostname new_hostname
cd /var/lib/rrdcached/db/pve2-storage/
cp -r old_hostname new_hostname
Now remove the old hostname from both folders.
cd /var/lib/rrdcached/db/pve2-node/
rm -r old_hostname
cd /var/lib/rrdcached/db/pve2-storage/
rm -r old_hostname
Now reboot!
reboot
That’s it, It should now show all your vm’s with your new hostname.
NOTE:
If you run into issues, reverse the process by returning the original files you backed up, to there original locations while also returning your hostname back to its original and all will return to normal.