How to check serial number of NVMe disk?
To check serial number for sda and sdb I used:
sudo lsblk --raw -o name,type,serial
However it does not work for NVMe disks (nvme0n0, nvme0n1 etc). No information about serial number is provided.
How to check serial number of NVMe disk?
To check serial number for sda and sdb I used:
sudo lsblk --raw -o name,type,serial
However it does not work for NVMe disks (nvme0n0, nvme0n1 etc). No information about serial number is provided.
The nvme tool provides options to obtain NVME device information, for example, to install the tool, list the NVME devices and look at the id control fields on /dev/nvme0n1, one would use:
sudo apt-get install nvme-cli
sudo nvme list
sudo nvme id-ctrl /dev/nvme0n1
You can use good old sysfs and cat for that:
$ cat /sys/block/nvme0n1/device/serial
PHNH912345441P0B
Also as @VZ pointed out modern versions of lsblk will output serial numbers for NVMe drives correctly.
Example:
$ lsblk -d -o TRAN,NAME,TYPE,MODEL,SERIAL,SIZE
TRAN NAME TYPE MODEL SERIAL SIZE
mmcblk0 disk 0xda61bcdf 14.6G
mmcblk0boot0 disk 0xda61bcdf 4M
mmcblk0boot1 disk 0xda61bcdf 4M
nvme nvme0n1 disk INTEL SSDPEKNW010T8 PHNH912345441P0B 953.9G
Note that there are two kinds of M.2 drives - the NVMe and the SATA - and they present completely different interfaces.
This is as evidenced by the completely different dev device name: /dev/sd? for SATA, and /dev/nvme0n1 for NVMe.
If you download smartmontools 6.6, it has experimental NVMe support built in and can show serial number as I remember. (smartctl -a, again IIRC).
Otherwise, for NVMe drives you indeed need the nvme-cli tools to be able to do anything more than smartctl can do.
another way to get drive information is to run hdparm
sudo hdparm -i /dev/sda /dev/sdb
That will give you info on both your disks
FWIW , my laptop has a built in LITEONIT LMT-512L9M-11 MSATA 512GB which does report its serial number via your command and mine. It maybe that your disk doesn't actually return it or that its newness means not enough linux developers have access to them.