Elastic Cloud Server

Cloud-init

2026-03-23 10:22:20

Cloud-init

Cloud-init or Cloudbase-init tools are tools within cloud platforms for Linux/Windows images to initialize newly launched VMs. They include functionalities such as initializing the Host Name, network configuration, and initial passwords. Linux system public images come with Cloud-init pre-installed; Windows system public images come with Cloudbase-init pre-installed.

For more information about Cloud-init, please refer to the Cloud-init official documentation.

What Can Cloud-init Do

Cloud-init is a tool for initializing cloud servers, equipped with a variety of modules that provide the following capabilities for cloud servers: initializing passwords, expanding the root partition, setting the Host Name, injecting public keys, executing custom scripts, and more, making it very powerful.

Install Cloud-init

Step One: Check if the Cloud-init tool is already installed

Different operating systems have different commands. Taking CentOS as an example, execute the following command to check if Cloud-init is already installed:

rpm -qa | grep cloud-init

Step Two: Install Cloud-init

Without a specific version requirement, it is recommended to install the version available in the system's repository:

Install using the following command:

yum install cloud-init cloud-utils-growpart -y

Step Three: Configure Cloud-init Step 3

  1. The default cloud.cfg configuration file at /etc/cloud/cloud.cfg should be modified as follows:

    1.1 Determine the parameter values as follows: true/True/1, false/False/0 are all acceptable.


    1.2 The module includes the following content (recommended for reference and modification):

    1.3 Modify the system_info section.
    Do not modify the distro content.
    default_user: Change the default username to root, and set lock_passwd to False.
    The remaining parts involve changes to the system's yum/apt sources. It is recommended to follow the Other System Configuration Modifications, keep the system defaults, and remove the Cloud-init configurations.
    Do not modify the other contents of system_info.

    1.4 Add the datasource_list and datasource sections, and disable network hosting.


XmimnRillQ4N