You can replace the operating system of an Elastic Compute Service (ECS) instance by replacing its system disk. This topic describes how to use a non-public image such as a custom image to replace the operating system of an instance.

Prerequisites

  • Snapshots are created to back up instance data to prevent data loss caused by the automatic release of the system disk to be replaced. For more information, see Create a snapshot for a disk.
  • The instance whose operating system you want to replace is in the Stopped state. For information about how to stop an instance, see Stop an instance.
    Warning When you stop a pay-as-you-go instance in a virtual private cloud (VPC), you must select Retain Instance and Continue Charging After Instance Is Stopped. If you select No Charges After Instance Is Stopped instead, you may not be able to start the instance after you replace its operating system.

Background information

This topic describes how to replace the operating system of a single instance in the ECS console. If you want to batch replace the operating systems of multiple instances, you can use the ACS-ECS-BulkyReplaceSystemDisk public template provided by Operation Orchestration Service (OOS). To learn more about the template, go to the OOS console.

For information about how to use a public image to replace the operating system of an instance, see Replace the operating system of an instance by using a public image. For information about image types, see Image overview.

Precautions

Risks may arise when you replace the system disk of an instance. Before you perform this operation, take note of the following items:
  • 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. 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.
  • After you replace the operating system of an instance, you must redeploy environments on the new system disk to run services. This may interrupt the services that are running on the instance for an extended period of time.
  • Snapshots of the original system disk cannot be used to roll back the new system disk, but can be used to create custom images. Take note of the following items about the snapshots based on their types:
    • The manual snapshots of the original system disk are not automatically 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.
  • If you want to make replacements between Windows Server and Linux operating systems, take note of the following items:
    • You can make replacements between Windows Server and Linux operating systems only within regions inside mainland China.
    • Make sure that the hostname of the instance meets the requirements of the replacement operating system, and delete invalid characters. For information about how to modify the hostname, see Modify the properties of an instance or ModifyInstanceAttribute.
  • If you want to replace the operating system to Windows Server, take note of the following items:
    • The system disk must have at least 1 GiB space reserved. Otherwise, the instance may not be able to start after the operating system is replaced.
    • Microsoft no longer provides support for Windows Server 2003. To ensure your data security, we recommend that you do not use Windows Server 2003 for your instances. Alibaba Cloud no longer provides Windows Server 2003 images. For more information, see End of support for Windows Server 2003 public images.

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 on which you want to perform operations is located.
  2. Find the instance whose operating system you want to replace and choose More > Disk and Image > Replace System Disk in the Actions column.
  3. In the Replace System Disk message, read the notes and click OK.
  4. On the Change Operating System page, configure parameters.
    1. In the Image section, select Custom Image, Shared Image, or Marketplace Image and then select an image and an image version.
    2. In the System Disk section, specify the capacity of the new system disk based on your business needs and the requirements of your selected image.
      You cannot replace the current system disk with a disk of a different category. The minimum capacity of the new system disk is determined by the image type and the capacity of the current system disk. Your specified disk capacity must be smaller than or equal to 500 GiB.
      Image Size range of a resized system disk (GiB)
      CoreOS and FreeBSD [Max{30, Original size of the system disk}, 500]
      Other Linux distributions [Max{20, Original size of the system disk}, 500]
      Windows Server [Max{40, Original size of the system disk}, 500]
      Note If you have renewed your instance and downgraded its configurations, the system disk capacity cannot be modified until the next subscription period starts.
    3. In the Security Settings section, configure the authentication method.
      Authentication method Description
      Key Pair Select an existing key pair or click Create Key Pair to create a key pair. After a key pair is created, go back to the ECS instance creation wizard and click the refresh icon to query the most recent key pair list. For more information, see Create an SSH key pair.
      Note Key pairs can be used to log on only to Linux instances.
      Use Predefined Password Use the predefined password of your selected image.
      Note Only custom images or shared images support this authentication method.
      Password Enter and confirm a password. When you log on to an instance by using a username and a password, the default username for Linux is root and that for Windows is administrator.
      Set after Change After the operating system is replaced, bind the key pair or reset the 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.
    • For more information about billing details of the image, see Image overview.
    • For more information about prices of system disks, visit the Pricing tab of the Elastic Compute Service product page.
  6. 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 instance automatically enters the Running state. You can click the instance ID to go to the Instance Details page and view the information of the new image.

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 the new operating system is a Linux operating system and the instance has data disks attached, you must write the information of the data disk partitions to the /etc/fstab file and run the mount command to mount the partitions. 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 automatically becomes invalid, and you must configure an automatic snapshot policy for the new system disk. For more information, see Apply or disable an automatic snapshot policy.
  • Optional. You can delete the snapshots of the original system disk that you no longer need. For more information, see Delete a snapshot.

FAQ

Question Answer
How do I use the data disks of an instance after I replace its Linux operating system to Windows Server? By default, Windows Server operating systems cannot recognize ext3, ext4, and 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 Server operating system. For more information, see Re-initialize a system 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 allows the Windows Server 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 Server operating system to Linux? 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 system disk and Format a data disk for a Linux instance.
  • If your data disks contain important data, separately install software (such as NTFS-3G) that allows the Linux operating system to work with NTFS file systems.