Proxmox node name change

Am I correct that changing the hostname in a cluster setup with existing VMs would break the entire installation? Or is it somehow possible to change it by editing the SQLite DB directly?

Reason being that when I initially setup the cluster, our naming convention wasn't finalized yet. Can change it on all other hosts, so just the PVE hosts would remain with the old naming scheme...
Afaik that is correct, attempting to change the hostname of a host that is set up is not supported, or recommended.

but if you back up your containers and vms, reinstall, and do the steps laid out in the comment above yours, you can restore the containers afterwards no problem.

Unless you have a lot of host modifications, which proxmox definitely mentions is not recommended somewhere in their wiki, it's pretty straightforward.
 
Yes, I have done it on v7.2.3. First, I struggled like many of you, too. I finally succeeded by combining 2 major steps:

A)
As mentioned in https://pve.proxmox.com/wiki/Renaming_a_PVE_node I corrected the hostname to the new name in the following files:
  1. /etc/hosts
  2. /etc/hostname
  3. /etc/postfix/main.cf
I then rebooted the host.

B)
I followed the combined steps indicated by ikke and bryanpedini further up in this thread:
  1. systemctl stop pveproxy.service
  2. I emptied the folder /etc/pve/nodes/$NEWHOSTNAME
  3. I moved the contents of the folder /etc/pve/nodes/$OLDHOSTNAME to /etc/pve/nodes/$NEWHOSTNAME
  4. I removed the folder /etc/pve/nodes/$OLDHOSTNAME
  5. systemctl start pveproxy.service
Furthermore, I opened the "Storage" menu in the Proxmox GUI at the level "datacenter" and opened the storage containers one by one. Wherever the old hostname was in the field "Nodes" I exchanged it with the new hostname. - If you don't check your storage containers you may run into errors of the following kind when starting virtual machines:
TASK ERROR: storage 'YOUR-STORAGE-NAME' is not available on node 'OLDHOSTNAME'

This worked for me.
root@svr-pve1:/# pveversion
pve-manager/7.3-3/c3928077 (running kernel: 5.15.74-1-pve)


Best Regards!!
 
  • Like
Reactions: RmFeUTOK
Hi guys, chiming in as I to wanted to rename my fairly fresh install of Proxmos and ran into the same issue that everyone here has described. It's hard to understand why this simply task couldn't be made simpler via the UI.

I also agree that the wiki article needs to be reworded significantly as destroying your VMs should front and center.

Anyway, I eventually reverted my hostname back (/etc/hosts and /etc/hostname).
My main issue in trying to do anything is that no matter what I do, I get access denied when trying to read or copy anything under /etc/pve/nodes. I tried stopping pveproxy.service but no go. I can't even copy the files locally as a backup (tried scp in terminal but also cyberduck and WinSCP)

root@VMserver1:~# pveversion
pve-manager/7.3-3/c3928077 (running kernel: 5.15.74-1-pve)
root@VMserver1:~#
 
  • Like
Reactions: DvdNwk
Yes, I have done it on v7.2.3. First, I struggled like many of you, too. I finally succeeded by combining 2 major steps:

A)
As mentioned in https://pve.proxmox.com/wiki/Renaming_a_PVE_node I corrected the hostname to the new name in the following files:
  1. /etc/hosts
  2. /etc/hostname
  3. /etc/postfix/main.cf
I then rebooted the host.

B)
I followed the combined steps indicated by ikke and bryanpedini further up in this thread:
  1. systemctl stop pveproxy.service
  2. I emptied the folder /etc/pve/nodes/$NEWHOSTNAME
  3. I moved the contents of the folder /etc/pve/nodes/$OLDHOSTNAME to /etc/pve/nodes/$NEWHOSTNAME
  4. I removed the folder /etc/pve/nodes/$OLDHOSTNAME
  5. systemctl start pveproxy.service
Furthermore, I opened the "Storage" menu in the Proxmox GUI at the level "datacenter" and opened the storage containers one by one. Wherever the old hostname was in the field "Nodes" I exchanged it with the new hostname. - If you don't check your storage containers you may run into errors of the following kind when starting virtual machines:
TASK ERROR: storage 'YOUR-STORAGE-NAME' is not available on node 'OLDHOSTNAME'
This worked for me on 7.3, thank you!
 
Proxmox 8 is out now, is there a way to painlessly change the hostname yet? I ran into this issue again on Proxmox 7.4 and it is still highly frustrating that hostnames cannot be easily changed.
 
Proxmox 8 is out now, is there a way to painlessly change the hostname yet? I ran into this issue again on Proxmox 7.4 and it is still highly frustrating that hostnames cannot be easily changed.
Are you saying you can't change node names with Proxmox 8?
 
When you follow the guide to rename your PVE node, but your node is not empty, you'll run into trouble like this (as noted before):
Code:
# cd /etc/pve/nodes
# cp -R old new
cp: cannot create regular file 'new/qemu-server/100.conf': File exists

Or in case of trying to move the directory:
Code:
# mv old new
mv: cannot move 'old' to 'new': Directory not empty

It seems this is due to the fact that the system detects that you're trying to create VMs with the same IDs.
I had success doing the following:
Code:
# systemctl stop pve-cluster
# pmxcfs -l
# cp -R old new
cp: cannot create regular file 'new/qemu-server/100.conf': File exists
# cp old/qemu-server/100.conf new/qemu-server/200.conf # do this for every VM
# mv old /root/ # for backup
# reboot
# systemctl stop pve-cluster
# pmxcfs -l
# cd /etc/pve/nodes/new/qemu-server
# mv 200.conf 100.conf # do this for every VM
# reboot

Slightly involved, but does the trick. Also, I'm not sure if it's necessary to stop the pve-cluster service, manually mount the fuse fs and then reboot.
I did it anyway for reasons of caution.
THIS /\ has worked for me, thanks!

To sum it up:

0. I've had only one node (let's call it OLD) in my `Datacenter` and wanted to rename it (into let's call it NEW)
1. Shutdown the VM in the WebUI -> then ssh into the machine.
2. `nano /etc/hosts` – replace OLD with NEW
3. `nano /etc/hostname` – replace OLD with NEW
4. `nano /etc/postfix/main.cf` – replace OLD with NEW
5. `reboot`
6. `cd /etc/pve/nodes`
7. `ls -alh` – I saw OLD and NEW dirs (both), but their contents did (obviously?) differ
8. `systemctl stop pve-cluster`
9. `pmxcfs -l`
10. `ls -alh` -> `ls: cannot open directory '.': Transport endpoint is not connected` -> just "go into" the dir again:
11. `cd /etc/pve/nodes && ls -alh`
12. `rm -rf NEW` – delete the "NEW" dir that was created after the reboot
13. `cp -R OLD NEW` -> `cp: cannot create regular file 'NEW/qemu-server/100.conf': File exists` – don't worry, the rest of the files should have been copied with no problems
14. `cp OLD/qemu-server/100.conf NEW/qemu-server/200.conf` – YES, change the name in the NEW copy (temporarily)
15. `cp -R OLD /root/OLD_backup` – make a backup just in case
16. `rm -rf OLD`
17. `reboot`
18. `systemctl stop pve-cluster`
19. `pmxcfs -l`
20. `mv /etc/pve/nodes/NEW/qemu-server/200.conf /etc/pve/nodes/NEW/qemu-server/100.conf`
21. `reboot`
22. `rm -rf /root/OLD_backup` – maybe remove the backup if everything works

Ooof, done :p

Thanks again to everyone in this thread –> this kind of info should be in the Wiki, but I guess I won't be able to add it, as I don't know if this is a "substantial change" and I'm pretty sure I'm not a user "with a long-standing account and post history in the community forum" (apparently the criteria to register to the wiki :p). Good luck!
 
Last edited:
+
pvecm updatecerts -f
systemctl restart pveproxy

for disable error:
'/etc/pve/nodes/pve/pve-ssl.pem' does not exist!
Not working here. It's still spamming the logs and asking for the /etc/pve/nodes/oldhostname/pve-ssl.pem.
 
I've found that in my cluster I needed to update these and others; etc/hosts /etc/hostname /etc/postfix/main.cf /etc/pve/corosync.conf /etc/pve/storage.cfg /etc/pve/user.cfg /etc/pve/ceph.conf /etc/pve/priv/known_hosts /etc/pve/ha/groups.cfg

Please read through the entire post before you execute anything

I wrote a one-liner that changes all found occurrences of the old hostname and changes it to the new one:

Bash:
#!/bin/bash
exit 1
OLDNODE="name"
NEWNODE="name"

grep -rnw /etc -e '$OLDNODE' | awk -F ':' '{print $1}' | sort | uniq | xargs -I {} sed -i 's|$OLDNODE|$NEWNODE|g' {}

mv /etc/pve/nodes/$OLDNODE /root/$OLDNODE.backup

postalias /etc/aliases

pvecm updatecerts -f

reboot

Here's a detailed breakdown of each part of the script:

### Updating References in Configuration Files

Bash:
grep -rnw /etc -e '$OLDNODE' | awk -F ':' '{print $1}' | sort | uniq | xargs -I {} sed -i 's|$OLDNODE|$NEWNODE|g' {}

- This pipeline of commands updates references from `$OLDNODE` to `$NEWNODE` in files within the `/etc` directory:

- `grep -rnw /etc -e '$OLDNODE'`: Searches recursively (`-r`) in the `/etc` directory for the exact match (`-w`) of the string `$OLDNODE`, including line numbers (`-n`). Note that single quotes might prevent variable expansion, treating `$OLDNODE` as a literal string. Double quotes should be used if `$OLDNODE` is a variable.

- `awk -F ':' '{print $1}'`: Processes each line from `grep`, using `:` as a field separator, and prints the first field, which corresponds to the file path.

- `sort | uniq`: Sorts the file paths and removes any duplicates, ensuring each file is processed only once.

- `xargs -I {} sed -i 's|$OLDNODE|$NEWNODE|g' {}`: For each unique file path, `xargs` invokes `sed` to replace all occurrences of `$OLDNODE` with `$NEWNODE` in-place (`-i`). The `{}` is a placeholder for the file path. Note that using `|` as a delimiter in the `sed` command allows using paths without escaping `/`.

### Updating Postfix Aliases Database

Bash:
postalias /etc/aliases

- Updates the Postfix alias database. Postfix uses `/etc/aliases` (and its corresponding database file, usually `/etc/aliases.db`) to redirect mail for local recipients. The `postalias` command creates or updates the alias database (`/etc/aliases.db`) from the text file `/etc/aliases`. The hostname (`myhostname`) in the Postfix configuration is updated, and `/etc/aliases.db` might contain the old hostname, necessitating this update.

### Updating Proxmox VE Cluster Certificates

Bash:
pvecm updatecerts -f

- This command updates the certificates used by the Proxmox VE cluster. `pvecm` is a command-line tool for Proxmox VE cluster management, and `updatecerts` is the command used to update the cluster's certificates. The `-f` flag forces the update without asking for confirmation. This might be necessary if the node's hostname or other critical information has changed.

### Rebooting the System

Bash:
reboot

- This command reboots the system.

### General Notes

- The script assumes that `$OLDNODE` and `$NEWNODE` are defined and exported in the environment where the script runs, or they should be replaced with actual values or passed to the script as arguments.
- It's critical to use this script with caution, especially the parts that modify system configurations and reboot the system, as they can have significant effects on the system's operation and accessibility.
- Before running such a script, especially on a production system, it's highly recommended to have a backup and a recovery plan in place.
- Use at your own risk.
- Dont forget to change the /etc/hosts on the other nodes in the cluster to reflect the made changes.
- I first migrated all my nodes to the other nodes in the cluster so that /etc/pve/nodes/$OLDNODE/qemu-server/ was empty, even templates, after the reboot when everything was fine, I migrated the VMs back to the new node. (remove the mds entry for the node your changing the name on first from /etc/pve/ceph.conf before manually recreating).
- Only thing that remained was manually deleting and recreating the CEPH metadata, monitor and managers referencing the old names as in mgr.$OLDNAME, mon.$OLDNAME and mds,$OLDNAME
 
Last edited:
To sum it up:

0. I've had only one node (let's call it OLD) in my `Datacenter` and wanted to rename it (into let's call it NEW)
1. Shutdown the VM in the WebUI -> then ssh into the machine.
2. `nano /etc/hosts` – replace OLD with NEW
3. `nano /etc/hostname` – replace OLD with NEW
4. `nano /etc/postfix/main.cf` – replace OLD with NEW
5. `reboot`
6. `cd /etc/pve/nodes`
7. `ls -alh` – I saw OLD and NEW dirs (both), but their contents did (obviously?) differ
8. `systemctl stop pve-cluster`
9. `pmxcfs -l`
10. `ls -alh` -> `ls: cannot open directory '.': Transport endpoint is not connected` -> just "go into" the dir again:
11. `cd /etc/pve/nodes && ls -alh`
12. `rm -rf NEW` – delete the "NEW" dir that was created after the reboot
13. `cp -R OLD NEW` -> `cp: cannot create regular file 'NEW/qemu-server/100.conf': File exists` – don't worry, the rest of the files should have been copied with no problems
14. `cp OLD/qemu-server/100.conf NEW/qemu-server/200.conf` – YES, change the name in the NEW copy (temporarily)
15. `cp -R OLD /root/OLD_backup` – make a backup just in case
16. `rm -rf OLD`
17. `reboot`
18. `systemctl stop pve-cluster`
19. `pmxcfs -l`
20. `mv /etc/pve/nodes/NEW/qemu-server/200.conf /etc/pve/nodes/NEW/qemu-server/100.conf`
21. `reboot`
22. `rm -rf /root/OLD_backup` – maybe remove the backup if everything works

Ooof, done :p

Thanks again to everyone in this thread –> this kind of info should be in the Wiki, but I guess I won't be able to add it, as I don't know if this is a "substantial change" and I'm pretty sure I'm not a user "with a long-standing account and post history in the community forum" (apparently the criteria to register to the wiki :p). Good luck!

This worked for me on 8.1.4. I had a single node with 2 VMs. No clustering.
 
  • Like
Reactions: DvdNwk
I just found this thread (First hit on google for 'proxmox change hostname').

I am running Proxmox 4.4-2 and I have an assortment of both containers and VMs on my host (qemu). It is a single-host environment, no clustering in use. I am however using a 3-disk RAIDZ-1 for storage (as configured by the Proxmox installer).

It turns out the steps to follow in order to change the hostnames are as follow:
  1. Powerdown all VMs and containers
  2. Edit /etc/hostname and /etc/hosts with the new hostname
  3. Reboot the host
  4. At this point you will see your old host as "disconnected" in the web interface, and a new host with your new hostname appears.
  5. SSH into the machine and navigate to /etc/pve/nodes - here you will see two folders (one with your new hostname, one with your old hostname)
  6. The config for the containers is located at /etc/pve/nodes/<currenthostname>/lxc
  7. The config for virtual machines is stored at /etc/pve/nodes/<currenthostname>/qemu-server
    etc. depending on what other technologies you are using
  8. So I just moved the contents of each folder into the folder for the new host - i.e. /etc/pve/nodes/<newhostname>/lxc etc.
    The second I did this, I saw the web interface update with the VMs and containers now showing in the correct datacenter and under the correct host.
  9. Finally, move the folder with the old server's hostname (/etc/pve/nodes/<oldhostname>) somewhere for backup.
  10. Reboot
When the system came back up the old "disconnected" host was gone, and only the new host was shown with the correct name. All the containers & VMs start up just fine, all the host config has been retained and is working properly.
Your a rockstar my friend. Thanks, this solved hours of work! Thanks.
 

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!