• 在linux下获取硬盘序列号


    方法一:hwinfo --disk

    例子sda

    $ hwinfo --disk
    28: IDE 00.0: 10600 Disk                                        
      [Created at block.245]
      Unique ID: 3OOL.XxO12I_gR04
      Parent ID: _+Pw.BwJ_Mdxf5A3
      SysFS ID: /class/block/sda
      SysFS BusID: 0:0:0:0
      SysFS Device Link: /devices/pci0000:00/0000:00:0f.0/ata1/host0/target0:0:0/0:0:0:0
      Hardware Class: disk
      Model: "KINGSTON RBUSMS1"
      Vendor: "KINGSTON"
      Device: "RBUSMS1"
      Revision: "61D1"
      Driver: "ahci", "sd"
      Driver Modules: "ahci", "sd_mod"
      Device File: /dev/sda
      Device Files: /dev/sda, /dev/disk/by-id/ata-KINGSTON_RBUSMS180S364GJ_50026B72821EF73A, /dev/disk/by-path/pci-0000:00:0f.0-ata-1, /dev/disk/by-id/wwn-0x50026b72821ef73a
      Device Number: block 8:0-8:15
      BIOS id: 0x80
      Drive status: no medium
      Config Status: cfg=new, avail=yes, need=no, active=unknown
      Attached to: #14 (SATA controller)

    例子nvme

    generic@generic-PC:/$ hwinfo --disk
    14: PCI 00.0: 10600 Disk                                        
      [Created at block.245]
      Unique ID: wLCS.FG_TsB9ija0
      Parent ID: B35A.iiLHwdxfB34
      SysFS ID: /class/block/nvme0n1
      SysFS BusID: nvme0
      SysFS Device Link: /devices/pci0000:00/0000:00:01.0/0000:02:00.0/nvme/nvme0
      Hardware Class: disk
      Model: "Disk"
      Vendor: pci 0x1df5 
      Device: pci 0x1202 
      SubVendor: pci 0x1df5 
      SubDevice: pci 0x1202 
      Driver: "nvme"
      Driver Modules: "nvme"
      Device File: /dev/nvme0n1
      Device Files: /dev/nvme0n1, /dev/disk/by-id/nvme-kimtigo_SSD_256GB_S780100G00110S, /dev/disk/by-path/pci-0000:02:00.0-nvme-1, /dev/disk/by-id/nvme-eui.0100000000000000
      Device Number: block 259:0
      Drive status: no medium
      Config Status: cfg=new, avail=yes, need=no, active=unknown
      Attached to: #2 (Non-Volatile memory controller)

    方法二:cat /sys/class/block/sda/device/wwid或者cat /sys/class/block/nvme0n1/device/serial

     sda

    $ cat /sys/class/block/sda/device/wwid 
    t10.ATA     KINGSTON RBUSMS180S364GJ                50026B72821EF73A    

     nvme

    cat /sys/class/block/nvme0n1/device/serial 
    S780100G00110S      

    方法三:udevadm info --query=all --name=/dev/xxx |grep -w ID_SERIAL_SHORT

    $ udevadm info --query=all --name=/dev/sda |grep -w ID_SERIAL_SHORT
    E: ID_SERIAL_SHORT=50026B72821EF73A
    $ udevadm info --query=all --name=/dev/nvme0n1 |grep -w ID_SERIAL_SHORT
    E: ID_SERIAL_SHORT=S780100G00110S

    方法四:lsblk -n --nodeps -o name,serial /dev/xxx

    $ lsblk -n --nodeps -o name,serial /dev/sda
    sda  50026B72821EF73A
    lsblk -n --nodeps -o name,serial /dev/nvme0n1
    nvme0n1 S780100G00110S
  • 相关阅读:
    Microsoft Excel 不能使用对象链接和嵌入的错误/cannot use object linking and enbedding
    (转)QML代码与现有Qt UI代码整合
    vs2012编译Qwt
    参数和返回类型也可以多态
    多态的运行
    调用哪个方法
    继承的意义
    设计继承树2
    设计继承树1
    了解继承
  • 原文地址:https://www.cnblogs.com/libra13179/p/15992230.html
Copyright © 2020-2023  润新知