Automatically Changing Xen ECSs to KVM ECSs in a Batch (Linux)
Scenarios
Before changing Xen ECSs that run Linux to KVM ECSs, make sure that the required drivers have been installed and configured on the ECSs.
If a large number of Xen ECSs running Linux need to be changed to KVM ECSs, follow the instructions provided in this section to automatically install desired drivers and configure automatic disk attachment for these ECSs in a batch using a script. After installing the drivers, use the Modify Specifications function available on the management console to change the Xen ECSs to KVM ECSs.

- Xen ECS flavors: S1, C1, C2, and M1.
- KVM ECS flavors: See the Virtualization column in ECS Specifications.
- To support both Xen and KVM, Linux ECSs require the xen-pv and virtio drivers. Before changing a Xen ECS to a KVM ECS, make sure that the Linux ECS has been configured, including driver installation and automatic disk attachment.
Constraints
- Batch driver installation only applies to Linux ECSs.
- The ECS needs to be stopped during the specification modification, so you are advised to perform this operation during off-peak hours.
- The executor ECS must run CentOS 7, have an EIP bound, and be able to communicate with the ECSs where drivers are to be batch installed.
If the internal yum repository has been configured, the executor ECS does not require an EIP.
- You have obtained the IP addresses of the ECSs where drivers are to be batch installed, and the password of user root or the private key file for login.
- Only ECSs that use the same key pair support batch driver installation and configuration.
Procedure
Step |
Description |
---|---|
1 |
|
2 |
|
3 |
|
4 |
Step 1: Back Up an ECS
If you modify the specifications of an ECS without installing the driver, the ECS may become unavailable and the data on the system disk may be lost. You are advised to back up the ECS first to prevent data loss.
- Check the ECS.
Before backing up the ECS, stop and then start the ECS to ensure that services can run properly after the ECS is started.
- Back up the ECS.
Backing up ECSs generate storage costs. There are two types of EVS snapshots: standard snapshots and legacy snapshots. Legacy snapshots are in OBT and free of charge. Standard snapshots are billed. Select the one type as required.
- Method 1: Create a backup for the ECS.
For details, see ECS Backup Procedure.
- Method 2: Create a system disk snapshot and a data disk snapshot.
For details about how to create a snapshot, see Creating an EVS Snapshot in Elastic Volume Service User Guide.
- Method 1: Create a backup for the ECS.

Backups and snapshots created for the ECS are used to restore data. If the specifications fail to be modified, you can use the backups or snapshots to restore data.
- To use backups to restore data, see Restoring from a Cloud Server Backup.
- To use snapshots to roll back data, see Rolling Back Disk Data from a Snapshot.
After the specifications are modified, if services are running properly, delete the ECS backups or snapshots from the corresponding service console.
Step 2: Batch Install and Configure Drivers
Perform the operations described in this section if your ECSs support the batch configuration using a script.
If the ECSs cannot be automatically configured using a script, follow the instructions provided in Manually Changing a Xen ECS to a KVM ECS (Linux).
- Log in to the executor ECS. The ECS must meet requirements in Constraints.
- Run the following command to install the dependency required to run a batch script:
- Run the following command to download the driver installation script to the root directory:
curl URL > ~/resize_ecs_modify_linux.sh
URL is the address for downloading the driver installation script.
Select an address for downloading the script based on the region where the ECS is located:
- CN East-Shanghai 2: https://cn-east-2-server-resize.obs.cn-east-2.myhuaweicloud.com/linux/server_resize/resize_ecs_modify_linux.sh
- CN North-Beijing 1: https://cn-north-1-server-resize.obs.cn-north-1.myhuaweicloud.com/linux/server_resize/resize_ecs_modify_linux.sh
- CN South-Guangzhou: https://cn-south-1-server-resize.obs.cn-south-1.myhuaweicloud.com/linux/server_resize/resize_ecs_modify_linux.sh
- Run the following command to download the batch execution script to the root directory:
curl URL > ~/batch_resize_ecs_modify_linux.py
URL is the address for downloading the batch execution script.
Select an address for downloading the script based on the region where the ECS is located:
- CN East-Shanghai 2: https://cn-east-2-server-resize.obs.cn-east-2.myhuaweicloud.com/linux/server_resize/batch_resize_ecs_modify_linux.py
- CN North-Beijing 1: https://cn-north-1-server-resize.obs.cn-north-1.myhuaweicloud.com/linux/server_resize/batch_resize_ecs_modify_linux.py
- CN South-Guangzhou: https://cn-south-1-server-resize.obs.cn-south-1.myhuaweicloud.com/linux/server_resize/batch_resize_ecs_modify_linux.py
- Create host_list.txt and press i to enter editing mode.
vi host_list.txt
Place the driver installation script, batch execution script, and host_list.txt file in the same directory.
- Enter the information of the target ECSs in the host_list.txt file.
The information entered must match that of the target ECSs.
- If the target ECSs use a key pair for authentication, enter the following information:
Enter an ECS IP address in each line.
An example is provided as follows:
192.168.1.10 192.168.1.11
- If the target ECSs use a password for authentication, enter the following information:
Enter an ECS IP address and password of user root separated using a comma (,) in each line.
An example is provided as follows:
192.168.1.10,'**********' 192.168.1.11,'**********'
Press Esc to exit Insert mode and enter :wq to save the settings and exit.
- If the target ECSs use a key pair for authentication, enter the following information:
- Run the batch execution script batch_resize_ecs_modify_linux.py to automatically check the configured ECSs and install the native xen-pv and virtio drivers on them in a batch.
- Install drivers on the configured ECSs.
- ECSs using key pair authentication
Since the private key file and the batch execution script are in the same directory, you only need to specify the private key file name.
python batch_resize_ecs_modify_linux.py {Name of the private key file or path in which the private key file is stored}Figure 2 Executing the script - ECSs using password authentication
python batch_resize_ecs_modify_linux.py
Figure 3 Executing the script
- ECSs using key pair authentication
- Install drivers on the configured ECSs.
- Check execution results.
Wait until the script is executed. After checking that the drivers have been installed, the system automatically tags the ECSs. The specifications of only the tagged ECSs can be modified.
If the installation failed, manually configure the ECSs by following the instructions provided in Manually Changing a Xen ECS to a KVM ECS (Linux) or contact customer service.Table 2 Execution results Command output
Description
Total: {Quantity} Success: {Quantity} Failed: 0
All ECSs have been checked, and the drivers have been installed on them.
Total: {Quantity} Success: {Quantity} Failed: {Quantity}
The value of Failed is not 0, indicating that the driver check or installation failed on certain ECSs. In this case, view logs/exec_origin.log and identify the failure cause.
Please check the format of host_list.txt
The host_list.txt file does not meet the requirements. Follow the instructions provided in 6 to modify the file.
[Error] resize_ecs_modify_linux.sh not found.
The driver installation script described in 6 has not been downloaded. Download the script.
Host(s) is unreachable, please check the network or password of user root.
The target ECSs are unreachable from the executor. Check whether the network is connected or whether the password of user root configured in the host_list.txt file is correct.
[Error] host_list.txt not found.
The host_list.txt file is unavailable. Follow the instructions provided in 6 to create the file.
[Error] key-file {Private key file} not found.
The specified private key file is unavailable. Ensure that the private key file is available and perform 6 again.
Alternatively, use the password to log in to the target ECS and perform 6 again.
Please confirm that the ansible has been installed.
The dependency required in 2 has not been installed. Install the dependency.

- After the driver is installed, safely store the login password configured in the host_list.txt file and the private key file.
- Make sure that the ECSs have been configured successfully. Otherwise, the ECSs will be unavailable after the modification is performed. If the operation failed, follow the instructions provided in Manually Changing a Xen ECS to a KVM ECS (Linux).
- FAQs related to a script installation failure:
Step 3: Modify Specifications
- Using the management console
- Log in to the management console.
- Click
in the upper left corner and select your region and project.
- Click
. Under Compute, click Elastic Cloud Server.
- On the Elastic Cloud Server page, view the status of the target ECS.
If the ECS is not in Stopped state, choose More > Stop in the Operation column.
- Choose More > Modify Specifications in the Operation column.
The Modify ECS Specifications page is displayed.
- Select the new ECS type, vCPUs, and memory.
- (Optional) Set DeH.
If the ECS is created on a DeH, the system allows you to change the DeH.
To do so, select the target DeH from the drop-down list. If no DeH is available in the drop-down list, it indicates that remaining DeH resources are insufficient and cannot be used to create the ECS with new specifications.
- Select the check box to confirm that Step 2: Batch Install and Configure Drivers has been performed.
- Click Next.
- Confirm the new specifications, read and agree to the disclaimer, and then click Submit Application.
- The cloud platform automatically creates a system disk snapshot for you. After the specifications are modified, manually delete the snapshot on the snapshot page if you have verified that services are running properly.
- If ECS specifications failed to be modified and the ECS becomes unavailable, reinstall the OS. This operation will clear the data on the system disk while the data on data disks is retained.
(Optional) Step 4: Check Disk Attachment
After a Xen ECS is changed to a KVM ECS, disk attachment may fail. Therefore, check disk attachment after specifications modification. If disks are properly attached, the specifications modification is successful.
- Linux ECS
For details, see Why Does the Disk Attachment of a Linux ECS Fail After I Modify the ECS Specifications?
Follow-up Procedure
If the ECS specifications have been modified but the OS cannot be started after remote login, contact customer service or reinstall the ECS OS to resolve this issue. For details, see Reinstalling the OS.

Reinstalling the OS will clear the system disk data, but the data on data disks is not affected.
After the specifications are modified, manually delete the snapshot on the snapshot page if you have verified that services are running properly.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot