Modify Proxmox Hostname


Step 1: Change the Hostname

Run the following command and modify the following three files:

hostnamectl set-hostname new-hostname

vim /etc/hosts

vim /etc/hostname

vim /etc/postfix/main.cf

Step 2: Backup

Backup all files in the `/etc/pve` directory to a local machine. Ensure the backup is stored locally.

Step 3: Near Disaster

First, stop the file synchronization service and force the local data to be authoritative:

systemctl stop pve-cluster

pmxcfs –local

At this point, my `/etc/pve` directory became empty, with no files at all. After copying the backup files back into the directory, the system continued to report errors.

I searched for solutions based on the error messages on the official forums but found nothing useful.

Unable to identify the cause, I compared the `mount` list of a properly running machine and the faulty machine but found no differences.

Next, I compared the disk space usage using `df -h` on the problematic and functioning machines and discovered the following error message:

fuse: mountpoint is not empty

fuse: if you are sure this is safe, use the ‘nonempty’ mount option.

Clearing out the `/etc/pve` directory resolved the issue. Afterward, I ran the `pmxcfs` command to reload `/dev/fuse`.

Commands to Execute:

# Make a backup!

cp -r /etc/pve/nodes/old-hostname /tmp/old-hostname

# This might fail; deal with it later

rm -rf /etc/pve/nodes/old-hostname

# Copy instead of moving since pmxcfs doesn’t allow moving non-empty folders

cp -r /etc/pve/nodes/old-hostname /etc/pve/nodes/new-hostname

Once you confirm there is only one folder under `nodes` with the new hostname, you need to update some symbolic links in the file system. These symbolic links are not user-writable and are automatically configured when the file synchronization service starts. Therefore, restart the file synchronization process:

killall pmxcfs

systemctl restart pve-cluster

RRDcache

systemctl stop rrdcached

cd /var/lib/rrdcached/db

cd pve2-node

rm new-hostname

mv old-hostname new-hostname

cd ../pve2-storage

rm -rf new-hostname

mv old-hostname new-hostname

systemctl start rrdcached

Repeat the following:

systemctl stop rrdcached

cd /var/lib/rrdcached/db

cd pve2-node

rm new-hostname

mv old-hostname new-hostname

cd ../pve2-storage

rm -rf new-hostname

mv old-hostname new-hostname

systemctl start rrdcached

Some log replay errors might occur during service restart due to the filename changes. These can be ignored.

API Server

The API and certain reverse proxies rely on the hostname to locate the appropriate host (even if your PVE setup is a single node). Restart the related services to reload the correct configuration:

systemctl restart pvedaemon

systemctl restart pvestatd

systemctl restart pveproxy

systemctl restart pvebanner

Since the steps might vary slightly depending on your version, ensure the backup is copied locally. Delete the contents of the original `nodes` folder, create a new folder named after the new hostname, and copy the original contents into the newly created folder.


Leave a Reply

Your email address will not be published. Required fields are marked *