[Linux 學習心得] Ubuntu Linux 下查詢M.2 SSD 硬體資訊

Richard Tsai
5 min readJun 3, 2020

--

這幾天在處理公司的Server 時,發現原先使用 hdparm 可以查到硬碟相關資訊,在M.2 SSD 上是查不到任何資訊的。會出現如下訊息:

# hdparm -I /dev/nvme0 | more 
nvme0 nvme0n1 nvme0n1p1 nvme0n1p2 nvme0n1p3
# hdparm -I /dev/nvme0 | more
HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device
/dev/nvme0:
# hdparm -I /dev/nvme0n1 | more
HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device
/dev/nvme0n1:
# hdparm -I /dev/nvme0n1p1 | more
HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device
/dev/nvme0n1p1:

在 mSATA SSD 是可以的

root@ceph-node1:/dev# hdparm -I /dev/sda/dev/sda:ATA device, with non-removable media
Model Number: KINGSTON SHSS37A240G
Serial Number: 50026B725A02FA7E
Firmware Revision: SAFM001B
Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
Supported: 9 8 7 6 5
Likely used: 9
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
.....
.....

後來發現可以使用 lsblk 這個指令來達到我們要的目的。可以用以下指令:

lsblk -o NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE,MODEL,SERIAL,STATE,VENDOR

順便將其他欄位也列出:

Available columns (for --output):
NAME device name
KNAME internal kernel device name
MAJ:MIN major:minor device number
FSTYPE filesystem type
MOUNTPOINT where the device is mounted
LABEL filesystem LABEL
UUID filesystem UUID
PARTTYPE partition type UUID
PARTLABEL partition LABEL
PARTUUID partition UUID
PARTFLAGS partition flags
RA read-ahead of the device
RO read-only device
RM removable device
HOTPLUG removable or hotplug device (usb, pcmcia, ...)
MODEL device identifier
SERIAL disk serial number
SIZE size of the device
STATE state of the device
OWNER user name
GROUP group name
MODE device node permissions
ALIGNMENT alignment offset
MIN-IO minimum I/O size
OPT-IO optimal I/O size
PHY-SEC physical sector size
LOG-SEC logical sector size
ROTA rotational device
SCHED I/O scheduler name
RQ-SIZE request queue size
TYPE device type
DISC-ALN discard alignment offset
DISC-GRAN discard granularity
DISC-MAX discard max bytes
DISC-ZERO discard zeroes data
WSAME write same max bytes
WWN unique storage identifier
RAND adds randomness
PKNAME internal parent kernel device name
HCTL Host:Channel:Target:Lun for SCSI
TRAN device transport type
SUBSYSTEMS de-duplicated chain of subsystems
REV device revision
VENDOR device vendor

有關於 M.2 SSD 資訊可以參考以下連結:

https://www.kingston.com/tw/ssd/ssd-faq

--

--

Richard Tsai
Richard Tsai

Written by Richard Tsai

人的大腦是用來思考, 解決問題, 不是拿來當記事本