Updated on 2025-08-01 GMT+08:00

Creating a Lite Server OS

Scenario

If the current Lite Server OS does not meet your requirements, you can use BMS or ECS to create an image and save the current OS as a new image for other Lite Servers.

Constraints

Before creating an image, ensure that the Lite Server is stopped.

The created image can only be created based on the current OS of the Lite Server.

Procedure

  1. Delete temporary files before creating an OS image to prevent potential issues with running the image. To do so, log in to the server. Run the commands below separately or create a script to run the commands all at once. For details about the clearance script, see Script for Deleting Temporary Files.
    1. Clear user login records:
      echo > /var/log/wtmp
      echo > /var/log/btmp
    2. Delete temporary files:
      rm -rf /var/log/cloud-init*
      rm -rf /var/lib/cloud/*
      rm -rf /var/log/network-config.log
      rm -rf /opt/huawei/network_config/network_config.json
      rm -rf /opt/huawei/port_config/uplink_hash_config.log
      rm -rf /opt/huawei/firmware_check/firmware_check.log
    3. Delete residual configurations.
      • CentOS/EulerOS/HCE OS: Check the files whose names start with ifcfg in the /etc/sysconfig/network-scripts/ folder and delete them except ifcfg-lo.

        Check files:

        ll /etc/sysconfig/network-scripts/

        Delete files:

        rm -rf /etc/sysconfig/network-scripts/ifcfgxxx
      • Ubuntu:
        rm -rf /etc/network/interfaces.d/50-cloud-init.cfg
    4. Clear the network information of the parameter plane:
      echo >/etc/netplan/roce.yaml
      echo > /etc/hccn.conf
    5. Clear operation records:
      history -w;echo > /root/.bash_history;history -c;history -c;history -c;
  2. Shut down the Lite Server.

    Log in to the ModelArts console and stop the target server.

    Figure 1 Stopping the Lite Server

  3. On the Lite Server details page, click the BMS address or ECS address to access its details page.
    Figure 2 Lite Server details page

  4. On the BMS or ECS console, return to the server list page, and choose Manage Image > Create Image in the Operation column.
    Figure 3 Creating an image on an ECS

    On the image creation page, enter the image name and enterprise project, select the agreement, and confirm the creation. The created image is saved in the private image list of the IMS service. For details, see Creating an Image and Creating a Private Image from a BMS.

    The created image can be used for other Lite Servers. For details, see Changing or Resetting the Lite Server OS.

Script for Deleting Temporary Files

#!/bin/bash

# Clear user login records:
echo > /var/log/wtmp
echo > /var/log/btmp

# Delete temporary files:
rm -rf /var/log/cloud-init*
rm -rf /var/lib/cloud/*
rm -rf /var/log/network-config.log
rm -rf /opt/huawei/network_config/network_config.json
rm -rf /opt/huawei/port_config/uplink_hash_config.log
rm -rf /opt/huawei/firmware_check/firmware_check.log

# Delete residual configurations:
## CentOS/EulerOS/HCE OS:
## Check the files whose names start with ifcfg in the /etc/sysconfig/network-scripts/ folder and delete them except ifcfg-lo.
find /etc/sysconfig/network-scripts/ -name 'ifcfg*' ! -name 'ifcfg-lo' -type f | xargs rm -f
## Ubuntu:
rm -rf /etc/network/interfaces.d/50-cloud-init.cfg

# Clear the network information of the parameter plane:
echo > /etc/netplan/roce.yaml
echo > /etc/hccn.conf

# Clear operation records:
history -w;echo > /root/.bash_history;history -c;history -c;history -c;
echo > ~/.bash_history
exec bash