When you use an Elastic Compute Service (ECS) instance, you can replace the operating system based on your needs. This topic describes how to use a public image or a non-public image (such as a custom image or shared image) to replace the operating system of an instance.

Prerequisites

  • The operating system replacement operation replaces the system disk. After the operating system is replaced, the original system disk is released and all data stored on the disk is cleared. Before you replace the operating system of an instance, we recommend that you create a snapshot of the system disk to back up data. For more information, see Create a snapshot of a disk.
  • The instance whose operating system you want to replace is in the Stopped state. If the instance is not in the Stopped state, stop it. For more information, see Stop an instance.
    Warning If 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.

Background information

This topic describes how to use a public or non-public 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.

For information about image types, see Image overview.

Precautions

Risks may arise when you replace the operating system of an instance. Before you perform this operation, take note of the items described in the following table.
Item Description
Impacts on the system disk
  • The original system disk is released and all of the data and partition information of the disk are cleared.

    After the operating system is replaced, the original system disk is released and all data stored on the disk is cleared. Before you replace the operating system of an instance, we recommend that you create a snapshot of the system disk to back up data. For more information, see Create a snapshot of a disk.

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

    When you replace the operating system of an instance, Alibaba Cloud assigns a new system disk to the instance. The system disk ID changes and the original system disk is released.

Impacts on the data disks Data on the data disks attached to the instance is not affected.
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 not enabled 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 becomes invalid, and you need to configure an automatic snapshot policy for the new system disk.
Limits that apply when the replacement operating system is a Windows operating system
  • Make sure that the system disk has at least 1 GiB of free space reserved. Otherwise, the instance may be unable to start after the operating system is replaced.
  • After January 14, 2020, Microsoft no longer provides support for Windows Server 2008 and Windows Server 2008 R2. Alibaba Cloud no longer provides technical support for ECS instances that use these operating systems. If you have ECS instances that use these operating systems, upgrade them to Windows Server 2012 or later as soon as possible. For more information, see Overview.
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 can be replaced across the Windows and Linux operating system families for instances only in regions inside the Chinese mainland. In regions outside the Chinese mainland, operating systems can be replaced for instances only within the Windows or Linux operating system family.
  • Check that the hostname of the instance meets the requirements of the replacement operating system. For example, the instance hostname cannot exceed 15 characters in length if the replacement operating system is a Windows operating system. For more information about how to modify the hostname of an instance, see Modify the properties of an instance or ModifyInstanceAttribute.
Charges
You are not charged for the operating system replacement operation but are charged for involved resources in the following situations:
  • 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, you are charged for the disk capacity increment. For more information, see EBS devices.
Amount of time required to replace the operating system
It takes about 10 minutes to replace an operating system. The actual amount of time it takes 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 some reasons such as slow boot. Wait a while and log on to the instance again.
Note 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 system disk data and reduce service downtime, use Server Migration Center (SMC) to migrate the operating system. For more information, see Migrate operating systems.

Procedure

  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 is located.
  2. Find the instance whose operating system you want to replace and choose More > Disk and Image > Replace Operating System in the Actions column.
  3. In the Replace System Disk message, read the notes and then click OK.
  4. On the Change Operating System page, configure parameters.
    Replace the operating system of an instance
    1. ①: In the Image section, select an image type and 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 needs.
      You can extend the system disk in this step. The capacity of the new system disk must be greater than the capacity of the current system disk and cannot exceed 500 GiB.
      Important
      • You cannot replace the system disk with a disk of a different category.
      • If you have renewed your instance and downgraded its configurations, the system disk capacity cannot be modified until the next billing cycle starts.
      • If the system disk is extended, you are charged for the disk capacity increment. For more information, see EBS devices.
    3. In the Security Settings section, configure an authentication method.
      Authentication method Description
      Key Pair
      Note Key pairs can be used to log on to only Linux instances.
      Select a username 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 a key pair is created, go back to the Change Operating System page and click the Refresh icon next to the Key Pair field to obtain the most recent key pair list.
      Logon Username can be set 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 Only custom images and shared images support this authentication method.
      You can select this option to use the password preset in the selected image for logons to the instance. If you want to select this option, 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.
        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, a default value of administrator is used for Username.
      Set after Change After the operating system is replaced, bind a key pair or use the password reset feature to set 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.
  5. Check the fees, read and select ECS Service Terms, and then click Create Order.
  6. 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 attach 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 needs. 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 modify the hostname of an instance when I replace its Linux operating system with a Windows operating system? For Windows operating systems, hostnames must not exceed 15 characters in length. Modify the hostname of the instance based on your needs. For more information, see Modify the properties of an instance or ModifyInstanceAttribute.
Which operating systems support visualization?
  • By default, each Linux operating system offers a command line interface. You can install a visual desktop based on your needs. Example: the desktop described in Install a GUI desktop for Ubuntu 18 .
  • All Windows operating systems support visualization except for Windows Server Version 2004 **** (Without UI) and Windows Server 2022 Datacenter **** (Without UI). For more information, see Third-party images and open source images.
How do I use the data disks of an instance after I replace its Linux operating system 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:
  • If your data disks do not contain important data, re-initialize the disks and format them to file systems that are supported by the Windows operating system. For more information, see Re-initialize a data disk and Partition and format a data disk on a Windows instance.
  • If your data disks contain important data, separately install software (such as Ext2Read and Ext2Fsd) that enables the Windows operating system to work with ext3, ext4, or xfs file systems.
How do I use the data disks of an instance after I replace its Windows operating system 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 them to file systems that are supported by the Linux operating system. For more information, see Re-initialize a data disk and Partition and format a data disk 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.
    When you use ntfsprogs, run the following commands in sequence to allow the Linux operating system to access the NTFS file systems:
    yum -y install ntfsprogs
    mount -t ntfs-3g <Data disk partition name> <Mount directory>
    Note Set <Data disk partition name> and <Mount directory> to the actual names and mount directories of the data disk partitions.