All Products
Search
Document Center

Elastic Compute Service:Detach or attach a system disk

Last Updated:Oct 25, 2023

You can detach system disks from Elastic Compute Service (ECS) instances. This topic describes how to detach and attach the system disk for an ECS instance.

Scenarios

If an instance cannot start because files on the system disk are corrupted, you can detach the disk from the instance and attach the disk to another instance as a data disk for repair. After the disk is repaired, you can attach it back to the original instance as the system disk.

Prerequisites

  • Snapshots are created for the system disk of an instance that you want to manage to back up disk data. For more information, see Create a snapshot for a disk.

  • The involved resources meet the following requirements before you detach the system disk from the instance:

    • The instance is in the Stopped state because the system disk can be detached only offline.

    • The image used to create the instance is not deleted.

    • The image used by the instance is not an Alibaba Cloud Marketplace image or a custom image that is created based on an Alibaba Cloud Marketplace image.

  • An instance meets the following requirements before you attach a detached system disk as a system disk to the instance:

    • The instance is in the No System Disk state.

    • The instance is the instance from which the system disk was detached.

Step 1: Detach a system disk

  1. Log on to the ECS console.

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

  3. In the upper-left corner of the top navigation bar, select a region. 地域

  4. Find an instance that is in the Stopped state and click the ID of the instance.

  5. On the Instance Details page, click the Cloud Disk tab.

  6. In the Actions column corresponding to the system disk, choose 更多 > Detach.

  7. In the Detach Disk dialog box, click OK.

    Note

    If you clear Release Disk with Instance in the dialog box, the system disk is retained as a data disk when the instance is released. The disk is then billed on a pay-as-you-go basis.

  8. Check whether the system disk is detached.

    1. Go back to the Instances page. You can find that the instance is in the No System Disk state and a tag is added to the instance.

      卸载云盘-结果
    2. In the left-side navigation pane, choose Storage & Snapshots > Disks.

    3. The system disk is converted to a data disk and has three tags. The billing method of the disk remains unchanged.

      卸载云盘-结果-云盘

    You can use the tags that are added to the instance and to the disk to search for resources. The following table describes the tags.

    Tag key

    Description

    Tag value

    acs:ecs:sourceSystemDiskId

    The system disk of the instance.

    The ID of the disk.

    acs:ecs:sourceInstanceId

    The instance to which the system disk was attached.

    The ID of the instance.

    acs:ecs:diskDeleteProtection

    Indicates that the release protection feature is enabled for the disk. The disk cannot be manually released.

    true

    acs:ecs:diskPayType

    The billing method of the disk.

    The billing method of the disk before it was detached. Valid values:

    • Prepaid: subscription.

    • AfterPay: pay-as-you-go

After a system disk is detached from an instance, the instance and the system disk do not support the following operations:

  • Start the instance

  • Change the billing method of the instance

  • Change the instance type

  • Change the public bandwidth

  • Create a custom image

  • Separately release the system disk

  • Replace the system disk

  • Resize the system disk

  • Change the billing method of the disk

Step 2: Attach the detached system disk as a data disk to a different instance

  1. After you detach a system disk from an instance, attach the disk as a data disk to a different instance and then perform repair operations, such as file restoration and data restoration, on the disk.

    For more information, see Attach a data disk.

  2. Detach the repaired disk from the instance.

    For more information, see Detach a data disk.

Step 3: Attach the disk as a system disk to the original instance

  1. Log on to the ECS console.

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

  3. In the upper-left corner of the top navigation bar, select a region. 地域

  4. Find the original instance that is in the No System Disk state. In the Actions column, click Attach Disk.

  5. In the Attach Disk dialog box, perform the following operations:

    1. Copy the value of Source System Disk and paste the value to the Disk field.

    2. Configure the parameters that are described in the following table.

      Parameter

      Description

      Example

      Username

      The username to use to log on to the instance.

      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.

      ecs-user

      Logon Credentials

      The logon credentials for the instance.

      • Key Pair: Select this option only for Linux instances.

      • Password: You can select this option for Windows Server instances and Linux instances. This option takes effect only when the administrator username is used for Windows Server instances or when the root or ecs-user username is used for Linux instances.

      Key Pair

      Release Mode

      Release Disk with Instance: specifies whether to retain the disk when the instance is released.

      • If this option is selected, the disk is released when the instance is released.

      • If this option is not selected, the disk is retained as a data disk and billed on a pay-as-you-go basis when the instance is released.

      Do not select Release Disk with Instance

      Delete Automatic Snapshots While Releasing Disk: specifies whether to retain the automatic snapshots of the disk when the disk is released.

      • If this option is selected, the automatic snapshots are deleted when the disk is released.

      • If this option is not selected, the automatic snapshots are retained when the disk is released.

      Select Delete Automatic Snapshots While Releasing Disk

    3. Click OK.

    4. Confirm the settings and click Attach.