Persisting hostname for cloud-init enabled Cloud VPS/VDS
As cloud-init
sets the hostname on each reboot, the hostname you wish to set may not be persistent or reboot safe.
There are several possibilities to make sure your hostname remains:
- simply set the hostname via cloud-init, please refer to Set Hostname. Then it will always be set to the desired name.
- disable cloud-init altogether by
sudo touch /etc/cloud/cloud-init.disabled
- perform a proper shutdown or reboot of your operating system e.g. via
reboot
. This will eject the cloud-init file mounted causing setting the hostname on each reboot.