All Products
Search
Document Center

Elastic Compute Service:Replace the system disk (operating system) of an instance

Last Updated:Feb 14, 2025

If the operating system of an Elastic Compute Service (ECS) instance does not meet your business requirements, you can replace the operating system. When you replace the operating system of an ECS instance, you cannot replace only the image of the instance. You must replace the image and the system disk of the instance at the same time. 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.

    Important

    The operating system replacement operation replaces the system disk and the image of the instance. After you replace the operating system of an ECS instance, the original system disk is released and all data stored on the disk is deleted. Before you replace the operating system of an ECS instance, create snapshots for the system disk to back up disk data. You are charged for the created snapshots. For information about the billing of snapshots, see Snapshots.

  • 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 Instance.

    Warning

    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.

  • A subscription ECS instance is locked after the instance expires. If you want to replace the operating system of an expired subscription ECS instance, you must first renew the instance. For more information, see Renew a subscription instance.

Impacts

Replacing the operating system of an ECS instance is a high-risk operation. Before you perform this operation, take note of the items that are described in the following table.

Important

After you replace the operating system of an ECS instance, all data stored on the original system disk is deleted, and you must redeploy environments on the new system disk to run services. This may interrupt your business. If you want to retain data stored on the original system disk and reduce service downtime, and the original and new operating systems meet the requirements for operating system migrations and upgrades, use Server Migration Center (SMC) to migrate the operating system instead of replacing the operating system. 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:

  • The original system disk is released, and all data and partition information of the disk are deleted.

  • The system disk ID changes. However, the category of the system disk, the IP addresses of the instance, and the media access control (MAC) addresses of the elastic network interfaces (ENIs) bound to the instance remain unchanged.

Impacts on the data disks

  • If you replace the operating system of an ECS instance within the Windows or Linux operating system family, the system disk of the instance is replaced and you must re-attach the data disks to the instance before you can reuse the data disks.

  • If you replace the operating system of an ECS instance between Windows and Linux operating system families, the system disk of the instance is replaced. The new operating system cannot recognize the file systems on the data disks attached to the instance. You must re-initialize the data disks or separately install software that allows the new operating system to recognize the file systems. For more information, see the What to do next section of this topic.

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

  • The snapshots of the original system disk cannot be used to roll back the new system disk, but can be used to create custom images.

  • Manual snapshots of the original system disk are not released.

  • If you enable Delete Automatic Snapshots While Releasing Disk for the original system disk, the automatic snapshots of the original system disk are automatically released together with the disk. If you disable Delete Automatic Snapshots While Releasing Disk for the original system disk, the automatic snapshots of the original system disk are retained until the snapshots expire.

  • The automatic snapshot policy applied to the original system disk becomes invalid, and you can configure an automatic snapshot policy for the new system disk based on your business requirements.

Limits that apply when you replace an operating system with a Windows operating system

  • Make sure that the system disk has at least 1 GiB of free space. Otherwise, the ECS instance may fail to start after you replace the operating system of the instance.

  • Starting January 14, 2020, Microsoft no longer provide support for Windows Server 2008 and Windows Server 2008 R2. Starting October 10, 2023, Microsoft no longer provides support for Windows Server 2012 R2. Alibaba Cloud no longer provides technical support for ECS instances that run the preceding operating systems. If your ECS instances run the preceding operating systems, we recommend that you upgrade to Windows Server 2016 or later at the earliest opportunity. For more information, see Windows Server EOL guidance.

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

  • You can replace the operating systems of ECS instances between Windows and Linux operating system families only in regions inside the Chinese mainland. In regions outside the Chinese mainland, you can replace the operating systems of ECS instances only within the Windows or Linux operating system family.

  • Check whether the hostname of the ECS instance meets the requirements of the replacement operating system. For example, if the replacement operating system is a Windows operating system, the instance hostname cannot exceed 15 characters in length. For information about how to change the instance hostname, see Modify the attributes of an instance or ModifyInstanceAttribute.

Charges

You are not charged for the operating system replacement operation, but you are charged for the resources used in the following scenarios:

  • If you use a paid image as the replacement image, you are charged for the image. For more information, see Images.

  • If you extend the system disk when you replace the operating system of an ECS instance, you are charged for the additional disk capacity. For more information, see Block storage devices.

Amount of 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 of an ECS instance 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 ECS instance at a later time.

Procedure

This section describes how to use an image to replace the operating system of an 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.

  1. Open the Replace Operating System dialog box.

    1. Log on to the ECS console.

    2. In the left-side navigation pane, choose Instances & Images > Instances.

    3. In the top navigation bar, select the region where the ECS instance resides.image.png

    4. Find the ECS instance whose operating system you want to replace and click Replace Operating System in the Actions column.

  2. Perform a precheck on the ECS instance.

    1. In the Replace Operating System dialog box, select Replace System Disk.

    2. A precheck is automatically performed on the ECS instance. The precheck requires approximately 10 seconds to complete.

      • If the ECS instance passes the precheck, image is displayed in the Precheck column.

      • If the ECS instance fails the precheck, image is displayed in the Precheck column. Follow the on-screen instructions to resolve the issue and then perform the precheck again.

    3. Read the precautions, select I am aware of the preceding risks and want to continue, and then click Continue to Replace Operating System.

  3. 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 corresponding drop-down lists.

      Note

      You can select only an image version that is supported by the instance type of the ECS instance.

    • In the Security Settings section, configure the authentication method.

      Logon credential

      Description

      Key Pair

      Note

      Key pairs can be used to log on to only Linux instances.

      Select the 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 new 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 the Username parameter to root or ecs-user.

      Warning

      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 the Username parameter to ecs-user.

      Use Predefined Password

      Note

      This option is available 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 option, make sure that your selected image has a preset password.

      Password

      Specify a username and a password.

      • For Linux instances, you can set the Username parameter to root or ecs-user.

        Warning

        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 the Username parameter to ecs-user.

      • For Windows instances, the Username parameter is automatically set to administrator.

      Set after Change

      After you replace the operating system of the ECS instance, bind a key pair to the instance or use the Reset Password feature to configure a password for the instance. For more information, see Bind an SSH key pair and Reset the logon password of an instance.

    • (Optional) In the System Disk section, specify the capacity of the new system disk based on your business requirements or select Encrypted to encrypt the new system disk.

      Important
      • You cannot replace the system disk with a disk from a different category.

      • You can extend the 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 encrypt the new system disk, the data stored on the disk is also encrypted, which protects the privacy and security of the data. For more information, see Encrypt cloud disks.

  4. View the fee, read and select ECS Terms of Service, and then click Confirm Order.

  5. (Optional) Complete the payment (if any) as prompted.

    After the operating system of the ECS instance is replaced, go to the Instance page and check whether the status of the instance changes to Running and whether the new operating system is displayed in the Operating System column.

  6. (Conditionally required) If the original and new operating systems of the ECS instance 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.

What to do next

  • You can redeploy environments on the new operating system of an ECS instance to run services, such as installing software, installing Advanced Packaging Tool (APT) or Yellowdog Updater Modified (YUM) repositories, and configuring environment variables.

  • After the operating system of an ECS instance is replaced, the original system disk is released and all data stored on the disk is deleted. You can use a snapshot of the original system disk to create a pay-as-you-go disk, and then attach the pay-as-you-go disk to the ECS instance to restore data. After you restore the data, we recommend that you release the pay-as-you-go disk at the earliest opportunity. For more information, see Use a snapshot of the original system disk to restore data after the operating system of an ECS instance is replaced.

  • After you replace the operating system of an ECS instance between Windows and Linux operating system families, you can perform the following operations to reuse the data disks of the instance:

    • 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 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 (Linux).

      • 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>
        Note

        Replace <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 information about how to configure an automatic snapshot policy for a cloud disk, see Configure an automatic snapshot policy for a cloud disk.

  • To reduce costs, delete snapshots of the original system disk that you no longer require. For information about how to delete a snapshot, see Delete a snapshot.

  • For 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.