Ubuntu 18.04 Chronicles: removing cloud-init

You just deployed yourself a fresh copy of Ubuntu Server 18.04 Bionic Beaver. It should be the latest and greatest, and you just need a virtual machine to do some web development or perhaps you just want to enable IP forwarding and use this machine as a router. That’s great, except the latest Ubuntu assumes that you are part of the current trend to put everything in the cloud, and so ships with something called cloud-init.

No harm normally, but this wastes valuable seconds doing something you don’t need if you’re not in the cloud. It’s easy to remove this package by following the (modified) instructions here: https://makandracards.com/operations/42688-how-to-remove-cloud-init-from-ubuntu :

  1. dpkg-reconfigure cloud-init
    1. Then deselect all the options except None
  2. sudo apt-get purge cloud-init
  3. sudo mv /etc/cloud/ ~/; sudo mv /var/lib/cloud/ ~/cloud-lib
    1. I prefer to move, rather than delete, in case something goes wrong and you wish to restore the files.

When you remove cloud-init following those steps, your machine stops booting and there is apparently a service that is waiting for network to be up. This would normally be just an inconvenience, but the boot hangs indefinitely waiting for said network. Odd choice of configuration out of the box, but anyway, you can fix this by:

  1. List the services which depend on network being online.
    • sudo systemctl show -p WantedBy network-online.target
  2. This will list the culprits as some iscsi services that you probably don’t need.
  3. Disable the services
    • systemctl disable <service name

That should do to get the system booting without some service waiting endlessly for a network connection.

14 thoughts to “Ubuntu 18.04 Chronicles: removing cloud-init”

  1. A word of warning: I tried this on the Ubuntu 16.04 minimal server image for the Raspberry Pi, and there’s something different about its setup that kept this method from working. I wound up with the “permanent hang on boot” problem. There’s probably some different “WantedBy” that needs fixing, but this is my first encounter with cloud-init, so I have no clue about how to find out what it is.

    One of the wonderful things about the Internet is folks like Fanen who share their experience in ways that have often helped me out of a jam, so I’m not disparaging this tip. I just wanted to let people know that it’s not universally applicable.

    1. Thanks for your comment. Perhaps you missed some of the output of WantedBy? What was the culprit in your case? I may be able to incorporate your feedback into the blog post.

      Mind you also, your comment says Ubuntu 16.04, but this Post is aimed specifically at Ubuntu 18.04.

  2. This was a great write-up of how to remove something that Ubuntu should have left as an optional install!
    I use a lot of small ubuntu servers for simple stuff at customers and have no need of the cloudy stuff for that.

    Thank you!

  3. Another word of warning. On my 18.04 install, attempting “apt remove open-iscsi” will also remove “ubuntu-server”. If it comes up with that, DON’T DO IT!! Just skip the last command as disabling the services is enough to speed up the boot process.

  4. Great help. Thank you very much.
    Why did they decide to just put this in by default. I thought Ubuntu was supposed to be light on resources.

  5. Arggghhhh….now I know why docker isn’t working after my new 18.04 install. Not everyone is cloud-enamoured…
    Thanks for posting this. A great help.

  6. If you dont want to delete it but simply disable the service, this command should do the trick.

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

    This tells cloud-init not to configure anything at start or any other point in time. 🙂

  7. Tried this but didn’t work. 18.04, removed cloud-init entirely then this hang at startup began. WantedBy only reports open-iscsi.service which I disabled to no avail.

Leave a Reply to rantalbottCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.