If the operating system of an Elastic Compute Service (ECS) instance does not meet your business requirements, you can replace the operating system. This topic describes how to use a public image or a non-public image (such as a custom image or a shared image) to replace the operating system of an instance.
Prerequisites
A snapshot is created for the system disk that you want to replace. For more information, see Create a snapshot for a disk.
The operating system replacement operation replaces the system disk. After the operating system of the instance is replaced, the original system disk is released and data stored on the disk is cleared. Before you replace the operating system, make sure that you create snapshots for the system disk to back up data.
The instance whose operating system you want to replace is in the Stopped state. If the instance is not in the Stopped state, stop the instance. For more information, see Stop an instance.
WarningIf the billing method of an instance is pay-as-you-go and the network type of the instance is VPC, you must enable the standard mode for the instance when you stop the instance. If you enable the economical mode for the instance, you may not be able to start the instance after you replace its operating system.
Precautions
If you replace the operating system of an instance, risks may occur. Before you perform this operation, take note of the items that are described in the following table.
After you replace the operating system of an instance, you must redeploy environments on the new system disk to run services. This may interrupt services that are running on the instance for an extended period of time. If you want to retain data stored on the original system disk and reduce service downtime, we recommend that you use Server Migration Center (SMC) to migrate the operating system instead of replacing the operating system. For more information, see Migrate the operating system of an ECS instance.
Item | Description |
Impacts on the system disk | After you replace the operating system of an instance, Alibaba Cloud assigns a new system disk to the instance. Take note of the following items:
|
Impacts on the data disks | Data on the data disks attached to the instance is not affected. |
Impacts on snapshots |
|
Limits that apply when the replacement operating system is a Windows operating system |
|
Limits that apply when you replace a Windows operating system with a Linux operating system or replace a Linux operating system with a Windows operating system |
|
Charges | You are not charged for replacing the operating system of an instance but are charged for the resources that are used in the following scenarios:
|
Amount of time required to replace the operating system | It takes approximately 10 minutes to replace the operating system of an instance. The actual amount of time varies based on the operating system. Important After the operating system is replaced, you may be unable to log on to the instance by using Virtual Network Computing (VNC) for specific reasons such as slow boot. Log on to the instance again later. |
Procedure
This section describes how to use an image to replace the operating system of a single instance in the ECS console. To batch replace the operating systems of multiple instances, you can use the ACS-ECS-BulkyReplaceSystemDisk public template provided by Operation Orchestration Service (OOS). For more information, see Public Templates.
Go to the Instances page in the ECS console.
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 is located.
Find the instance whose operating system you want to replace and choose in the Actions column.
In the Replace System Disk dialog box, select Replace System Disk.
Read the notes and select I understand the risks. Then, click Continue to Replace Operating System.
On the Change Operating System page, configure parameters.
①: In the Image section, select an image type. Then, select an image and an image version from the drop-down lists.
NoteIf you want to use a custom image to replace the operating system, make sure that the custom image does not contain data disk snapshots. For more information about custom images, see Overview.
(Optional) ②: In the System Disk section, specify the capacity of the new system disk based on your business requirements.
You can specify a capacity that is greater than the capacity of the current system disk.
ImportantYou cannot replace the system disk with a disk of a different category.
If you renewed your instance and downgraded its configurations, you cannot change the system disk capacity until the next billing cycle starts.
If you extend the system disk, you are charged for the additional disk capacity. For more information, see Block storage devices.
If you extend the system disk during the operating system replacement process, partitions on the system disk may fail to be extended due to a timeout error. For information about how to resolve the issue, see the What do I do if partitions on the system disk of an instance fail to be extended when I extend the disk by replacing the operating system of the instance? section of the "FAQ about replacing the operating system of an instance" topic.
③: In the Security Settings section, configure an authentication method. The following table describes the authentication methods.
Authentication method
Description
Key Pair
NoteYou can use key pairs to log on to only Linux instances.
Select a username that you want to use to log on to the instance. Then, select an existing key pair or click create a key pair to create a key pair. For more information, see Create an SSH key pair. After you create a key pair, go back to the Change Operating System page and click the
icon next to the Key Pair field to obtain the most recent key pair list.
You can set Username to root or ecs-user.
WarningIf you log on to the instance as the root user, you have the highest permissions on the instance. However, security risks may arise. We recommend that you use ecs-user instead to log on to the instance.
Use Predefined Password
NoteOnly custom images and shared images support this authentication method.
To use the password preset in the selected image to log on to the instance, select this authentication method. If you select this authentication method, make sure that your selected image has a password preset.
Password
Specify a username and a password.
For a Linux instance, set Username to root or ecs-user.
WarningIf you log on to the instance as the root user, you have the highest permissions on the instance. However, security risks may arise. We recommend that you use ecs-user instead to log on to the instance.
For a Windows instance, Username is set to administrator by default.
Set after Change
After you replace the operating system, bind a key pair or use the password reset feature to specify a password for the instance. For more information, see Bind an SSH key pair to an instance and Reset the logon password of an instance.
Check the fees, read and select ECS Service Terms, and then click Create Order.
(Optional) Complete the payment (if any) as prompted.
It takes about 10 minutes to replace the operating system. After the operating system is replaced, you can go back to the ECS console and find that the state of the instance changes to Running. You can click the instance ID to go to the Instance Details page and view image information.
What to do next
After you replace the operating system of an instance, you can perform the following operations based on the actual conditions:
Redeploy environments on the new operating system to run services.
If both the replaced and replacement operating systems are Linux operating systems and the data disk partitions of the instance are configured to automatically mount on instance startup, the mounting information of the data disk partitions is lost. You must rewrite the mounting information of the data disk partitions to the /etc/fstab file. For more information, see Configure UUIDs in the fstab file to automatically mount data disks.
(Optional) The automatic snapshot policy applied to the original system disk becomes invalid, and you can apply an automatic snapshot policy to the new system disk based on your business requirements. For more information, see Enable or disable an automatic snapshot policy.
(Optional) Delete the snapshots of the original system disk that are no longer needed. For more information, see Delete a snapshot.
FAQ
Question | Answer |
How do I change the hostname of an instance when I replace the Linux operating system of the instance with a Windows operating system? | The hostnames of Windows operating systems must not exceed 15 characters in length. Modify the hostname of the instance based on your business requirements. For more information, see Modify the attributes of an instance or ModifyInstanceAttribute. |
Which operating systems support graphical desktops? |
|
How do I use the data disks of an instance after I replace the Linux operating system of the instance with a Windows operating system? | By default, Windows operating systems do not support ext3, ext4, or xfs file systems. We recommend that you perform one of the following operations on your data disks:
|
How do I use the data disks of an instance after I replace the Windows operating system of the instance with a Linux operating system? | By default, Linux operating systems do not support New Technology File System (NTFS) file systems. We recommend that you perform one of the following operations on your data disks:
|
For more information, see FAQ about replacing the operating system of an instance.