I have a fully-configured instance and an image from that for an autoscaling group. When autoscaling new instances from this image, it calls cloud-init. cloud-init changes the hostname and breaks fstab.

I want to prevent cloud-init from starting on instance launch.

2 Answers 2


In systems that use systemd and have a current (17.0+) version of cloud-init, upstream documentation describes the process for disabling cloud-init with either of the following:

  • touch /etc/cloud/cloud-init.disabled
  • add cloud-init=disabled to the kernel command line.

For older versions of cloud-init (0.7.X) the following information might be useful.

You can disable cloud-init's modification of /etc/fstab in one of 2 ways.

a.) by providing cloud-config that overrides the default 'mounts' entries and disables them.

 - [ephemeral0, null]
 - [swap, null]

b.) by disabling the mounts module from running. This is done by removing it from the 'cloud_config_modules' list that you'll see in /etc/cloud/cloud.cfg.

With regard to hostname, you can also control that also. If you just want to stop cloud-init from modifying /etc/hostname, then:

preserve_hostname: true

Also interesting to you might be manage_etc_hosts.

Both of these are documented in doc/examples/cloud-config.txt (and installed in /usr/share/doc/cloud-init/examples)

I'm interested in knowing how cloud-init is breaking /etc/fstab, though. Please file a bug using ubuntu-bug cloud-init from inside your instance, and describe what it is doing that you think is wrong.

  • I do not think this is actually a bug. cloud-init adds swap and ephemeral to /etc/fstab already there. As a result ephemeral mounts to 2 points: /cache and /mnt. Is it safe?
    – homm
    Commented Jan 15, 2014 at 5:59
  • @homm depends on what you mean by "safe." I don't see anything /dangerous/ about it.
    – xofer
    Commented Jun 18, 2015 at 20:17
  • @smoser By default, it's mounting just a single volume. I'm provisioning with Chef and don't want to automate umount, so for me cloud-init is "breaking" fstab.
    – xofer
    Commented Jun 18, 2015 at 20:20
  • 1
    Note that you need to run sudo dpkg-reconfigure cloud-init after making changes.
    – xofer
    Commented Jun 18, 2015 at 20:20
  • Weird behaviour. With Ubuntu 18.04.2, it looks like the file /etc/cloud/cloud-init.disabled doesn't matter and only the dpkg-reconfigure cloud-init with data source None (Failsafe datasource) is needed. This contradicts the documentation of cloud-init. Commented Mar 13, 2019 at 8:17

On Ubuntu 20.04, these steps worked for me to disable and remove cloud-init:

Run this command to disable:

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

Reboot machine.

Run these commands to remove:

sudo apt-get purge cloud-init
sudo rm -rf /etc/cloud/; sudo rm -rf /var/lib/cloud/
  • touching the /etc/cloud/cloud-init.disabled file alone worked for me in Ubuntu 16.04.7
    – bnoeafk
    Commented Dec 18, 2020 at 7:39
  • 2
    Yes that will disable it, but not remove. The following commands also remove it. Commented Dec 18, 2020 at 8:09

You must log in to answer this question.

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