If you have selected an incorrect operating system when creating an ECS instance or if the current operating system no longer meets your business needs, you can replace the ECS instance's operating system. This process involves replacing both the image and the system disk. Follow the instructions in this topic to replace the operating system.
Prerequisites
Create a snapshot of the system disk to back up data.
Replacing the operating system will result in the replacement of the system disk and the image. The original system disk will be released, and all data will be erased. Ensure you have created a snapshot of the system disk to back up data before proceeding with the operating system replacement. Snapshot creation may incur charges. For more information, see Snapshots.
The ECS instance must be in the Stopped state. If the instance is running, stop it first. For detailed instructions, see Stop an instance.
If an ECS instance uses the pay-as-you-go billing method and resides in a VPC, you must enable the standard mode when you stop the instance. If you enable the economical mode, you may be unable to start the instance after you replace the operating system of the instance.
For subscription ECS instances, they will be locked upon expiration. Renew the instance before replacing the operating system. For detailed instructions, see How to renew a subscription instance.
Scope of impacts
Replacing the operating system is a high-risk operation. It is important to understand the following points:
After replacing the operating system, the data on the system disk will be erased. You will need to redeploy the business environment on the new system disk, which may lead to business interruptions. If you want to retain the data on the system disk and minimize business downtime, and if the original and target operating systems are compatible with migration and upgrade scenarios, consider using the Server Migration Center (SMC) for operating system migration. For more information, see Operating system migration and upgrade.
Item | Description |
Item | Description |
Impacts on the system disk | After replacement, Alibaba Cloud will assign a new system disk to your ECS instance:
|
Impacts on the data disk |
If you use a custom image that includes a data disk to replace the operating system, ensure there are no dependencies between the system disk and the data disk that could affect your business processes. For instance, if your business involves read and write operations from the system disk to the data disk, replacing the operating system may cause issues with these operations due to changes in the system disk. |
Impacts on snapshots |
|
When replacing with a Windows operating system |
|
When replacing between Windows and Linux operating systems |
|
Costs | There is no charge for replacing the operating system itself. However, you may incur charges in the following scenarios:
|
Time required to replace the operating system | The operating system replacement process typically takes about 10 minutes. The actual duration may vary depending on the operating system. Please be patient. After the replacement is complete, VNC may not log on immediately due to slow system startup. Please wait and try again later. |
Procedure
This section describes how to use an image to replace the operating system of a single ECS instance in the ECS console. If you need to perform batch operations, you can use the OOS public template ACS-ECS-BulkyReplaceSystemDisk to replace ECS system disks in batches. For more information, see ACS-ECS-BulkyReplaceSystemDisk.
Navigate to the Replace Operating System page.
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region where the ECS instance resides.
Locate the destination instance. In the Operation column, click Replace Operating System.
Conduct a precheck on the operating system replacement.
In the Replace Operating System dialog box, select Replace System Disk.
The system will automatically perform a precheck on the operating system replacement, which takes about 10 seconds. Please wait patiently.
If the Precheck column shows , the precheck is successful.
If the Precheck column shows , the precheck has failed. Follow the on-screen instructions to resolve any issues before attempting to replace the operating system again.
Read the precautions for replacing the operating system carefully, select I Am Aware Of The Above Risks And Confirm To Continue, and then click Continue To Replace Operating System.
In the Replace Operating System dialog box, configure the new operating system information.
In the Select Image area, select the type and specific version of the image you want to use.
Only image versions supported by the instance type can be replaced.
In the Security Settings area, set the logon authentication method.
Logon Credential
Description
Logon Credential
Description
Key Pair
Only Linux instances support logon authentication using key pairs.
Select the username and existing key pair for instance logon, or click Create SSH Key Pair Create an SSH key pair. After creating the key pair, return to the Replace Operating System page and click the button next to the key pair dropdown list to refresh the key pair list.
The username can be set to root or ecs-user.
root is the highest-privileged account in the operating system. If you set Username to root, security risks may occur. We recommend that you set Username to ecs-user.
Use Image Preset Password
Only Custom Images and Shared Images support this authentication method.
You can use the preset password of the selected image for logon authentication. To ensure normal use, verify that the selected image has a password preset.
Custom Password
Set the logon username and password. The username information is as follows:
Linux instances: The username can be set to root or ecs-user.
root is the highest-privileged account in the operating system. If you set Username to root, security risks may occur. We recommend that you set Username to ecs-user.
Windows instances: The default username is administrator.
Post-replacement Settings
After the replacement is complete, bind the key pair or reset the password when you remotely log on to the ECS instance. For more information, see Bind SSH Key Pair and Reset Instance Logon Password.
(Optional) In the System Disk area, adjust the system disk capacity or decide whether to encrypt the system disk according to your business needs.
You cannot switch to a different category of system disk.
You can increase the system disk capacity. Additional charges apply for the increased capacity. For more information, see Elastic Block Storage Billing.
If you have downgraded your instance after renewal, you cannot change the system disk capacity until the next billing cycle.
If you extend the system disk during the operating system replacement, partition extension might fail due to a timeout. For solutions, see What to Do If the System Disk Extension Fails When Replacing the Operating System.
If you opt to encrypt the system disk, the data stored on it will be encrypted for enhanced privacy and security. For more information, see Encrypt Disks.
Review the cost details and click Replace Now.
(Optional) Complete the payment process as prompted if there are fees associated with the replacement.
Once the replacement is finished, verify that the status of the ECS instance in the instance list has changed to Running and that the Operating System type of the instance has been updated.
(Conditionally required) If both the original and new operating systems are Linux and the data disk partitions are configured to automatically mount at startup, the mount information for the data disk partitions will be lost after the operating system switch. You will need to update the /etc/fstab configuration. For more information, see Configure Automatic Mounting of Data Disks by UUID in the fstab File.
What to do next
You will need to redeploy environments on the new operating system to resume services, which may include installing software, configuring APT or YUM repositories, and setting environment variables.
After replacing the operating system, the original system disk is released and the data is erased. You can create a new pay-as-you-go disk from a snapshot of the original system disk and attach it to the ECS instance to restore data. Once data restoration is complete, it is advisable to release the disk promptly. For more information, see create a disk from a snapshot, attach a data disk, and release a disk.
How do you reuse the data disks of an ECS instance after replacing the instance operating system between Windows and Linux operating system families?
After switching from a Linux to a Windows operating system, the Windows system may not recognize Ext3, Ext4, or XFS file systems by default. Depending on whether the data disks contain important data, you have a couple of options:
If the data disks do not contain important data, reinitialize them and format into a file system recognized by the Windows operating system. For more information, see reinitialize a data disk and initialize a data disk (Windows).
If the data disks contain important data, install software that enables the Windows operating system to recognize Ext3, Ext4, or XFS file systems, such as Ext2Read or Ext2Fsd.
After switching from a Windows to a Linux operating system, the Linux system may not recognize NTFS file systems by default. Depending on whether the data disks contain important data, you have a couple of options:
If the data disks do not contain important data, reinitialize them and format into a file system recognized by the Linux operating system. For more information, see reinitialize a data disk and initialize a data disk (Linux).
If the data disks contain important data, install software such as ntfsprogs to enable the Linux operating system to recognize NTFS file systems.
When using ntfsprogs, execute the following commands in sequence to grant the Linux operating system access to NTFS file systems:
yum -y install ntfs-3g mount -t ntfs-3g <data disk partition name> <mount directory>
Modify
<data disk partition name>
and<mount directory>
as per your specific requirements.For additional details, see how to mount an NTFS disk between Linux and Windows systems.
References
When replacing the operating system, if you need to know which operating systems support visualization, see Which operating systems support visualization (graphical desktop)?
After replacing the operating system, the automatic snapshot policy of the original system disk becomes invalid. You can configure a new automatic snapshot policy for the new system disk as needed. For more information, see Set automatic snapshot policies for disks.
Delete unnecessary snapshots of the original system disk to reduce costs. For more information, see Delete snapshots.
For additional questions related to replacing the operating system, see FAQs about replacing the operating system.
You can also replace the operating system using the API operation ReplaceSystemDisk.