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 replace the operating system of an ECS instance.
Prerequisites
A snapshot is created for the system disk of the ECS instance whose operating system you want to replace to back up disk data. For more information, see Create a snapshot.
ImportantThe operating system replacement operation replaces the system disk. After the operating system of an ECS instance is replaced, the original system disk is released and all data stored on the disk is cleared. Before you replace the operating system, create snapshots for the system disk to back up data.
The ECS instance whose operating system you want to replace is in the Stopped state. If the ECS instance is not in the Stopped state, stop the instance. For more information, see Stop an instance.
WarningIf 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.
Precautions
If you replace the operating system of an ECS 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 ECS instance, all data stored on the original system disk is cleared, and you must redeploy environments on the new system disk to run services. This may interrupt your business for an extended period of time. If the following conditions are met, you can use Server Migration Center (SMC) to migrate the operating system instead of replacing it: The ECS instance runs an operating system such as Alibaba Cloud Linux or CentOS, and you want to retain data stored on the original system disk and reduce service downtime. For more information, see Migrate and upgrade the operating system of an ECS instance.
Item | Description |
Impacts on the system disk | After you replace the operating system of an ECS instance, Alibaba Cloud assigns a new system disk to the instance. Take note of the following items:
|
Impacts on the data disks | You can use an image that contains or does not contain data from data disks to replace the operating system of an ECS instance. The replacement operation replaces the system disk but does not affect the data disks attached to the instance. Important If the image that you use to replace the operating system of an ECS instance contains data from data disks, make sure that no business dependency exists between the original system disk and the data disks attached to the instance or no issues occur when the new system disk performs operations on the data disks. For example, if the original system disk read data from and wrote data to the data disks, exceptions may occur when the new system disk reads data from and writes data to the data disks. |
Impacts on snapshots |
|
Limits that apply when you replace an operating system with 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 ECS instance, but you are charged for the resources that are used in the following scenarios:
|
Time required to replace the operating system | Approximately 10 minutes is required to replace the operating system of an ECS 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 ECS instance by using Virtual Network Computing (VNC) for specific reasons, such as slow boot. In this case, log on to the instance 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. To replace the operating systems of multiple ECS instances at a time, use the ACS-ECS-BulkyReplaceSystemDisk public template provided by OOS. For more information, see ACS-ECS-BulkyReplaceSystemDisk.
Open the Replace Operating System dialog box.
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.
Find the ECS instance whose operating system you want to replace and choose in the Actions column.
Perform a precheck on the ECS instance.
In the Replace Operating System dialog box, select Replace System Disk.
A precheck is automatically performed on the ECS instance and requires approximately 10 seconds to complete.
If the ECS instance passes the precheck, is displayed in the Precheck column.
If the ECS instance fails the precheck, is displayed in the Precheck column. Follow the on-screen instructions to resolve the issue and then try again.
Read the precautions, select I am aware of the preceding risks and want to continue, and then click Continue to Replace Operating System.
On the Change Operating System page, configure the parameters.
①: In the Image section, select an image type. Then, select an image and an image version from the drop-down lists.
(Optional) ②: In the System Disk section, specify the capacity of the new system disk based on your business requirements or select Encryption to encrypt the new system disk.
ImportantYou cannot replace the system disk with a disk from a different category.
If you renewed the ECS instance and downgraded its configurations, you cannot change the system disk capacity until the next billing cycle starts.
You can specify a capacity that is greater than the capacity of the current system disk. 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, the 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 in 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 only to Linux instances.
Select a username that you want to use to log on to the ECS 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 to the Change Operating System page and click the icon next to the Key Pair field to obtain the most recent key pair list.
Set Username to root or ecs-user.
Warningroot 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 Predefined Password
NoteThis authentication method is supported only if you select the Custom Image or Shared Image image type in the Image section.
You can select this option to use the preset password in the selected image to log on to the ECS instance. If you select this authentication method, make sure that your selected image has a preset password.
Password
Specify a username and a password.
For a Linux instance, you can set Username to root or ecs-user.
Warningroot 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.
For a Windows instance, Username is automatically set to administrator.
Set after Change
After you replace the operating system, bind a key pair or use the Reset Password feature to specify a password for the instance. For more information, see Bind an SSH key pair 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.
Approximately 10 minutes is required to replace the operating system. Go to the ECS console and verify that the state of the ECS instance changes to Running. Check whether the operating system of the instance changes.
(Conditionally required) If the replaced and replacement operating systems are Linux operating systems and the data disk partitions of the ECS 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.
What to do next
You can redeploy environments on the new operating system to run services, such as installing software, APT repositories, and YUM repositories, and configuring environment variables.
After the operating system is replaced, the original system disk is released and all data stored on the disk is cleared. You can use a snapshot of the original system disk to create a pay-as-you-go disk and then attach the new disk to the ECS instance to restore data. After the data is restored, we recommend that you release the new disk at the earliest opportunity. For more information, see Create a disk from a snapshot, Attach a data disk, and Release a disk.
How do I reuse the data disks of an ECS instance after I replace the instance operating system between Windows and Linux operating system families?
After you replace the Linux operating system of an ECS instance with a Windows operating system, the Windows operating system cannot recognize Ext3, Ext4, or XFS file systems on the data disks of the instance. To resolve the preceding issue, we recommend that you perform one of the following operations on the data disks:
If the data disks do not contain important data, re-initialize the disks and format the disks into a file system that can be recognized by the Windows operating system. For more information, see Re-initialize a data disk and Initialize a data disk whose size does not exceed 2 TiB on a Windows instance.
If the data disks contain important data, separately install software that allows the Windows operating system to recognize Ext3, Ext4, or XFS file systems, such as Ext2Read and Ext2Fsd.
After you replace the Windows operating system of an ECS instance with a Linux operating system, the Linux operating system cannot recognize New Technology File System (NTFS) file systems on the data disks of the instance. To resolve the preceding issue, we recommend that you perform one of the following operations on the data disks:
If the data disks do not contain important data, re-initialize the disks and format the disks into a file system that can be recognized by the Linux operating system. For more information, see Re-initialize a data disk and Initialize a data disk whose size does not exceed 2 TiB on a Linux instance.
If the data disks contain important data, separately install software that allows the Linux operating system to recognize NTFS file systems, such as ntfsprogs.
If you use ntfsprogs, run the following commands in sequence to allow the Linux operating system to access the NTFS file systems:
yum -y install ntfs-3g mount -t ntfs-3g <Data disk partition name> <Mount directory>
NoteReplace
<Data disk partition name>
and<Mount directory>
with the actual names and mount directories of the data disk partitions.For more information, see How do I move an NTFS disk between a Linux instance and a Windows instance?
References
For information about the operating systems that support graphical desktops, see the Which operating systems support graphical desktops? section of the "FAQ about images during instance creation" topic.
After you replace the operating system of an ECS instance, the automatic snapshot policy applied to the original system disk becomes invalid. You can configure an automatic snapshot policy for the new system disk based on your business requirements. For more information, see Enable or disable an automatic snapshot policy.
After you replace the operating system of an ECS instance, you can delete the snapshots of the original system disk to reduce snapshot costs. For information about how to delete a snapshot, see Delete a snapshot.
To obtain the answers to frequently asked questions about replacing the operating system of an ECS instance, see FAQ about replacing the operating system of an instance.
You can call the ReplaceSystemDisk operation to replace the operating system of an ECS instance. For more information, see ReplaceSystemDisk.