Detach or attach a system disk

更新时间:
复制 MD 格式

You can detach a system disk from an ECS instance and attach it to another ECS instance as a data disk to migrate data. You can also do this to repair a corrupted system disk that prevents the source instance from starting. After the repair, you can reattach the disk to the source instance as its system disk. This topic describes how to detach and attach a system disk for an ECS instance.

Usage notes

After a system disk is detached, the following operations are not supported on the source ECS instance and the system disk:

  • Start the instance

  • Change the billing method for the instance

  • Change the instance type

  • Change the public bandwidth

  • Create a custom image

  • Release the system disk separately

  • Replace the system disk

  • Resize the system disk

  • Change the billing method for the disk

Detach the system disk

Prerequisites

Before you detach the system disk, make sure that the following requirements are met:

  • You have created a snapshot to back up the data on the system disk. For more information, see Create a snapshot.

  • The associated ECS instance must be in the Stopped state.

  • If the ECS instance was created from a custom image, make sure that the custom image has not been deleted.

  • The image used by the ECS instance is not an Alibaba Cloud Marketplace image or a custom image created from an Alibaba Cloud Marketplace image.

Procedure

  1. Go to ECS console - Instances.

  2. In the top navigation bar, select the region and resource group of the resource that you want to manage. Region

  3. Find the ECS instance that is in the Stopped state and click the instance ID.

  4. On the Instance Details page, click the Block Storage tab.

  5. In the Actions column of the System Disk, select More > Detach.

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

    Note
    • By default, Release Disk with Instance is enabled. If this option is enabled, the system disk is released when the source instance is released, even if the disk is detached or attached to another instance as a data disk.

    • If you disable Release Disk with Instance, the system disk is retained as a pay-as-you-go data disk after the source instance is released.

  7. Verify the result.

    1. Return to the Instances page. The Status of the ECS instance changes to No System Disk, and the tag acs:ecs:sourceSystemDiskId is added to the instance.

    2. In the left-side navigation pane, choose Storage & Snapshots > Cloud Disk.

    3. The system disk is converted into a data disk, and its Status changes to Detached System Disk. Three tags are added to the disk: acs:ecs:sourceInstanceId, acs:ecs:diskDeleteProtection, and acs:ecs:diskPayType. The billing method of the disk remains unchanged.

    The following tags are added to help you find the resources:

    Tag key

    Description

    Value

    acs:ecs:sourceSystemDiskId

    The ID of the system disk that was detached from the instance.

    The disk ID.

    acs:ecs:sourceInstanceId

    The instance to which the system disk belongs.

    The instance ID.

    acs:ecs:diskDeleteProtection

    Prevents the disk from being manually released.

    true

    acs:ecs:diskPayType

    The billing method of the disk.

    Same as before detachment.

    • Prepaid: subscription

    • AfterPay: pay-as-you-go

Attach as a data disk

After you detach the system disk, you can attach it to another ECS instance in the same zone as a data disk to migrate data or repair files. For more information, see Attach a data disk.

Attach as a system disk

If a corrupted system disk prevents an ECS instance from starting, you can detach it for repair. This involves attaching it to another ECS instance as a data disk, and then reattaching it to the source instance as a system disk after the repair is complete.

Prerequisites

Before you attach the system disk, make sure that the target ECS instance meets the following requirements:

  • The instance is in the No System Disk state.

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

Procedure

  1. Go to ECS console - Instances.

  2. In the top navigation bar, select the region and resource group of the resource that you want to manage. Region

  3. Detach the repaired disk from the ECS instance that you used for repair.

    For more information, see Detach a data disk.

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

  5. In the Attach Disk dialog box, configure the following options.

    1. In the Source System Disk text box, enter the ID of the Disk.

    2. Configure the attachment options.

      Parameter

      Description

      Example

      Logon Username

      The username for logging on to the ECS instance.

      Warning

      The root user has the highest permissions on the operating system. Using root as the username may pose security risks. We recommend that you use a standard user, such as ecs-user.

      ecs-user

      Logon Credential

      When you attach a system disk, you must set the logon credentials for the ECS instance:

      • Key Pair: for Linux instances only.

      • Password: for both Windows Server and Linux instances. The password applies only to the administrator (Windows Server), root, or ecs-user (Linux) username. It does not apply to other usernames.

      Key Pair

      Release Mode

      Release Disk with Instance: Determines if the disk is released (deleted) when the instance is released.

      • Selected: The disk is released with the instance.

      • Cleared: The system disk is retained as a pay-as-you-go data disk.

      Cleared

      Delete Automatic Snapshots While Releasing Disk: Determines if automatic snapshots are deleted when the disk is released.

      • Selected: The automatic snapshots are deleted.

      • Cleared: The automatic snapshots are retained.

      Selected

    3. Click Next.