Host name reverts to old name after reboot in 18.04 LTS












13















This may be related to running 18.04 LTS as a virtual machine (Host is Win 2016 DC) but I can't figure it out how. I have tried every method of I know of to change the hostname but it always reverts to the hostname I entered when I built the machine on reboot. I have tried the following:




  1. hostnamectl set-hostname xxx.

  2. Editing hostname directly.

  3. Adding --static to hostnamectl.

  4. Editing hosts file and adding desired hostname.

  5. Searching drive for references to old hostname before reboot.

  6. A few other weird suggestions I found on the internet not worth mentioning.


I have no DNS for this server at this time.



Example:



XXXX@iwrxmail:~# hostnamectl
Static hostname: iwrxmail
Pretty hostname: Interwrx Ubuntu Mail Server
Transient hostname: ctl
Icon name: computer-vm
Chassis: vm
Machine ID: 01ef0d836d2c4945b51a4fab8e506381
Boot ID: e6608fe238d843f883cde52af7631a79
Virtualization: microsoft
Operating System: Ubuntu 18.04 LTS
Kernel: Linux 4.15.0-20-generic
Architecture: x86-64
XXXX@iwrxmail:~# hostnamectl set-hostname test
XXXX@iwrxmail:~# hostnamectl
Static hostname: test
Icon name: computer-vm
Chassis: vm
Machine ID: 01ef0d836d2c4945b51a4fab8e506381
Boot ID: e6608fe238d843f883cde52af7631a79
Virtualization: microsoft
Operating System: Ubuntu 18.04 LTS
Kernel: Linux 4.15.0-20-generic
Architecture: x86-64
root@iwrxmail:~# cat /etc/hostname
test
root@iwrxmail:~# cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

However on reboot I get this again ....

XXXX@iwrxmail:~# hostnamectl
Static hostname: iwrxmail
Icon name: computer-vm
Chassis: vm
Machine ID: 01ef0d836d2c4945b51a4fab8e506381
Boot ID: 25a00676b22048eb8d43492c9de4f147
Virtualization: microsoft
Operating System: Ubuntu 18.04 LTS
Kernel: Linux 4.15.0-20-generic
Architecture: x86-64


I had had this issue with the beta of 18.04, but I figured I would wait for the release copy. I also considered it might be a problem with the fact I had cloned the VMs, but this was a brand new version built from scratch with the just released distro.



What am I missing?



Thanks in advance.










share|improve this question





























    13















    This may be related to running 18.04 LTS as a virtual machine (Host is Win 2016 DC) but I can't figure it out how. I have tried every method of I know of to change the hostname but it always reverts to the hostname I entered when I built the machine on reboot. I have tried the following:




    1. hostnamectl set-hostname xxx.

    2. Editing hostname directly.

    3. Adding --static to hostnamectl.

    4. Editing hosts file and adding desired hostname.

    5. Searching drive for references to old hostname before reboot.

    6. A few other weird suggestions I found on the internet not worth mentioning.


    I have no DNS for this server at this time.



    Example:



    XXXX@iwrxmail:~# hostnamectl
    Static hostname: iwrxmail
    Pretty hostname: Interwrx Ubuntu Mail Server
    Transient hostname: ctl
    Icon name: computer-vm
    Chassis: vm
    Machine ID: 01ef0d836d2c4945b51a4fab8e506381
    Boot ID: e6608fe238d843f883cde52af7631a79
    Virtualization: microsoft
    Operating System: Ubuntu 18.04 LTS
    Kernel: Linux 4.15.0-20-generic
    Architecture: x86-64
    XXXX@iwrxmail:~# hostnamectl set-hostname test
    XXXX@iwrxmail:~# hostnamectl
    Static hostname: test
    Icon name: computer-vm
    Chassis: vm
    Machine ID: 01ef0d836d2c4945b51a4fab8e506381
    Boot ID: e6608fe238d843f883cde52af7631a79
    Virtualization: microsoft
    Operating System: Ubuntu 18.04 LTS
    Kernel: Linux 4.15.0-20-generic
    Architecture: x86-64
    root@iwrxmail:~# cat /etc/hostname
    test
    root@iwrxmail:~# cat /etc/hosts
    127.0.0.1 localhost.localdomain localhost
    ::1 localhost6.localdomain6 localhost6
    # The following lines are desirable for IPv6 capable hosts
    ::1 localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts

    However on reboot I get this again ....

    XXXX@iwrxmail:~# hostnamectl
    Static hostname: iwrxmail
    Icon name: computer-vm
    Chassis: vm
    Machine ID: 01ef0d836d2c4945b51a4fab8e506381
    Boot ID: 25a00676b22048eb8d43492c9de4f147
    Virtualization: microsoft
    Operating System: Ubuntu 18.04 LTS
    Kernel: Linux 4.15.0-20-generic
    Architecture: x86-64


    I had had this issue with the beta of 18.04, but I figured I would wait for the release copy. I also considered it might be a problem with the fact I had cloned the VMs, but this was a brand new version built from scratch with the just released distro.



    What am I missing?



    Thanks in advance.










    share|improve this question



























      13












      13








      13


      3






      This may be related to running 18.04 LTS as a virtual machine (Host is Win 2016 DC) but I can't figure it out how. I have tried every method of I know of to change the hostname but it always reverts to the hostname I entered when I built the machine on reboot. I have tried the following:




      1. hostnamectl set-hostname xxx.

      2. Editing hostname directly.

      3. Adding --static to hostnamectl.

      4. Editing hosts file and adding desired hostname.

      5. Searching drive for references to old hostname before reboot.

      6. A few other weird suggestions I found on the internet not worth mentioning.


      I have no DNS for this server at this time.



      Example:



      XXXX@iwrxmail:~# hostnamectl
      Static hostname: iwrxmail
      Pretty hostname: Interwrx Ubuntu Mail Server
      Transient hostname: ctl
      Icon name: computer-vm
      Chassis: vm
      Machine ID: 01ef0d836d2c4945b51a4fab8e506381
      Boot ID: e6608fe238d843f883cde52af7631a79
      Virtualization: microsoft
      Operating System: Ubuntu 18.04 LTS
      Kernel: Linux 4.15.0-20-generic
      Architecture: x86-64
      XXXX@iwrxmail:~# hostnamectl set-hostname test
      XXXX@iwrxmail:~# hostnamectl
      Static hostname: test
      Icon name: computer-vm
      Chassis: vm
      Machine ID: 01ef0d836d2c4945b51a4fab8e506381
      Boot ID: e6608fe238d843f883cde52af7631a79
      Virtualization: microsoft
      Operating System: Ubuntu 18.04 LTS
      Kernel: Linux 4.15.0-20-generic
      Architecture: x86-64
      root@iwrxmail:~# cat /etc/hostname
      test
      root@iwrxmail:~# cat /etc/hosts
      127.0.0.1 localhost.localdomain localhost
      ::1 localhost6.localdomain6 localhost6
      # The following lines are desirable for IPv6 capable hosts
      ::1 localhost ip6-localhost ip6-loopback
      fe00::0 ip6-localnet
      ff02::1 ip6-allnodes
      ff02::2 ip6-allrouters
      ff02::3 ip6-allhosts

      However on reboot I get this again ....

      XXXX@iwrxmail:~# hostnamectl
      Static hostname: iwrxmail
      Icon name: computer-vm
      Chassis: vm
      Machine ID: 01ef0d836d2c4945b51a4fab8e506381
      Boot ID: 25a00676b22048eb8d43492c9de4f147
      Virtualization: microsoft
      Operating System: Ubuntu 18.04 LTS
      Kernel: Linux 4.15.0-20-generic
      Architecture: x86-64


      I had had this issue with the beta of 18.04, but I figured I would wait for the release copy. I also considered it might be a problem with the fact I had cloned the VMs, but this was a brand new version built from scratch with the just released distro.



      What am I missing?



      Thanks in advance.










      share|improve this question
















      This may be related to running 18.04 LTS as a virtual machine (Host is Win 2016 DC) but I can't figure it out how. I have tried every method of I know of to change the hostname but it always reverts to the hostname I entered when I built the machine on reboot. I have tried the following:




      1. hostnamectl set-hostname xxx.

      2. Editing hostname directly.

      3. Adding --static to hostnamectl.

      4. Editing hosts file and adding desired hostname.

      5. Searching drive for references to old hostname before reboot.

      6. A few other weird suggestions I found on the internet not worth mentioning.


      I have no DNS for this server at this time.



      Example:



      XXXX@iwrxmail:~# hostnamectl
      Static hostname: iwrxmail
      Pretty hostname: Interwrx Ubuntu Mail Server
      Transient hostname: ctl
      Icon name: computer-vm
      Chassis: vm
      Machine ID: 01ef0d836d2c4945b51a4fab8e506381
      Boot ID: e6608fe238d843f883cde52af7631a79
      Virtualization: microsoft
      Operating System: Ubuntu 18.04 LTS
      Kernel: Linux 4.15.0-20-generic
      Architecture: x86-64
      XXXX@iwrxmail:~# hostnamectl set-hostname test
      XXXX@iwrxmail:~# hostnamectl
      Static hostname: test
      Icon name: computer-vm
      Chassis: vm
      Machine ID: 01ef0d836d2c4945b51a4fab8e506381
      Boot ID: e6608fe238d843f883cde52af7631a79
      Virtualization: microsoft
      Operating System: Ubuntu 18.04 LTS
      Kernel: Linux 4.15.0-20-generic
      Architecture: x86-64
      root@iwrxmail:~# cat /etc/hostname
      test
      root@iwrxmail:~# cat /etc/hosts
      127.0.0.1 localhost.localdomain localhost
      ::1 localhost6.localdomain6 localhost6
      # The following lines are desirable for IPv6 capable hosts
      ::1 localhost ip6-localhost ip6-loopback
      fe00::0 ip6-localnet
      ff02::1 ip6-allnodes
      ff02::2 ip6-allrouters
      ff02::3 ip6-allhosts

      However on reboot I get this again ....

      XXXX@iwrxmail:~# hostnamectl
      Static hostname: iwrxmail
      Icon name: computer-vm
      Chassis: vm
      Machine ID: 01ef0d836d2c4945b51a4fab8e506381
      Boot ID: 25a00676b22048eb8d43492c9de4f147
      Virtualization: microsoft
      Operating System: Ubuntu 18.04 LTS
      Kernel: Linux 4.15.0-20-generic
      Architecture: x86-64


      I had had this issue with the beta of 18.04, but I figured I would wait for the release copy. I also considered it might be a problem with the fact I had cloned the VMs, but this was a brand new version built from scratch with the just released distro.



      What am I missing?



      Thanks in advance.







      18.04






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 19 '18 at 4:01









      Codito ergo sum

      1,5033825




      1,5033825










      asked Apr 27 '18 at 6:00









      Andy WyldeAndy Wylde

      66114




      66114






















          5 Answers
          5






          active

          oldest

          votes


















          16














          First edit /etc/cloud/cloud.cfg and set the parameter "preserve_hostname" from "false" to "true" and then edit /etc/hostname.






          share|improve this answer



















          • 2





            Works like a charm. I would have never gotten that from the comment line above it: " # This will cause the set+update hostname module to not operate (if true) ". Thanks so much, so many incorrect methods out on the web.

            – Andy Wylde
            Apr 27 '18 at 14:39





















          6














          The hostname is being reset by cloud-init which can be disabled as follows (after which you can set the hostname in the normal way e.g. using hostnamectl):



          sudo touch /etc/cloud/cloud-init.disabled


          Or you can create/modify user-data file (/var/lib/cloud/seed/nocloud-net/user-data) so that the hostname is correct. Firstly you'll need to clean the existing config:



          sudo cloud-init clean


          And then reinitialise cloud-init's config from the new/modified user-data file:



          sudo cloud-init init


          Then reboot. See the cloud-init docs for more details.






          share|improve this answer


























          • Be carful with running cloud-init clean or cloud-init init it can rewrite your /etc/netplan/ yaml files.

            – Michael D.
            Sep 11 '18 at 13:37



















          3














          For the "lazy guys" like me, a copy-paste solution :)



          sudo sed -i '/preserve_hostname: false/cpreserve_hostname: true' /etc/cloud/cloud.cfg && sudo hostnamectl set-hostname ReplaceThisWithTheHostnamePreferred


          First command allows the new hostname to be remembered by the OS.



          The second part (after the &&) will only run if the first part has finished successfully and will set the hostname to the desired value.



          Regards! L






          share|improve this answer

































            0














            I had the same issue and found that, after removing the cloud packages, you can change your hostname.



            apt remove cloud-init cloud-initramfs-copymods cloud-initramfs-dyn-netconf





            share|improve this answer





















            • 1





              I'm sure this will work but I think I prefer the answer above. Thanks for responding though

              – Andy Wylde
              Apr 27 '18 at 14:43











            • I suggest to refrain from this solution if you are using ubuntu-server package. Why? Because the above mentioned packages are prerequisites of it. Description of the ubuntu-server package 'Description-en: The Ubuntu Server system This package depends on all of the packages in the Ubuntu Server system . It is also used to help ensure proper upgrades, so it is recommended that it not be removed.'

              – linux64kb
              May 30 '18 at 17:29



















            0














            1- Edit vi /etc/cloud/cloud.cfg and change



            preserve_hostname: false


            To



            preserve_hostname: true


            Save and exit.



            2- Edit vi /etc/hostname and replace your new name in this file or you can do this step with bellow command.



            hostnamectl set-hostname NEWNAME


            Enjoy it :)






            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "89"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1028633%2fhost-name-reverts-to-old-name-after-reboot-in-18-04-lts%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              5 Answers
              5






              active

              oldest

              votes








              5 Answers
              5






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              16














              First edit /etc/cloud/cloud.cfg and set the parameter "preserve_hostname" from "false" to "true" and then edit /etc/hostname.






              share|improve this answer



















              • 2





                Works like a charm. I would have never gotten that from the comment line above it: " # This will cause the set+update hostname module to not operate (if true) ". Thanks so much, so many incorrect methods out on the web.

                – Andy Wylde
                Apr 27 '18 at 14:39


















              16














              First edit /etc/cloud/cloud.cfg and set the parameter "preserve_hostname" from "false" to "true" and then edit /etc/hostname.






              share|improve this answer



















              • 2





                Works like a charm. I would have never gotten that from the comment line above it: " # This will cause the set+update hostname module to not operate (if true) ". Thanks so much, so many incorrect methods out on the web.

                – Andy Wylde
                Apr 27 '18 at 14:39
















              16












              16








              16







              First edit /etc/cloud/cloud.cfg and set the parameter "preserve_hostname" from "false" to "true" and then edit /etc/hostname.






              share|improve this answer













              First edit /etc/cloud/cloud.cfg and set the parameter "preserve_hostname" from "false" to "true" and then edit /etc/hostname.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Apr 27 '18 at 11:53









              Karsten HoffmannKarsten Hoffmann

              1612




              1612








              • 2





                Works like a charm. I would have never gotten that from the comment line above it: " # This will cause the set+update hostname module to not operate (if true) ". Thanks so much, so many incorrect methods out on the web.

                – Andy Wylde
                Apr 27 '18 at 14:39
















              • 2





                Works like a charm. I would have never gotten that from the comment line above it: " # This will cause the set+update hostname module to not operate (if true) ". Thanks so much, so many incorrect methods out on the web.

                – Andy Wylde
                Apr 27 '18 at 14:39










              2




              2





              Works like a charm. I would have never gotten that from the comment line above it: " # This will cause the set+update hostname module to not operate (if true) ". Thanks so much, so many incorrect methods out on the web.

              – Andy Wylde
              Apr 27 '18 at 14:39







              Works like a charm. I would have never gotten that from the comment line above it: " # This will cause the set+update hostname module to not operate (if true) ". Thanks so much, so many incorrect methods out on the web.

              – Andy Wylde
              Apr 27 '18 at 14:39















              6














              The hostname is being reset by cloud-init which can be disabled as follows (after which you can set the hostname in the normal way e.g. using hostnamectl):



              sudo touch /etc/cloud/cloud-init.disabled


              Or you can create/modify user-data file (/var/lib/cloud/seed/nocloud-net/user-data) so that the hostname is correct. Firstly you'll need to clean the existing config:



              sudo cloud-init clean


              And then reinitialise cloud-init's config from the new/modified user-data file:



              sudo cloud-init init


              Then reboot. See the cloud-init docs for more details.






              share|improve this answer


























              • Be carful with running cloud-init clean or cloud-init init it can rewrite your /etc/netplan/ yaml files.

                – Michael D.
                Sep 11 '18 at 13:37
















              6














              The hostname is being reset by cloud-init which can be disabled as follows (after which you can set the hostname in the normal way e.g. using hostnamectl):



              sudo touch /etc/cloud/cloud-init.disabled


              Or you can create/modify user-data file (/var/lib/cloud/seed/nocloud-net/user-data) so that the hostname is correct. Firstly you'll need to clean the existing config:



              sudo cloud-init clean


              And then reinitialise cloud-init's config from the new/modified user-data file:



              sudo cloud-init init


              Then reboot. See the cloud-init docs for more details.






              share|improve this answer


























              • Be carful with running cloud-init clean or cloud-init init it can rewrite your /etc/netplan/ yaml files.

                – Michael D.
                Sep 11 '18 at 13:37














              6












              6








              6







              The hostname is being reset by cloud-init which can be disabled as follows (after which you can set the hostname in the normal way e.g. using hostnamectl):



              sudo touch /etc/cloud/cloud-init.disabled


              Or you can create/modify user-data file (/var/lib/cloud/seed/nocloud-net/user-data) so that the hostname is correct. Firstly you'll need to clean the existing config:



              sudo cloud-init clean


              And then reinitialise cloud-init's config from the new/modified user-data file:



              sudo cloud-init init


              Then reboot. See the cloud-init docs for more details.






              share|improve this answer















              The hostname is being reset by cloud-init which can be disabled as follows (after which you can set the hostname in the normal way e.g. using hostnamectl):



              sudo touch /etc/cloud/cloud-init.disabled


              Or you can create/modify user-data file (/var/lib/cloud/seed/nocloud-net/user-data) so that the hostname is correct. Firstly you'll need to clean the existing config:



              sudo cloud-init clean


              And then reinitialise cloud-init's config from the new/modified user-data file:



              sudo cloud-init init


              Then reboot. See the cloud-init docs for more details.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jul 3 '18 at 15:47

























              answered Jun 18 '18 at 16:31









              PierzPierz

              91197




              91197













              • Be carful with running cloud-init clean or cloud-init init it can rewrite your /etc/netplan/ yaml files.

                – Michael D.
                Sep 11 '18 at 13:37



















              • Be carful with running cloud-init clean or cloud-init init it can rewrite your /etc/netplan/ yaml files.

                – Michael D.
                Sep 11 '18 at 13:37

















              Be carful with running cloud-init clean or cloud-init init it can rewrite your /etc/netplan/ yaml files.

              – Michael D.
              Sep 11 '18 at 13:37





              Be carful with running cloud-init clean or cloud-init init it can rewrite your /etc/netplan/ yaml files.

              – Michael D.
              Sep 11 '18 at 13:37











              3














              For the "lazy guys" like me, a copy-paste solution :)



              sudo sed -i '/preserve_hostname: false/cpreserve_hostname: true' /etc/cloud/cloud.cfg && sudo hostnamectl set-hostname ReplaceThisWithTheHostnamePreferred


              First command allows the new hostname to be remembered by the OS.



              The second part (after the &&) will only run if the first part has finished successfully and will set the hostname to the desired value.



              Regards! L






              share|improve this answer






























                3














                For the "lazy guys" like me, a copy-paste solution :)



                sudo sed -i '/preserve_hostname: false/cpreserve_hostname: true' /etc/cloud/cloud.cfg && sudo hostnamectl set-hostname ReplaceThisWithTheHostnamePreferred


                First command allows the new hostname to be remembered by the OS.



                The second part (after the &&) will only run if the first part has finished successfully and will set the hostname to the desired value.



                Regards! L






                share|improve this answer




























                  3












                  3








                  3







                  For the "lazy guys" like me, a copy-paste solution :)



                  sudo sed -i '/preserve_hostname: false/cpreserve_hostname: true' /etc/cloud/cloud.cfg && sudo hostnamectl set-hostname ReplaceThisWithTheHostnamePreferred


                  First command allows the new hostname to be remembered by the OS.



                  The second part (after the &&) will only run if the first part has finished successfully and will set the hostname to the desired value.



                  Regards! L






                  share|improve this answer















                  For the "lazy guys" like me, a copy-paste solution :)



                  sudo sed -i '/preserve_hostname: false/cpreserve_hostname: true' /etc/cloud/cloud.cfg && sudo hostnamectl set-hostname ReplaceThisWithTheHostnamePreferred


                  First command allows the new hostname to be remembered by the OS.



                  The second part (after the &&) will only run if the first part has finished successfully and will set the hostname to the desired value.



                  Regards! L







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jun 30 '18 at 14:37

























                  answered May 30 '18 at 19:02









                  linux64kblinux64kb

                  630513




                  630513























                      0














                      I had the same issue and found that, after removing the cloud packages, you can change your hostname.



                      apt remove cloud-init cloud-initramfs-copymods cloud-initramfs-dyn-netconf





                      share|improve this answer





















                      • 1





                        I'm sure this will work but I think I prefer the answer above. Thanks for responding though

                        – Andy Wylde
                        Apr 27 '18 at 14:43











                      • I suggest to refrain from this solution if you are using ubuntu-server package. Why? Because the above mentioned packages are prerequisites of it. Description of the ubuntu-server package 'Description-en: The Ubuntu Server system This package depends on all of the packages in the Ubuntu Server system . It is also used to help ensure proper upgrades, so it is recommended that it not be removed.'

                        – linux64kb
                        May 30 '18 at 17:29
















                      0














                      I had the same issue and found that, after removing the cloud packages, you can change your hostname.



                      apt remove cloud-init cloud-initramfs-copymods cloud-initramfs-dyn-netconf





                      share|improve this answer





















                      • 1





                        I'm sure this will work but I think I prefer the answer above. Thanks for responding though

                        – Andy Wylde
                        Apr 27 '18 at 14:43











                      • I suggest to refrain from this solution if you are using ubuntu-server package. Why? Because the above mentioned packages are prerequisites of it. Description of the ubuntu-server package 'Description-en: The Ubuntu Server system This package depends on all of the packages in the Ubuntu Server system . It is also used to help ensure proper upgrades, so it is recommended that it not be removed.'

                        – linux64kb
                        May 30 '18 at 17:29














                      0












                      0








                      0







                      I had the same issue and found that, after removing the cloud packages, you can change your hostname.



                      apt remove cloud-init cloud-initramfs-copymods cloud-initramfs-dyn-netconf





                      share|improve this answer















                      I had the same issue and found that, after removing the cloud packages, you can change your hostname.



                      apt remove cloud-init cloud-initramfs-copymods cloud-initramfs-dyn-netconf






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Apr 27 '18 at 14:39









                      Eliah Kagan

                      82.9k22228369




                      82.9k22228369










                      answered Apr 27 '18 at 10:45









                      MaddinMaddin

                      91




                      91








                      • 1





                        I'm sure this will work but I think I prefer the answer above. Thanks for responding though

                        – Andy Wylde
                        Apr 27 '18 at 14:43











                      • I suggest to refrain from this solution if you are using ubuntu-server package. Why? Because the above mentioned packages are prerequisites of it. Description of the ubuntu-server package 'Description-en: The Ubuntu Server system This package depends on all of the packages in the Ubuntu Server system . It is also used to help ensure proper upgrades, so it is recommended that it not be removed.'

                        – linux64kb
                        May 30 '18 at 17:29














                      • 1





                        I'm sure this will work but I think I prefer the answer above. Thanks for responding though

                        – Andy Wylde
                        Apr 27 '18 at 14:43











                      • I suggest to refrain from this solution if you are using ubuntu-server package. Why? Because the above mentioned packages are prerequisites of it. Description of the ubuntu-server package 'Description-en: The Ubuntu Server system This package depends on all of the packages in the Ubuntu Server system . It is also used to help ensure proper upgrades, so it is recommended that it not be removed.'

                        – linux64kb
                        May 30 '18 at 17:29








                      1




                      1





                      I'm sure this will work but I think I prefer the answer above. Thanks for responding though

                      – Andy Wylde
                      Apr 27 '18 at 14:43





                      I'm sure this will work but I think I prefer the answer above. Thanks for responding though

                      – Andy Wylde
                      Apr 27 '18 at 14:43













                      I suggest to refrain from this solution if you are using ubuntu-server package. Why? Because the above mentioned packages are prerequisites of it. Description of the ubuntu-server package 'Description-en: The Ubuntu Server system This package depends on all of the packages in the Ubuntu Server system . It is also used to help ensure proper upgrades, so it is recommended that it not be removed.'

                      – linux64kb
                      May 30 '18 at 17:29





                      I suggest to refrain from this solution if you are using ubuntu-server package. Why? Because the above mentioned packages are prerequisites of it. Description of the ubuntu-server package 'Description-en: The Ubuntu Server system This package depends on all of the packages in the Ubuntu Server system . It is also used to help ensure proper upgrades, so it is recommended that it not be removed.'

                      – linux64kb
                      May 30 '18 at 17:29











                      0














                      1- Edit vi /etc/cloud/cloud.cfg and change



                      preserve_hostname: false


                      To



                      preserve_hostname: true


                      Save and exit.



                      2- Edit vi /etc/hostname and replace your new name in this file or you can do this step with bellow command.



                      hostnamectl set-hostname NEWNAME


                      Enjoy it :)






                      share|improve this answer




























                        0














                        1- Edit vi /etc/cloud/cloud.cfg and change



                        preserve_hostname: false


                        To



                        preserve_hostname: true


                        Save and exit.



                        2- Edit vi /etc/hostname and replace your new name in this file or you can do this step with bellow command.



                        hostnamectl set-hostname NEWNAME


                        Enjoy it :)






                        share|improve this answer


























                          0












                          0








                          0







                          1- Edit vi /etc/cloud/cloud.cfg and change



                          preserve_hostname: false


                          To



                          preserve_hostname: true


                          Save and exit.



                          2- Edit vi /etc/hostname and replace your new name in this file or you can do this step with bellow command.



                          hostnamectl set-hostname NEWNAME


                          Enjoy it :)






                          share|improve this answer













                          1- Edit vi /etc/cloud/cloud.cfg and change



                          preserve_hostname: false


                          To



                          preserve_hostname: true


                          Save and exit.



                          2- Edit vi /etc/hostname and replace your new name in this file or you can do this step with bellow command.



                          hostnamectl set-hostname NEWNAME


                          Enjoy it :)







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 14 at 15:35









                          Milad NorouziMilad Norouzi

                          11




                          11






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Ask Ubuntu!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1028633%2fhost-name-reverts-to-old-name-after-reboot-in-18-04-lts%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              How did Captain America manage to do this?

                              迪纳利

                              南乌拉尔铁路局