Hostname keep changing when reboot

Hi,
Does anyone know why my hostname keeps being changed when I reboot it? I’m using this command:

sudo hostnamectl set-hostname aml-s905x-comp1

The change is supposed to be permanent, I’m using Ubuntu 22.04.
Thanks!

Hostname are set by different components on different images. On Ubuntu server, it is set by cloud-init so it should be modified in /etc/cloud.d/. On Raspbian, it should be /etc/hostname and /etc/hosts.

1 Like

I ended up modifying /etc/cloud/cloud.cfg and I’ve set preserve_hostname: true and it worked :slight_smile:

2 Likes