FAQ: Attaching, initializing, and releasing disks
Attaching disks
-
How do I select a zone for a disk based on application requirements?
-
Why can't I find the instance that I want to attach a disk to?
-
Can I attach a pay-as-you-go data disk to a subscription ECS instance?
Initializing disks
-
What do I need to know when I add mount information for basic and SSD disks?
-
How do I troubleshoot data access issues caused by data disk mounting problems?
-
Can I repartition a data disk to create additional partitions?
-
What is the relationship between writing data and formatting a partition?
-
How do I resolve an automatic file system mount failure after I enable Project Quota?
-
How do I resolve an error that occurs when I mount or read a file system?
-
How do I check disks and format partitions on a Linux instance?
Detaching or releasing disks
Appendix
Selecting a disk zone for an application
You can attach a pay-as-you-go disk only to an ECS instance in the same zone.
-
For high-availability applications, create data disks in different zones and attach them to the corresponding ECS instances.
-
For low-latency applications, create and attach a data disk to an ECS instance in the same zone.
What is a standalone disk?
A standalone disk is a pay-as-you-go data disk that you purchase separately, rather than with an ECS instance. You can attach and detach a standalone disk between different ECS instances within the same zone, but you cannot attach it across regions or zones. Before using a standalone disk, you must attach it to an instance, then partition and format it. For more information, see Create an empty data disk.
Attaching a disk to multiple instances
No, a disk can be attached to only one instance within the same zone. You cannot attach a disk across zones.
Maximum attachable disks per instance
You can attach up to 64 data disks to an ECS instance. The maximum number of attachable disks varies by instance type. For more information, see Instance families.
The instance type determines the maximum number of disks that you can attach to an instance. You can call the DescribeInstanceTypes API operation to query this limit. When you create an instance, you can specify a maximum of 1 system disk and 64 data disks, subject to the limits displayed in the console. If you require more data disks, you can attach them after the instance is created.
Finding an instance to attach a disk
Ensure the instance has not been released and is in the same region and zone as the disk.
Cross-zone disk attachment
No, you can attach and detach pay-as-you-go disks only between ECS instances within the same zone.
Attach pay-as-you-go disks to subscription instances
Yes.
Partitioning SSD disks on Linux instances
On a Linux operating system, the device name for an SSD disk is displayed as /dev/vd*, which is different from the common device name /dev/xvd*. We recommend that you use the /dev/vd* format in your mount command.
Adding mount information for disks
When you add a data disk to a Linux instance and format its partitions, note that the device name of the data disk differs between I/O optimized and non-I/O optimized instances. The operating system automatically assigns a device name to the data disk based on the following rules:
-
For I/O optimized instances:
-
For data disks attached over the NVMe protocol, the device name is /dev/nvmeXn1, such as /dev/nvme1n1, /dev/nvme2n1, and /dev/nvme3n1. For more information about NVMe-compliant disks, see NVMe-enabled disks.
-
For data disks not attached over the NVMe protocol, the device name is /dev/vd[b-z], such as /dev/vdb, /dev/vdc, and /dev/vdd.
-
-
For non-I/O optimized instances: The data disk device name is /dev/xvd[b-z], such as /dev/xvdb, /dev/xvdc, and /dev/xvdd.
Use the universally unique identifier (UUID) to reference new partitions in the /etc/fstab file. Operations such as releasing a disk can cause the device names of other disks to change. If you use device names directly in /etc/fstab, these changes may affect your stored data.
If you add incorrect information, the mount -a command fails. To resolve this issue, perform the following steps:
-
Run the
fdisk -lcommand to view detailed data disk information. -
Verify the entries in the
/etc/fstabfile.NoteDo not add duplicate mount information. Duplicates can cause repeated mount attempts on startup and prevent the system from booting.
-
Use vim to modify the
/etc/fstabfile. -
Comment out or delete the incorrect entries and add the correct mount information.
-
Run the
mount -acommand to verify that the mount is successful.
For information about the standard procedure, see Initialize a data disk (Linux).
What is a device name?
A device name specifies the location of a disk on the disk controller bus of an ECS instance. The selected device name corresponds to the disk device number in a Linux operating system and the disk order in Disk Management in a Windows operating system.
Mounting partitions on pay-as-you-go disks
After purchasing a pay-as-you-go data disk separately, you must attach it to an instance, then partition and format it. For more information, see Initialize a data disk (Linux) and Initialize a data disk (Windows).
Data disk not visible in the OS
-
Linux
If you purchased a pay-as-you-go data disk separately, you must partition, format, and mount it before you can use it and view its storage space. For more information, see Initialize a data disk (Linux) and Mount a data disk.
-
Windows
For information about the causes and solutions, see Resolve the issue where a data disk cannot be viewed in a Windows instance.
Troubleshooting data access issues
If you cannot access the data on a Linux data disk, you can follow the steps in this section to troubleshoot the issue.
-
Find the disk that stores the data and verify that the data disk is attached to the correct ECS instance.
-
Check in the console. For more information, see View the monitoring information of a disk.
-
Inside the instance, run the
fdisk -lcommand to check whether the partition information of the data disk is normal. Then, run thedf -handmount | grep "<devpath>"commands to check the mount status.
-
-
Run the cat command to check the /etc/fstab file and determine whether two disks are mounted to the same directory.
-
If the disks are mounted to the same directory, the disk that was mounted first is obscured by the disk that was mounted later, which makes the data on the first disk inaccessible. We recommend that you mount one of the disks to a different directory.
-
If the disks are not mounted to the same directory but the mount information still indicates the same directory, run the ll command to check whether the two mount directories are linked. If they are linked, we recommend that you run the mkdir command to create a new directory for mounting, and then test whether the data can be accessed.
-
Repartitioning a data disk
Yes. You can create multiple partitions on a data disk based on your requirements. Use the partitioning tools provided by the operating system.
Considerations for repartitioning a disk
For data security, create a snapshot to back up your disk data. This lets you roll back the disk if an operational error occurs. For more information, see Create a manual snapshot and Roll back a disk by using a snapshot.
Data writing and partition formatting
You must initialize a new disk or a new partition on a disk before you can use it. During initialization, data structures are recorded on the disk. The purpose of formatting is to create a file system. Therefore, creating a file system on a disk involves writing data to the disk. Different file systems write different amounts of data during formatting:
-
Formatting in a Windows operating system (Quick format and Full format):
-
Quick format: Assigns a file system to the partition and rewrites the directory table. A quick format uses a relatively small amount of actual disk space.
-
Full format: In addition to performing the tasks of a quick format, a full format scans the partition sector by sector to identify and mark bad sectors and fills empty blocks on the disk. This is equivalent to writing data to the entire disk. In this case, the first full snapshot is approximately the size of the disk capacity.
-
-
Formatting in a Linux operating system: After a disk is formatted, the size of the first snapshot depends on the file system format of the disk, assuming no service data has been written to the instance.
Resizing disk partitions
For system security and stability, you cannot repartition the system disk of a Windows or Linux instance. Using a third-party tool to force a repartition may lead to unforeseeable risks, such as system crashes or data loss.
You can repartition a data disk, but this is not recommended because it may cause data loss.
Checking disks and formatting partitions on Linux
You can run the df -h command to check disk space and usage, and run the fdisk -l command to check disk information. For information about how to partition and format a disk on a Linux instance, see Initialize a data disk (Linux).
Viewing the last attached instance
-
Go to the ECS console > Elastic Block Storage > Disks page.
-
Find a disk in the Unattached state. In the Tag column, hover over the
icon.-
If no binding information is available for the disk, the disk has never been attached to an ECS instance.
-
If binding information is available, find the tag key
acs:ecs:lastAttachedInstance. The corresponding tag value is the ID of the instance to which the disk was last attached.On the Disks page, hover over the tag icon in the row of the target disk to view the tag key-value pairs in the displayed tooltip.
-
Data loss when detaching a disk
-
On a Windows operating system, stop all read and write operations on the disk's file systems to ensure data integrity. Otherwise, you will lose data from incomplete operations.
-
On a Linux operating system, you must log on to the instance and run the umount command for the disk. After the command succeeds, detach the disk in the console.
Can I detach a system disk?
Yes. For more information, see Detach or attach a system disk.
Detaching data disks from subscription instances
You cannot directly detach a data disk from a subscription ECS instance. A subscription data disk expires at the same time as the instance and is released together with the instance. If you want to release the data disk, you must first change the billing method of the subscription data disk to pay-as-you-go, and then detach and release the data disk. For information about how to change the billing method of a disk, see Change the billing method for a disk.
Releasing a subscription disk before expiration
You cannot directly release subscription data disks. You can change the billing method to pay-as-you-go and then release the disk. Before you release the disk, back up important data. For more information, see Change the billing method for a disk and Release a disk.
After you change the billing method of a subscription data disk to pay-as-you-go, bills are generated on an hourly basis. You are no longer charged for the disk starting from the hour after the disk is released. The actual refund amount after you change the billing method is subject to the amount displayed on the page. Used coupons are not refunded.
Disk released with its instance
You can configure whether to automatically release a disk together with its associated instance. You can enable or disable this feature in the console or by calling an API operation. For more information, see Release a disk.
Snapshot retention after disk deletion
-
Manual snapshots are not deleted.
-
Whether automatic snapshots are deleted depends on whether you enable the Delete Automatic Snapshots While Releasing Disk attribute. For more information, see Enable automatic snapshot release.
Automatic snapshot creation failures
When the number of snapshots reaches the quota, the system automatically deletes the earliest automatic snapshot. Manual snapshots are not affected.
An automatic snapshot policy applies only when the disk is attached to an instance.