Hostname change after every reboot

asmar

Active Member
Nov 15, 2014
108
0
36
Hi all,

I've got a Proxmox4 running fine but any LXC VM I'm creating it doesn't keep the hostname I give and after every reboot it change.

For example, I setup during installation the hostname on a vm to be "vm1.mydomain.com"
When I reboot or shutdown the VM then if I run hostname I get just the name and not the full hostname so it is showing vm1 instead of vm1.mydomain.com and that gives me problem on a software I'm running.

Is this a bug and any workaround on it?

Thanks

Example output:

root@proxmox2 ~ # cat /etc/pve/lxc/101.conf
arch: amd64
cpulimit: 6
cpuunits: 1024
hostname: email1.mydomain.com
memory: 8192
nameserver: 208.67.222.222 8.8.8.8 8.8.4.4
net0: bridge=vmbr0,gw=192.168.1.10,hwaddr=32:63:32:30:38:36,ip=192.168.1.10/32,name=eth0,type=veth
ostype: debian
rootfs: local:101/vm-101-disk-1.raw,size=60G
searchdomain: google.de
swap: 8192



root@email1:~# hostname -f
email1

root@email1:~# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.1.10 email1 email1.mydomain.com
 
Last edited:
After a few tests, this is happening only on the LXC Debian 8 template. Installing CentOS 7 works fine.
Any idea about where I can download a different Debian Jessie template to test?

Thanks
 
Hmm, i don't know, but maybe this is a problem with hostnamectl in the container it self. Hostnamectl is used by systemd to set the hostname and other hostinformation. Test this: Set the hostname first normaly in lxc, then set it second time in the container direktly with hostnamectl.
 
I have the same problem with Proxmox4 Debian8 template: whatever changes made to /etc/hosts: it is reset at each restart of the vm.
Note that there is no hostnamectl command installed and systemd is deactivated on proxmox4 debian8 template.
 
Davidm, tried anything I found and simply doesn't work. I switched to KVM which works fine.
 
@LnxBil if you put the /etc/hostname in immutable the vm doesn't start afterwards.

lxc-start 1458917760.765 ERROR lxc_conf - conf.c:run_buffer:342 - Script exited with st
atus 1
lxc-start 1458917760.765 ERROR lxc_start - start.c:lxc_init:436 - failed to run pre-sta
rt hooks for container '103'.
lxc-start 1458917760.765 ERROR lxc_start - start.c:__lxc_start:1170 - failed to initial
ize the container
lxc-start 1458917765.770 ERROR lxc_start_ui - lxc_start.c:main:344 - The container fail
ed to start.
lxc-start 1458917765.770 ERROR lxc_start_ui - lxc_start.c:main:346 - To get more detail
s, run the container in foreground mode.
lxc-start 1458917765.770 ERROR lxc_start_ui - lxc_start.c:main:348 - Additional informa
tion can be obtained by setting the --logfile and --logpriority options.
 

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!