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 desired 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 ECSs include S1, C1, C2, and M1 ECSs.
- To obtain KVM ECSs, see the Virtualization Type 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 installing drivers and configuring automatic disk attachment.
Constraints
- Batch driver installation applies only to Linux.
- An ECS that runs CentOS 7 and has an EIP bound works as an executor. Ensure that the executor can communicate with the ECSs where drivers are to be installed in a batch.
If the internal yum source 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 installed in a batch, 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 | Task |
|---|---|
| 1 | |
| 2 | |
| 3 | |
| 4 |
Step 1: Create a System Disk Snapshot
Before modifying the specifications, back up the system disk by creating a system disk snapshot and install drivers on the ECS. Otherwise, once the ECS becomes unavailable after the modification, the data in the system disk may be lost.
For instructions about how to create a system disk snapshot, see Creating a Snapshot in Elastic Volume Service User Guide.
After the specifications are modified, manually delete the snapshot on the snapshot page if you verify that services have been recovered.
Step 2: Install and Configure Drivers in a Batch
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.
- Run the following command to install the dependency required for batch running the 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 the editing 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 ECSs with such a tag 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 management console.
- Click
in the upper left corner and select the desired region and project. - Under Computing, click Elastic Cloud Server.
- On the Elastic Cloud Server page, view the status of the target ECS.
If the ECS is not stopped, click More in the Operation column and select Stop.
- Click More in the Operation column and select Modify Specifications.
The Modify ECS Specifications page is displayed.
- Select the new ECS type, vCPUs, and memory as prompted.
- (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, remaining DeH resources are insufficient and cannot be used to create the ECS with specifications modified.
- Select the check box to confirm that Step 2: Install and Configure Drivers in a Batch has been performed.
- Click Next.
- The system automatically creates a system disk snapshot for you. After the specifications are modified, manually delete the snapshot on the snapshot page if you verify that services have been recovered.
- If modifying the ECS specifications failed and the ECS becomes unavailable, reinstall the OS to recover the ECS. However, this operation will clear the system disk data, and data disks will be retained.
- Using APIs
(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.
Follow-up Procedure
If the ECS with specifications modified is displayed in the ECS list but its OS cannot be started after the ECS is remotely logged in, contact customer service or reinstall the ECS OS to rectify this fault. For details, see Reinstalling the OS.
Reinstalling the OS will clear the system disk, but not affecting data disks.
After the specifications are modified, manually delete the snapshot on the snapshot page if you verify that services have been recovered.
Last Article: Manually Changing a Xen ECS to a KVM ECS (Linux)
Next Article: Migrating an ECS


Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.