Proxmox node name change

petka

New Member
Hello everyone!

As mentioned in the topic - I have only 1 proxmox node (which is not in a cluster or so) and would like to change its name.
Is there any way I could do that without rebooting the hypervisor?

If yes, how?

P.
 
change /etc/hostname and /etc/hosts
 
  • Like
Reactions: chrone
Re: [SOLVED] Proxmox node name change

Hello,

Actually, that hostname change caused me a lot of troubles. Indeed, when you change these files your hostname would change but:
1) It creates a separate datacentre (called with the new name)
2) All of your virtual machines are in the "old" datacentre
3) You can not power on old machines in the old datacentre as you removed the old hostname
4) When you click on the old datacentre you see "proxy loop error"

I was also thinking of backing up all of my machines and importing it to the new datacentre, but why do I need to make such an effort because of the hostname change?

P.
 
Re: [SOLVED] Proxmox node name change

copy all files and folders below /etc/pve/nodes/old to the /etc/pve/nodes/new,

then remove /etc/pve/nodes/old
 
  • Like
Reactions: chrone
The following was done to change the hostname on a PVE 3.0 machine:
Code:
nano /etc/hosts
nano /etc/hostname
nano /etc/postfix/main.cf
cd /etc/pve/nodes/
cp -r old new
rm -r old
cd /var/lib/rrdcached/db/pve2-node/
cp -r old new
rm -r old

On reboot the Web GUI was inaccessible and so was PuTTY although the physical machine could be logged into.

The following was also tried to no avail:
Code:
#!/bin/bash
# 
usage() {
   echo "usage : $0 new_host_name"
   exit 1
}

[ -z $1 ] && usage

old=`hostname`
new=$1

for file in \
   /etc/exim4/update-exim4.conf.conf \
   /etc/printcap \
   /etc/hostname \
   /etc/hosts \
   /etc/ssh/ssh_host_rsa_key.pub \
   /etc/ssh/ssh_host_dsa_key.pub \
   /etc/motd \
   /etc/ssmtp/ssmtp.conf
do
   [ -f $file ] && sed -i.old -e "s:$old:$new:g" $file
done
 
Last edited:
Hi guys,

I needed some time to plan a maintenance window and so on.

@tom - Thanks for letting me know, that worked like a charm!
@amputhu - ta very much for the script. It gave me ideas where the hostname variable may hide elsewhere than in /etc/hostname :)

P.
 
Re: [not really SOLVED] Proxmox node name change

Hi, this seems really simple :

copy all files and folders below /etc/pve/nodes/old to the /etc/pve/nodes/new,
then remove /etc/pve/nodes/old

But it doesn't work for me : it says that the "standard file" already exists
Code:
# ls -al batman/openvz/
total 0
drwxr-x--- 2 root www-data 0 aout  20 01:48 .
drwxr-x--- 2 root www-data 0 juin  20 08:29 ..
# cp -f sd-46880/openvz/*.* batman/openvz/
cp: impossible de creer le fichier standard á?batman/openvz/100.conf?â: Le fichier existe

should I delete the cluster before (rm -rf /var/lib/pve-cluster/*) ?
 
Re: [not really SOLVED] Proxmox node name change

So far, the only safe and successful way to migrate / change node name is to create a new Proxmox and move the containers to it. The down side is to either have a new hardware set or atleast another set of hard disks and backup old virtual machines to some network storage to restore from later.

Errors such as "standard file exists" are cryptic indeed and only Proxmox subscription holders can partake of support from the horse's mouth.

In your case see that you migrate only the numbered ###.conf files and not the non-numbered ones.
 
Last edited:
Re: [not really SOLVED] Proxmox node name change

Errors such as "standard file exists" are cryptic indeed and only Proxmox subscription holders can partake of support from the horse's mouth.

The error is quite clear to me - a VM config file with the same VMID already exists - the simple solution is to use 'mv' instead of 'cp'.
 
Re: [not really SOLVED] Proxmox node name change

It still didn't work. Even with the root account.
And after a restart of pve-cluster /etc/pve/openvz linked to the empty /etc/pve/openvz/nodes/newhostname/openvz/
so vzctl enter NNN didn't work because the configuration file wasn't found
I restored the old hostname (/etc/hostname etc..) and I can now enter again in the vm.
The web interface doesn't work (there is still the old 'newhostname' node inside), but it doesn't matter.
 
Re: [not really SOLVED] Proxmox node name change

The web interface doesn't work (there is still the old 'newhostname' node inside), but it doesn't matter.

I've restarted pveproxy and then pve-cluster.
Now everything is fine.
I only see one node in the GUI
 
apmuthu said:
Errors such as "standard file exists" are cryptic indeed and only Proxmox subscription holders can partake of support from the horse's mouth.

Dietmar said: ↑
The error is quite clear to me - a VM config file with the same VMID already exists - the simple solution is to use 'mv' instead of 'cp'.

This is a disingenious answer from Dietmar.

The error occurs because /etc/pve is virtual file system managed by the cluster file system, even if you only have one node. The files actually live inside a managed database. If a 100.conf file exists on any node, including the deleted and not available node, it is deemed to exist, since the cluster manager doesn't allow two nodes to exist in the same datacenter to have the same (conflicting) node number.

* provides strong consistency checks to avoid duplicate VM IDs

If you follow the instructions in link above to take the cluster offline, then you can make the changes in local mode.

service pve-cluster stop
pmxcfs --local
(make changes)
service pve-cluster stop
restart pve services (or reboot)
 
  • Like
Reactions: Frechetta93
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.
 
Thank you @breakaway9000 for the very helpful response. I just wanted to add that the files have to be MOVED for some reason. Copying them doesn't seem to work - I got "file exists" or something just like another user here did. I just assume they are special in some way.

Also, I simply restarted pveproxy at the end. I didn't have to reboot again.

If anyone wants to save the old rrd data that's all under /var/lib/rrdcached/db. I didn't care about this data, so I simply deleted the entry for the old hostname.
 
Apart from what was already mentioned, here are a couple more things I had to do:

1) Change some storage and config references in /etc/pve - just do a grep -ir 'oldhostnamehere' /etc/pve/. to find that
2) Don't forget to change the Search domain option for the node's DNS so your containers have they hostname set correctly (since PVE sets these dynamically).
 
Further to this.

I installed the cluster version of Proxmox on a single system, which mounts a FUSE filesystem over /etc/pve. Due to how the system works, the new node name's qemu-server directory under /etc/pve/nodes/newnodename is effectively unwriteable.Attempting to copy files from the old directory to the new resulted in no new files being created. Attempting to use
cat 101.conf >../../newnodename/qemu-server/101.conf
gave me an error saying the files were the same.

Because the FUSE file system is actually a sqlite3 file, I did the following:
  • Shut down pve-cluster: systemctl start pve-cluster
  • Go to /var/lib/pve-cluster
  • Dump the config.db file: echo ".dump" | sqlite3 config.db >config.sql
  • Use a text editor to change the node name on line 9 of the dump file to the new name
  • Delete a series of lines relating to the new name from the end of the file
  • Save the changed file
  • Re-load the database from the dump: echo ".read config.sql" | sqlite3 config.db
  • Restarted pve-cluster: systemctl start pve-cluster
After the restart my node was fine.

Note that this is probably an edge case: I was running a "culster" version of Proxmox on a single node. However this information may be useful in other situations.
 
Hopefully this helps other people that came from here: https://pve.proxmox.com/wiki/Renaming_a_PVE_node

I followed the instructions in the wiki and could not start my containers as others above me have experienced.

If you revert the changes you made by following the wiki and restarting, everything works as it did before the change.

Thanks to everyone above for sharing their experience and steps to follow to complete the hostname change.
 

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!