linux серийный номер жесткого диска

Заметка по полезным утилитам Linux, которые могут расскрыть данные о железе.
Конкретно в этом случае, мне нужно было узнать серийные номера жестких дисков, установленных в серверах.

1. hdparm

Model=Hitachi HUA722020ALA330, FwRev=JKAOA3EA, SerialNo=JK11A8XXXXXX
Config=< HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs >
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=56
BuffType=DualPortCache, BuffSize=29999kB, MaxMultSect=16, MultSect=16

2. lshw

Эта утилита дает более общий вывод по всем шинам

description: ATA Disk
product: Hitachi HUA72202
vendor: Hitachi
physical id: 0.0.0
bus info: scsi@1:0.0.0
logical name: /dev/sdb
version: A3EA
serial: JK11A8XXXXXX
size: 1863GiB (2TB)
capabilities: partitioned partitioned:dos
configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512

3. smartctl

Smartctl из пакета smartmontools в основном применял для контроля здоровья HDD, получить серийный номер, можно так, вместо ключа -a, используется -x.

-x, —xall — Show all information for device

Model Family: Hitachi Ultrastar A7K2000
Device Model: Hitachi HUA722020ALA330
LU WWN Device Id: 5 000cca 221f48cb1
Firmware Version: JKAOA3EA
User Capacity: 2 000 398 934 016 bytes [2,00 TB]
Sector Size: 512 bytes logical/physical
Rotation Rate: 7200 rpm
Form Factor: 3.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA8-ACS T13/1699-D revision 4
SATA Version is: SATA 2.6, 3.0 Gb/s

Что бы узнать какой жесткий диск установлен в вашем сервере/ПК, его производителя и технические характеристики, воспользуемся следующими утилитами:

# smartctl -i /dev/sda

smartctl 5.43 2012-06-30 r3573 [i686-linux-3.5.3-pmagic] (local build)
Copyright (C) 2002-12 by Bruce Allen,
Model Family: Seagate Barracuda 7200.12
Device Model: ST3750528AS
Serial Number: 6VP9QAXZ
LU WWN Device Id: 5 000c50 030b008b0
Firmware Version: CC44
User Capacity: 750,156,374,016 bytes [750 GB]
Sector Size: 512 bytes logical/physical
Device is: In smartctl database [for details use: -P show]
ATA Version is: 8
ATA Standard is: ATA-8-ACS revision 4
Local Time is: Tue Feb 12 08:41:30 2013 UTC
SMART support is: Available — device has SMART capability.
SMART support is: Enabled

Требуется установленный набор утилит smartmontools и для диска должны быть разрешено выполнение операцция со SMART-контроллером. Подробнее — в статье S.M.A.R.T: проверка HDD — описание атрибутов, значение атрибутов, утилиты, параметры.

Другой способ — утилита hdparm , позволяющая получать информацию напрямую из ядра системы. Например:

# hdparm -I /dev/sda | less

ATA device, with non-removable media
Model Number: WDC WD5000AZRX-00A8LB0
Serial Number: WD-WMC1U8368164
Firmware Revision: 01.01A01
Transport: Serial, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0

device size with M = 1024*1024: 476940 MBytes
device size with M = 1000*1000: 500107 MBytes (500 GB)

Ещё один вариант — утилита lshw , используемая для получения информации о любой hardware -части машины. Что бы получить информацию непосредственно о HDD — добавьте такие ключи:

# lshw -class disk -class storage

description: ATA Disk
product: WDC WD5000AZRX-0
vendor: Western Digital
physical id: 0
bus info: scsi@2:0.0.0
logical name: /dev/sda
version: 01.0
serial: WD-WMC1U8368164
size: 465GiB (500GB)
capabilities: partitioned partitioned:dos
configuration: ansiversion=5 signature=00002851

I have multiple harddisks which get connected to my server and I’m not sure which one is what in the view of sdXY . If I can see the serial numbers of my harddisks from terminal, I can easily identify them.

Is there any way I can see them from terminal?

8 Answers 8

Another solution which does not require root privileges:

udevadm info —query=all —name=/dev/sda | grep ID_SERIAL

This is actually the library that lsblk , mentioned by don_crissti, leverages, but my version of lsblk does not include the option for serial.

In terminal type:

EDIT: You can also use lshw or smartctl

# lshw -class disk

# smartctl -i /dev/sda

If you are missing those tools, just install following packages

Device 1 name and corresponding serial number:

add -n if you don’t want to print the header line:

Pass device as argument to get only the serial number of a specific device:

Keep in mind lsblk lists information about all available (or the specified) block devices. Now, for those who do not know what that last term means:
In general, block devices are devices that store or hold data. Diskette drives, hard drives and CD-ROM drives are all block devices. But that’s not a problem when using lsblk as you can simply add more columns e.g type (device type) and/or tran (device transport type) etc:

By using hdparm you can see your Harddisk serial number from terminal.

Open your terminal and type as

This will show you the serial number against the familiar disk name.

Easiest way I know (does not require root):

That outputs all disks, their serials, and any extra info. -p adds partitions. -l adds labels. -u adds UUID for the partitions.

Plus it’s a lot easier to remember, heh.

Note that this filters out optical drives. To see optical data:

Note that on my Debian system, lsblk does not show anything for serials, whether as root or user. Which is why inxi uses a much more reliable method to get that data.

As you can see, to lsblk, it thinks that an optical drive and floppy drive are also disks, which in a sense they are, though not really, since they don’t become disks until a disk is inserted. And it shows nothing for serial, it also by the way shows nothing for other values, like label. Definitely a bug since this data is available to the system, that’s where inxi gets it, direct.

Оцените статью
Добавить комментарий