Serial numbers can be used as unique IDs for cloud disks and local disks in an operating
system, helping identify and distinguish different disks. This topic describes how
to query the serial number of a disk in Linux and Windows.
Limits
Limits on using serial numbers:
- You can query only the serial numbers of new disks.
- This feature can only be used for I/O optimized instances.
- This feature is supported by enhanced SSDs (ESSDs), standard SSDs, ultra disks, and
basic disks.
- This feature is supported by local NVMe SSDs and SATA HDDs.
Query the serial number of a disk in Linux
- Remotely connect to an ECS instance. For more information, see Overview.
- Run the
lsblk
command to query the names of Block Storage devices in an instance.
[root@ecs ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vdb 254:16 0 20G 0 disk
vda 254:0 0 40G 0 disk
- Run the following command to query the serial number of a Block Storage device:
udevadm info --query=all --name= device name | grep ID_SERIAL
For example, you can use the following command to query the serial number of the /dev/vda
device:
[root@ecs ~]# udevadm info --query=all --name=/dev/vda | grep ID_SERIAL
E: ID_SERIAL=bp1d4foh3ef8bntl****
Query the serial number of a disk in Windows Server 2012 or later
- Remotely connect to an ECS instance. For more information, see Overview.
- Open Windows PowerShell.
Open the Start menu, enter PowerShell in the search field, and then click Windows PowerShell.
- Run the following command to query the disk corresponding to a specified logical volume
(LV):
Get-CimInstance -ClassName Win32_LogicalDiskToPartition |select Antecedent, Dependent |fl
Example:
PS C:\Users\Administrator> Get-CimInstance -ClassName Win32_LogicalDiskToPartition |select Antecedent, Dependent |fl
Antecedent : Win32_DiskPartition (DeviceID = "Disk #0, Partition #0")
Dependent : Win32_LogicalDisk (DeviceID = "C:")
Antecedent : Win32_DiskPartition (DeviceID = "Disk #1, Partition #0")
Dependent : Win32_LogicalDisk (DeviceID = "D:")
- Run the following command to query the disk serial number:
Get-Disk |select Number, SerialNumber
Example:
PS C:\Users\Administrator> Get-Disk |select Number, SerialNumber
Number SerialNumber
------ ------------
1 bp14dzwwr539hzqi****
0 bp16htuqeqnvlee8****
Query the serial number of a disk in an operating system earlier than Windows Server
2012
- Remotely connect to an ECS instance. For more information, see Overview.
- Open Windows PowerShell.
Open the Start menu, enter PowerShell in the search field, and then click Windows PowerShell.
- Run the following command to query the disk corresponding to a LV:
Get-WmiObject -Class Win32_LogicalDiskToPartition |select Antecedent, Dependent |fl
Example:
PS C:\Users\Administrator> Get-WmiObject -Class Win32_LogicalDiskToPartition |select Antecedent, Dependent |fl
Antecedent : \\ecs\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #0"
Dependent : \\ecs\root\cimv2:Win32_LogicalDisk.DeviceID="C:"
- Run the following command to query the disk serial number:
Get-WmiObject -Class Win32_PhysicalMedia |select Tag, Serialnumber
Example:
PS C:\Users\Administrator> Get-WmiObject -Class Win32_PhysicalMedia |select Tag, Serialnumber
Tag Serialnumber
--- ------------
\\. \PHYSICALDRIVE0 bp1bet4g35opq6vq****