How to get serial number from Mac hard disks?

后端 未结 7 782
遇见更好的自我
遇见更好的自我 2020-12-01 10:10

Is there an easy way to get the serial number of all the hard disks in a Mac using an API?

Basically, I\'m looking for a unique identifier for the hard disk with whi

7条回答
  •  遥遥无期
    2020-12-01 10:27

    The drive ID's can be retrieved from the IORegistry as follows:

    • Internal drives: IOAHCIBlockStorageDevice string property "Serial Number" inside "Device Characteristics" e.g.: (WD-WCAV5D1345345)

    • USB drives : IOUSBDevice string property "USB Serial Number" e.g.: (5743415654564561373734)

    • FireWire drives : IOReducedBlockServices number property "GUID" inside "Protocol Characteristics" e.g.: (407345709348650)

    • Thunderbolt drives: ??

    These ID's are persistent meaning the same external drives connected to different machines will show the same ID.

提交回复
热议问题