All Products
Search
Document Center

Elastic Compute Service:Query the serial number of a disk

Last Updated:Mar 20, 2024

Serial numbers are unique identifiers for cloud disks and local disks in an operating system and can be used to identify and distinguish different disks. Serial numbers can also be used to determine disk IDs. This topic describes how to query the serial numbers of disks and determine the IDs of disks based on serial numbers in Linux and Windows operating systems.

Limits

When you query serial numbers, take note of the following limits:

  • Serial number query is supported only for disks that are created on and after June 10, 2020.

    Note

    If the version of the virtio driver of your Windows instance is earlier than 58017, you must update the driver version before you query serial numbers. For more information, see Update Red Hat virtio drivers of Windows instances.

  • Serial number query is supported only for I/O optimized instances.

Query the serial number of a disk

Linux

  1. Connect to an ECS instance.

    For information about the connection methods, see Connection method overview.

  2. Run the lsblk command to query the names of the block storage devices that are attached to an instance.

    [testuser@ecs ~]# lsblk
    NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    vdb    254:16   0  20G  0 disk
    vda    254:0    0  40G  0 disk
  3. Run the following command to query the serial number of a block storage device:

    udevadm info --query=all --name=<Device name> | grep ID_SERIAL

    The following code shows how to query the serial number of the /dev/vda device:

    [testuser@ecs ~]# udevadm info --query=all --name=/dev/vda | grep ID_SERIAL
    E: ID_SERIAL=bp1d4foh3ef8bntl****

Windows

Windows Server 2012 or later

  1. Connect to an ECS instance.

    For information about the connection methods, see Connection method overview.

  2. Open Windows PowerShell.

    Enter PowerShell in the search box next to the Start icon and then click Windows PowerShell.

  3. Run the following command to query the disk corresponding to a logical volume (LV):

    Get-CimInstance -ClassName Win32_LogicalDiskToPartition |select Antecedent, Dependent |fl

    Sample command output:

    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:")
  4. Run the following command to query the serial number of the disk:

    Get-Disk |select Number, SerialNumber

    Sample command output:

    PS C:\Users\Administrator> Get-Disk |select Number, SerialNumber
    
    Number SerialNumber
    ------ ------------
         1 bp14dzwwr539hzqi****
         0 bp16htuqeqnvlee8****

Operating systems earlier than Windows Server 2012

  1. Connect to an ECS instance.

    For information about the connection methods, see Connection method overview.

  2. Open Windows PowerShell.

    Enter PowerShell in the search box next to the Start icon and then click Windows PowerShell.

  3. Run the following command to query the disk corresponding to an LV:

    Get-WmiObject -Class Win32_LogicalDiskToPartition |select Antecedent, Dependent |fl

    Sample command output:

    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:"
  4. Run the following command to query the serial number of the disk:

    Get-WmiObject -Class Win32_PhysicalMedia |select Tag, Serialnumber

    Sample command output:

    PS C:\Users\Administrator> Get-WmiObject -Class Win32_PhysicalMedia |select Tag, Serialnumber
    
    Tag                Serialnumber
    ---                ------------
    \\.\PHYSICALDRIVE0 bp1bet4g35opq6vq****

(Optional) Determine the disk ID by using the serial number

An ID in the d-<Serial number> format is allocated to each disk. After you obtain the serial number of a disk, you can determine the ID of the disk and find the disk in the Elastic Compute Service (ECS) console based on the serial number.

For example, if the serial number of a disk is bp1gks8z0fh3m1z9****, the disk ID that is displayed in the ECS console is d-bp1gks8z0fh3m1z9****.

image.png