How to change hostname proxmox

How to change hostname proxmox

Proxmox virtual environment uses the hostname as a node’s name, so changing it works similarly to changing the hostname. This must be done on an empty node.

Change hostname Proxmox

Solution I:

To change the hostname of Proxmox you should first turn off all virtual machines or containers on Proxmox. Then change the hostname of the /etc /hosts file from “proxmox1.sysadminote.com proxmox1″ to “proxmox2.sysadminote.com proxmox2″ and the /etc/hostname file from “proxmox1″ to “proxmox2″.

You can check how many nodes there are on Proxmox in the /etc/pve/nodes/ folder.

To check node:

# ls etc/pve/nodes/

First backup the data in proxmox1:

cp -R /etc/pve/nodes/proxmox1/ /root/

Next, move all the files and folders from the proxmox2 folder to proxmox1:

mv /etc/pve/nodes/proxmox1/* /etc/pve/nodes/proxmox2/*

You might go through the below error:

mv: cannot move ‘/etc/pve/nodes/proxmox1/qemu-server’ to ‘/etc/pve/nodes/proxmox2/qemu-server/qemu-server’: Directory not empty

Then need to move the file manually, and execute the below command:

mv /etc/pve/nodes/proxmox1/qemu-server/100.conf /etc/pve/nodes/proxmox2/qemu-server/

And make sure that the old hostname (proxmox1) node is deleted from the Proxmox dashboard. You can also delete the unnecessary nodes in the /etc/pve/nodes/proxmox1 folder.

Solution II:

Changing the hostname of a Proxmox node finds a bit harder than changing the hostname of your typical Linux machine. However, you can follow the below simple steps to change the hostname.

First, change the hostname as you would do on any Debian-based machine.

hostnamectl set-hostname NEW-HOSTNAME

Then update your host’s file:

vim /etc/hosts

By this Proxmox will momentarily create a new node with the new hostname:

ls -la /etc/pve/nodes

Now you will find a folder with the same name as your old hostname and one with your new hostname. If you can’t find the folder with the new hostname, then you have to wait a bit or you can restart the machine.

Before proceeding  it is better to take a backup of the current config files:

cp -r /etc/pve/nodes/OLD-HOSTNAME /root/

Next, you need to copy the configuration files for the old hostname to the new one.

cp /root/OLD-HOSTNAME/qemu-server/* /etc/pve/nodes/NEW-HOSTNAME/qemu-server

Finally, reboot the system.

reboot