If you need a completely new operating system environment, you can replace the system disk. This method supports a wider range of operating systems but requires you to redeploy your applications and environment from scratch. If you want to change the operating system while preserving the data on your existing system disk, consider migrating the operating system.
Replacing the system disk releases the original disk, which causes a service interruption. All data on the disk is permanently deleted. Before you proceed, you must create a manual snapshot to back up your data.
Impacts
Be aware of the following impacts:
System disk
Data deletion: The system releases the original system disk, permanently deleting all its data and partition information.
ID change: The instance is assigned a new system disk with a new disk ID.
Unchanged properties: The disk type, instance IP address, and elastic network interface MAC address remain unchanged.
Data disk
Same OS family: If you replace the OS within the same family (for example, Windows to Windows or Linux to Linux), the data disk is not affected. You only need to remount it after the replacement.
Cross-OS family: If you switch between Windows and Linux, the new OS cannot natively recognize the original data disk's file system. Refer to Next steps to re-initialize the data disk or install specific software to read the data.
Snapshots
Snapshots of the original system disk cannot be used to roll back the new system disk.
Manually created snapshots are retained.
The retention of automatic snapshots depends on whether the feature to release them along with the disk is enabled.
Enabled: The automatic snapshots are deleted.
Disabled: The automatic snapshots are retained until their lifecycle expires.
The automatic snapshot policy of the original system disk becomes invalid for the new system disk. You must configure a new policy.
Charges
The OS replacement feature is free. New fees are incurred in the following two scenarios:
Paid image: If you select a paid image, you are charged based on the pricing of the image.
System disk resize: If you increase the capacity of the system disk during the replacement, you are charged for the additional capacity.
Limitations
Region support: Cross-family OS replacement (for example, from Windows to Linux or vice versa) is supported only in regions in the Chinese mainland. In other regions, you can replace the OS only within the same family (for example, Linux to Linux or Windows to Windows).
Hostname: Before a cross-family OS replacement, ensure that the instance hostname meets the requirements of the target OS. For example, a Windows hostname must contain 2 to 15 characters.
Non-I/O optimized instances: You can check the instance type in the Other Information section on the instance details page. If the instance is a non-I/O optimized instance, you cannot use the console to replace its OS with Windows. You can only call the ReplaceSystemDisk API operation to replace the OS with one of the following public Windows Server images.
Target system disk capacity requirements: When you change the operating system to Windows, the system disk must have at least 1 GiB of available space. Otherwise, the instance fails to start after the replacement.
Image limitations: For Alibaba Cloud Linux 3 Pro instances, you cannot replace the operating system with a different one.
Procedure
Navigate to the ECS console - Instances page. At the top of the page, select the resource group and region where your target instance is located.
On the instance list page, click the ID of the target instance to go to its details page. In the upper-right corner, choose All Operations > Replace System Disk.
Set the OS replacement method.
Set Replacement Method to Replace a system disk. The system automatically performs a precheck. If the check fails, fix the issues as prompted and try again.
Read the notes, select I am aware of the preceding risks and want to continue, and then click Continue to Replace Operating System.
Configure the new operating system and instance information.
Image: Select an image type (such as public image or custom image) and a specific image version compatible with the current instance specification.
Security Settings:
Security option
Description
Key Pair
(Linux instances only) Select an existing key pair. If no key pairs are available, click Create Key Pair to create one.
Use Predefined Password
(Custom/Shared images only) Use the password that is preset in the image as the logon credential. Make sure that a password is configured for the selected image.
Password
Set the logon username and password for the new operating system. For a Linux system, you can set the username to
rootorecs-user(recommended). For a Windows system, the default username isadministrator.Set after Change
Skip the logon credential settings. After the OS is replaced, you must bind an SSH key pair or reset the instance logon password before you can log on to the instance.
System Disk (Optional): You can increase the system disk capacity or enable disk encryption. The system disk type cannot be changed.
For information about the fees for resizing a system disk, see Block storage billing.
Confirm the configuration and fees, and then replace the operating system.
(Required) If the instance is Running, stop the instance.
Subscription: If you increased the system disk capacity during the OS replacement, you must pay for the order as prompted. The replacement begins after the payment is complete.
Pay-as-you-go: We recommend that you select Standard Mode. If you use Economical Stop Mode, the instance may fail to start due to insufficient inventory after you change the operating system.
The replacement process takes about 10 minutes, and the instance will automatically restart. After the process is complete, the instance status will change to Running, and the operating system will be updated to the newly selected system.
Next steps
Handle the data disk
Same OS family: If you replaced a Linux OS with another Linux OS and a data disk exists, after the replacement, you must log on to the instance and mount the data disk file system.
Cross-OS family:
Linux to Windows: Windows does not natively recognize file systems such as ext4 and XFS. You can use a third-party tool such as
Ext2Fsdto read the data disk, or re-initialize the data disk if it does not contain important data.Windows to Linux: Linux does not natively recognize the NTFS file system. You can install the ntfs-3g tool to mount the file system, or re-initialize the data disk if it does not contain important data.
Recover data from the original system disk If you need to recover data from the original system disk, you can use a snapshot of the original system disk to restore the data. Use the snapshot that you created before the replacement to create a new pay-as-you-go disk, attach it to the instance, and then recover the data. After the data is recovered, release the disk in a timely manner to avoid unnecessary charges.
Extend the system disk partition and file system
When you resize a system disk by replacing the OS, the partition extension may not take effect due to a timeout. If the extension fails, you must extend the partition manually. For more information, see Extend partitions and file systems of a disk (Linux). This method extends only the system disk partition and does not affect the OS version.
Redeploy your business environment On the new operating system, reinstall the required business software, configure environment variables, and migrate your application code.
Related operations
Configure an automatic snapshot policy for a disk to automatically back up data on a regular basis.
After you confirm that the data on the original system disk is no longer needed, delete the snapshot to reduce storage costs.
Use the public template ACS-ECS-BulkyReplaceSystemDisk to bulk-replace the system disks of ECS instances.
Call the ReplaceSystemDisk API operation to replace an operating system.
FAQ
Why can't I see certain images (including custom images) when I replace the operating system?
The image features do not match the instance type: An instance type that supports NVMe can use only an image that supports NVMe. Make sure the NVMe driver is installed in the image and change the NVMe Driver attribute of the image to Supported so that the image appears in the image list. In addition, an instance type that supports only the UEFI boot mode can use only a UEFI image. For a custom image, change the boot mode of the image to resolve the issue.
The operating system is incompatible with the processor of the instance type: Some instance types, such as 8th-generation instances, support only specific operating systems.
Windows operating system versions have limits on the number of vCPUs and the memory size: To use a Windows image, the instance memory must be 1 GiB or larger. An instance with less than 1 GiB of memory can use only a Linux image.
Red Hat images support only instance types certified by Red Hat.
Some bare metal and local SSD instances have requirements on the drivers and kernel of the operating system: Select an image that matches the processor of the instance type.
For more information, see Why can't I see certain images when I create an ECS instance?