Installing cloud-init on Linux System

Last Updated At: 2025-11-26 15:01:22

Scenarios

Cloud-init primarily allows you to customize configurations during the first initialization of an instance. If an imported image is not installed with the cloud-init service, the instance that is enabled based on this image cannot be initialized normally, causing a failure in the normal import of this image. This document describes how to install the cloud-init service. The following three methods are recommended for installing cloud-init:
By downloading the cloud-init binary package.
By manually downloading the cloud-init source package.
By using the cloud-init package from the software source.

Related Operations

Note:

After the following operations are complete, do not restart the server. Otherwise, you will need to re-perform the following operations.

  1. Execute the following command to check whether the cloud-init configuration is successful.
cloud-init init --local

If information similar to the following is returned, it means that cloud-init has been successfully configured.

Cloud-init v. 20.1.0011 running 'init-local' at Fri, 01 Apr 2022 01:26:11 +0000. Up 38.70 seconds.
  1. Execute the following command to delete the cache records of cloud-init.
rm -rf /var/lib/cloud
  1. For Ubuntu or Debian operating systems, execute the following command.
rm -rf /etc/network/interfaces.d/50-cloud-init.cfg
  1. For the Ubuntu or Debian operating system, you need to modify /etc/network/interfaces to the following content:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*