All Products
Search
Document Center

Elastic Compute Service:Replace the operating system of an instance

Last Updated:Aug 15, 2024

If the operating system (system disk) 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 or non-public image, such as a custom image or a shared image, to replace the operating system of an ECS instance.

Prerequisites

  • A snapshot is created for the system disk of an ECS instance that you want to replace for data backup. For more information, see Create a snapshot for a disk.

    Important

    An operating system replacement operation replaces a system disk. After the operating system of an 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.

    Warning

    If an 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 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.

Important

After you replace the operating system of an ECS instance, all data stored on the 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. You can use Server Migration Center (SMC) to migrate the operating system instead of replacing the operating system if the following conditions are met: The ECS instance that you use 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 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 cleared.

  • The system disk ID is changed. 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) attached to the instance remain unchanged.

Impacts on the data disks

You can use an image that contains or does not contain data disks to replace the operating system of an ECS instance. The replacement operation replaces the system disk, but not 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 disks, make sure that no business dependency exists between the original system disk and the data disks attached to the instance, or make sure that 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

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

  • The manual snapshots of the original system disk are not released.

  • If Delete Automatic Snapshots While Releasing Disk is enabled for the original system disk, the automatic snapshots of the disk are automatically released along with the disk. If Delete Automatic Snapshots While Releasing Disk is disabled for the original system disk, the automatic snapshots of the disk are not automatically released until they 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 instance may fail to start after the operating system is replaced.

  • 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 operating systems. If your ECS instances run the operating systems, upgrade to Windows Server 2016 or later at the earliest opportunity.

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

  • Operating systems of instances can be replaced across Windows and Linux operating system families only in regions inside the Chinese mainland. In regions outside the Chinese mainland, operating systems of instances can be replaced only within the Windows or Linux operating system family.

  • Check whether the hostname of the 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 modify the hostname, see Modify the attributes of an instance or ModifyInstanceAttribute.

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:

  • If the replacement image is a paid 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 disk capacity increment. For more information, see Block storage devices.

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. Wait a while and then log on to the instance again.

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.

  1. Go to the Instances page in the ECS console.

    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

  2. Find the instance whose operating system you want to replace and choose 更多 > Disk and Image > Replace Operating System in the Actions column.

  3. In the Replace System Disk dialog box, select Replace System Disk.

  4. Read the notes and select I understand the risks. Then, click Continue to Replace Operating System.

  5. On the Change Operating System page, configure parameters.

    更换操作系统

    1. ①: In the Image section, select an image type. Then, select an image and an image version from the drop-down lists.

    2. (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.

      Important
      • You 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.

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

    3. ③: In the Security Settings section, configure an authentication method. The following table describes the authentication methods.

      Authentication method

      Description

      Key Pair

      Note

      You can use key pairs to log on to only 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 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.

      Warning

      If 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

      Note

      This authentication method is supported only if you select the Custom Image or Shared Image image type in the Image section.

      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

      Set a username and a password.

      • For a Linux instance, you can set Username to root or ecs-user.

        Warning

        If 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 configure a password for the ECS instance. For more information, see Bind an SSH key pair and Reset the logon password of an instance.

  6. Check the fees, read and select ECS Service Terms, and then click Create Order.

  7. (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.

  8. (Conditionally required) If both 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

After you replace the operating system of an instance, you can perform the following operations based on your business requirements:

  • 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 new pay-as-you-go disk, and then attach the disk to the ECS instance to restore data. After the data is restored, we recommend that you release the disk at the earliest opportunity. For more information, see Create a disk from a snapshot, Attach a data disk, and Release a disk.

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

  • You can delete the snapshots of the original system disk that you no longer need. For information about how to delete a snapshot, 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 hostname of an ECS instance that runs a Windows operating system cannot 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?

  • By default, Linux operating systems offer a command-line interface. You can install a graphical desktop based on your business requirements. Example: the desktop described in Install a GUI desktop for Ubuntu 18.

  • All Windows operating systems support graphical desktops, except for Windows Server Version 2004 **** (Without UI) and Windows Server 2022 Datacenter **** (Without UI). For more information, see the Third-party images and open source images section of the "Overview" topic.

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 cannot recognize 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 cannot recognize New Technology File System (NTFS) file systems. We recommend that you perform one of the following operations on your data disks:

  • If your data disks do not contain important data, re-initialize the disks and format the disks into a file system that is supported 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 your data disks contain important data, separately install software (such as ntfsprogs) that enables the Linux operating system to work with NTFS file systems.

    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?

For more information, see FAQ about replacing the operating system of an instance.