如何在 Linux 中识别虚拟硬盘的独特性?

如何在 Linux 中识别虚拟硬盘的独特性?

我可以使用“hdparm、sdparm、/sbin/udevadm 和 lshw”获取物理驱动器中的硬盘序列号,但当我使用“Hyper-V”时,我没有序列号。我如何在这种虚拟化环境中从硬盘获取序列号或任何其他数字来识别硬盘,有多独特?

我的尝试:

sdparm -li /dev/sda

   /dev/sda: Msft      Virtual Disk      1.0
Device identification [0x83] VPD page:
  Addressed logical unit:
    designator type: T10 vendor identification,  code set: Binary
      vendor id: MSFT
      vendor specific: ▒▒▒H▒F▒▒"?▒LQ▒
    designator type: NAA,  code set: Binary
      NAA 6, IEEE Company_id: 0x2248
      Vendor Specific Identifier: 0x83119188
      Vendor Specific Identifier Extension: 0x4897223f824c51fe
      [0x60022480831191884897223f824c51fe]

hdparm -i /dev/sda

/dev/sda:
SG_IO: bad/missing sense data, sb[]:  70 00 00 00 00 00 00 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 HDIO_GET_IDENTITY failed: Invalid argument

hdparm -I /dev/sda

/dev/sda:
SG_IO: bad/missing sense data, sb[]:  70 00 00 00 00 00 00 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

ATA device, with non-removable media
Standards:
        Likely used: 1
Configuration:
        Logical         max     current
        cylinders       0       0
        heads           0       0
        sectors/track   0       0
        --
        Logical/Physical Sector size:           512 bytes
        device size with M = 1024*1024:           0 MBytes
        device size with M = 1000*1000:           0 MBytes
        cache/buffer size  = unknown
Capabilities:
        IORDY not likely
        Cannot perform double-word IO
        R/W multiple sector transfer: not supported
        DMA: not supported
        PIO: pio0

/sbin/udevadm 信息 --query=属性 --name=sda

DEVLINKS=/dev/disk/by-id/scsi-360022480831191884897223f824c51fe /dev/disk/by-id/wwn-0x60022480831191884897223f824c51fe /dev/disk/by-path/acpi-VMBUS:00-scsi-0:0:0:0
DEVNAME=/dev/sda
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/device:07/VMBUS:00/vmbus_0_1/host2/target2:0:0/2:0:0:0/block/sda
DEVTYPE=disk
ID_BUS=scsi
ID_MODEL=Virtual_Disk
ID_MODEL_ENC=Virtual\x20Disk\x20\x20\x20\x20
ID_PART_TABLE_TYPE=dos
ID_PATH=acpi-VMBUS:00-scsi-0:0:0:0
ID_PATH_TAG=acpi-VMBUS_00-scsi-0_0_0_0
ID_REVISION=1.0
ID_SCSI=1
ID_SERIAL=360022480831191884897223f824c51fe
ID_SERIAL_SHORT=60022480831191884897223f824c51fe
ID_TYPE=disk
ID_VENDOR=Msft
ID_VENDOR_ENC=Msft\x20\x20\x20\x20
ID_WWN=0x6002248083119188
ID_WWN_VENDOR_EXTENSION=0x4897223f824c51fe
ID_WWN_WITH_EXTENSION=0x60022480831191884897223f824c51fe
MAJOR=8
MINOR=0
SUBSYSTEM=block
UDEV_LOG=3
USEC_INITIALIZED=90937344

lshw 级磁盘

  *-cdrom
       description: DVD reader
       physical id: 0.0.0
       bus info: scsi@1:0.0.0
       logical name: /dev/cdrom
       logical name: /dev/dvd
       logical name: /dev/sr0
       capabilities: audio dvd
       configuration: status=nodisc
  *-disk
       description: SCSI Disk
       physical id: 0.0.0
       bus info: scsi@2:0.0.0
       logical name: /dev/sda
       size: 8GiB (8589MB)
       capabilities: partitioned partitioned:dos
       configuration: sectorsize=512 signature=00077a0d

有些已经返回了许多数据('/sbin/udevadm 和 lshw'),但不知道我是否可以用它来确定其唯一性,即使每次格式化时改变的数字在这种情况下也会很有用。

答案1

这两个应该足以识别同一个磁盘,即使通常在虚拟化环境中。

DEVLINKS=/dev/disk/by-id/scsi-360022480831191884897223f824c51fe /dev/disk/by-id/wwn-0x60022480831191884897223f824c51fe

相关内容