- Узнать серийный номер HDD при помощи утилит Linux
- linux-notes.org
- Как узнать информацию о жестких дисках (серийный номер, модель, интерфейс).
- Linux: Find out serial / model number and vendor information for SATA and IDE hard disk
- Getting hard disk model and number under Linux
- scsi_id command examples
- sdparm command
- border / get_sn.c
- Getting hard disk drive serial number at the terminal — not the WWN [duplicate]
- Seagate Constellation ES, model ST3500514NS, a 500 GB 3.5″ SATA drive
- WD model WD4001FFSX, a 4 TB SATA drive
- HGST, model HUC109060CSS600, a 300 GB 2.5″ SAS drive
Узнать серийный номер HDD при помощи утилит Linux
Заметка по полезным утилитам Linux, которые могут раскрыть данные о железе. Конкретно в этом случае, мне нужно было узнать серийные номера жестких дисков, установленных в серверах.
1. hdparm
# hdparm -i /dev/sda
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
Эта утилита дает более общий вывод по всем шинам
*-disk
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
# smartctl -x /dev/sda
=== START OF INFORMATION SECTION ===
Model Family: Hitachi Ultrastar A7K2000
Device Model: Hitachi HUA722020ALA330
Serial Number: JK11A8XXXXXXJK11A8XXXXXX
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
Источник
linux-notes.org
Как узнать информацию о жестких дисках (серийный номер, модель, интерфейс).
В теме «Как узнать информацию о жестких дисках (серийный номер, модель, интерфейс)» я расскажу как можно узнать серийный номер, модель или интерфейс вашего устройства на жестком диске. Существует довольно много решений, приведу несколько.
Первое что я сделаю, так это посмотрю какие у меня разделы имеются:
вывод имеющихся разделов программой lsblk
1. Первую утилиту что я могу порекомендовать Вам — это утилита hdparm.
Если вы используете RedHat/Centos/Fedora:
Если вы используете Debian/Ubuntu/Linux Mint для установки программы:
Чтобы использовать эту утилиту нужно запустить ее с опцией «-i» и добавить нужный нам раздел:
пример использования hdparm с ключем -i для раздела sdf
2. Советую так же утилиту lshw.
Эта программа показывает информацию не только о HDD, так же она выводит в удобно для вас формате (TXT-формате, HTML или XML).
Чтобы установить ее на CentOS/RedHat/Fedora, но если не стоит у вас эта программа, нужно выполнить:
Чтобы установить ее на Ubuntu/Linux Mint или Debian:
Чтобы получить нужную информацию с помощью утилиты lshw, выполните:
пример использования lshw -class disk -class storage
Если вам нужно вывести информацию только об установленных дисках на вашей ОС, вы можете использовать:
пример использования команды lshw -short -C disk
3. Что еще за утилиту могу посоветовать для использования — так это smartctl.
При помощи программы smartctl можно выводить информацию о состоянии ваших устройств, которые поддерживают SMART. Вот пример использования команды для SATA-устройства:
Я использую просто вот так:
4. Напоследок, приведу я графическую утилиту — GNOME Disk Utility.
Чтобы установить ее для использования в Debian/Ubuntu/ Linux Mint, выполните:
Если используете Fedora/CentOS или RedHat, то выполните:
Утилита эта удобна тем, что у нее есть графический интерфейс (GUI), после установки вы можете ее запустить через командную строку ( а можно и найти ее в меню):
Очень проста в использовании и очень простая.
Источник
Linux: Find out serial / model number and vendor information for SATA and IDE hard disk
H ow do I find out the make, model and serial number for my SCSI or IDE hard disks under CentOS Linux server? How do I get vendor information about my disk storage w/o opening my Intel / AMD server chassis?
You need to use the hdparm command. It provides a command line interface to various hard disk ioctls supported by the stock Linux ATA/IDE/SATA device driver subsystem i.e. get BIOS information from hard disk.
Getting hard disk model and number under Linux
Try command as follows for /dev/sda (SATA). You need to pass -i or -I option which request identification info directly from the drive, which is displayed in a new expanded format:
# hdparm -I /dev/sda
# hdparm -I /dev/sda | grep Serial
OR for IDE /dev/hda
# hdparm -i /dev/hda
OR
# hdparm -I /dev/hda
Sample outputs:
scsi_id command examples
For SCSI attached disk use scsi_id command which queries a SCSI device via the SCSI INQUIRY vital product data (VPD) page 0x80 or 0x83 and uses the resulting data to generate a value that is unique across all SCSI devices that properly support page 0x80 or page 0x83.
# scsi_id -s /block/sda
# scsi_id -a -s /block/sda
# scsi_id -gus /block/sda
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
- -s : Generate an id for the sysfs-device
- -a : Always print information (model, vendor strings) about the device even if it does not support VPD pages.
- -g : Treat the device as white listed. The -g option must be specified on the command line or in the scsi_id configuration file for scsi_id to gener ate any output
- -u : Reformat the output : replace all whitespaces by underscores.
sdparm command
The sdparm command can be used to access SCSI modes pages; read VPD pages; send simple SCSI commands. It can provide all information:
# sdparm -a /dev/sda
# sdparm —vendor sea /dev/sda
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
border / get_sn.c
# include unistd.h > |
# include fcntl.h > |
# include stdio.h > |
# include string.h > |
# include errno.h > |
# include sys/ioctl.h > |
# include scsi/sg.h > |
# define SCSI_TIMEOUT 5000 /* ms */ |
static char *device = » /dev/sda » ; |
int scsi_io ( int fd, unsigned char *cdb, unsigned char cdb_size, int xfer_dir, |
unsigned char *data, unsigned int *data_size, |
unsigned char *sense, unsigned int *sense_len) |
< |
sg_io_hdr_t io_hdr; |
memset (&io_hdr, 0 , sizeof ( sg_io_hdr_t )); |
io_hdr. interface_id = ‘ S ‘ ; |
/* CDB */ |
io_hdr. cmdp = cdb; |
io_hdr. cmd_len = cdb_size; |
/* Where to store the sense_data, if there was an error */ |
io_hdr. sbp = sense; |
io_hdr. mx_sb_len = *sense_len; |
*sense_len= 0 ; |
/* Transfer direction, either in or out. Linux does not yet |
support bidirectional SCSI transfers ? |
*/ |
io_hdr. dxfer_direction = xfer_dir; |
/* Where to store the DATA IN/OUT from the device and how big the |
buffer is |
*/ |
io_hdr. dxferp = data; |
io_hdr. dxfer_len = *data_size; |
/* SCSI timeout in ms */ |
io_hdr. timeout = SCSI_TIMEOUT; |
if ( ioctl (fd, SG_IO, &io_hdr) 0 ) < |
perror ( » SG_IO ioctl failed » ); |
return — 1 ; |
> |
/* now for the error processing */ |
if ((io_hdr. info & SG_INFO_OK_MASK) != SG_INFO_OK) < |
if (io_hdr. sb_len_wr > 0 ) < |
*sense_len=io_hdr. sb_len_wr ; |
return 0 ; |
> |
> |
if (io_hdr. masked_status ) < |
printf ( » status=0x %x \n » , io_hdr. status ); |
printf ( » masked_status=0x %x \n » , io_hdr. masked_status ); |
return — 2 ; |
> |
if (io_hdr. host_status ) < |
printf ( » host_status=0x %x \n » , io_hdr. host_status ); |
return — 3 ; |
> |
if (io_hdr. driver_status ) < |
printf ( » driver_status=0x %x \n » , io_hdr. driver_status ); |
return — 4 ; |
> |
return 0 ; |
> |
int scsi_inquiry_unit_serial_number ( int fd) |
< |
unsigned char cdb[]=< 0x12 , 0x01 , 0x80 , 0 , 0 , 0 >; |
unsigned int data_size= 0x00ff ; |
unsigned char data[data_size]; |
unsigned int sense_len= 32 ; |
unsigned char sense[sense_len]; |
int res, pl, i; |
cdb[ 3 ]=(data_size>> 8 )& 0xff ; |
cdb[ 4 ]=data_size& 0xff ; |
printf ( » INQUIRY Unit Serial Number: \n » ); |
res= scsi_io (fd, cdb, sizeof (cdb), SG_DXFER_FROM_DEV, data, &data_size, sense, &sense_len); |
if (res) < |
printf ( » SCSI_IO failed \n » ); |
return — 1 ; |
> |
if (sense_len) < |
return — 1 ; |
> |
/* Page Length */ |
pl=data[ 3 ]; |
/* Unit Serial Number */ |
printf ( » Unit Serial Number: » ); |
for (i= 4 ;i 4 );i++) printf ( » %c » ,data[i]& 0xff ); printf ( » \n » ); |
return 0 ; |
> |
int open_scsi_device ( const char *dev) |
< |
int fd, vers; |
if ((fd= open (dev, O_RDWR)) 0 ) < |
printf ( » ERROR could not open device %s \n » , dev); |
return — 1 ; |
> |
if (( ioctl (fd, SG_GET_VERSION_NUM, &vers) 0 ) || (vers 30000 )) < |
printf ( » /dev is not an sg device, or old sg driver \n » ); |
close (fd); |
return — 1 ; |
> |
return fd; |
> |
int main ( int argc, const char *argv[]) |
< |
int fd; |
if (argc > 1 ) < |
device=argv[ 1 ]; |
> |
fd= open_scsi_device (device); |
if (fd 0 ) < |
printf ( » Could not open SCSI device %s \n » ,device); |
_exit ( 10 ); |
> |
scsi_inquiry_unit_serial_number (fd); |
return 0 ; |
> |
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
Getting hard disk drive serial number at the terminal — not the WWN [duplicate]
WWN = world wide name
Seagate Constellation ES, model ST3500514NS, a 500 GB 3.5″ SATA drive
It has «serial number», 9WJxxxxx which is eight characters. It has WWN 5000C5002E47xxxx which is a 16 characters. Both are printed on the label on the hard disk drive.
WD model WD4001FFSX, a 4 TB SATA drive
It has «serial number» WMC5D0Dxxxxx which is 12 characters. It has WWN 50014EE003Fxxxxx which is 16 characters.
HGST, model HUC109060CSS600, a 300 GB 2.5″ SAS drive
It has «serial number» KWJTxxx, also eight characters. It has WWN. I don’t know; it is not printed on the label and not plugged into the system to find out.
For inventory, we generally write down and track the following, which can always be gathered from the label on the drive:
- Manufacturer
- Model number
- Serial number
- Size in GB or TB, and connection type which is either SATA or SAS
- Location where in use, or in storage when not in use
The problem arises obviously 1, 2, 3 years later when an inventory sheet shows whatever hard drive. You are pretty sure it’s in a running server, but you don’t want to shut down the server to pull the hard drive to read the label.
How do you get the serial number of the drive that corresponds to what is on the label?
udevadm info —query=all —name=/dev/sda has ID_SERIAL, but that is the WWN. We don’t want another field to track the 16 characters of the WWN as an identifier. And I already hate writing down the long serial numbers of WD drives.
Is there a way in Linux to extract the serial number of the drive?
I believe it is possible because years ago the RAID storage manager GUI we had been using nicely reported the eight-character serial numbers of Seagate drives that were in use. And that RAID hardware has listed a bunch of Seagate-specific hard disk drives that were «officially supported», and if memory serves, really no other make/model of drives.
Is it possible this is hard disk drive firmware related, meaning it can be done on certain make drives and not others?
Источник