ubuntu18.04でhostnameを変更する
前提条件
- 使ったisoはubuntu-18.04-live-server-amd64.iso
- http://ftp.riken.go.jp/Linux/ubuntu-releases/18.04/
手順
-
/etc/cloud/cloud.cfg
のpreserve_hostname
をtrueにするpreserve_hostname: true
-
hostnamectl
からhostnameを変更hostnamectl set-hostname yourhostname
- rebootして設定が反映されているか確認
どうして
- (私の環境だけかもしれないが)Ubuntu18.04だとcloud.cfgの変更をしないとhostnameの変更ができなかった
- 一応基盤の差じゃないかと思ったのでOpenstackとESXi双方で検証した
- Ubuntu16.04でもデフォルトでは
preserve_hostname: false
になっているものの、ここをtrueに変えずともhostnameの変更がreboot後も維持できる。