0

I have copied my headless Ubuntu 22LTS server to a backup drive with dd, and I want to deploy it as a backup server with the same relevant settings.
What is the proper way to change the hostname on the copied drive before booting it from the backup hardware?
As the systems run headless, I cannot login to the console to set it interactively after booting it. I need to bring it on the network and login via ssh, but of course I need to avoid collision with the running server.
In the past, I just modified /etc/hostname on the mounted drive, but with systemd things may work differently.

2
  • In short, just the same: freedesktop.org/software/systemd/man/hostname.html
    – Tom Yan
    Commented Sep 14, 2023 at 10:59
  • 1
    "I have copied my headless Ubuntu 22LTS server to a backup drive with dd" - I hope the server wasn't running when you did this, otherwise, this copy is inconsistent and pretty much worthless
    – Panki
    Commented Sep 14, 2023 at 11:16

1 Answer 1

0

@Tom Yan: Thanks for the link. I have searched for my hostname in config files on my system and found some which are not covered by the 'hostname' command.

The main files are /etc/hostname and /etc/hosts, but there may also be /etc/postfix/main.cf and /etc/mailname which require adaptation if postfix is configured.
The hostname may also be set in the gcos field of /etc/passwd to make mails from root show as root@hostname.
Thus, I think it is best to search for files containing the old hostname and adapt them manually if necessary to cover specific settings of a host.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .