how to get HDD and SSD serial number in linux using command line
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
-I Request identification info directly from the drive, which is displayed in a new expanded format with considerably more detail than with the older -i option.
By using the 'I' option you can get the desired information.
Code:
hdparm -I /dev/sda
/dev/sda:
ATA device, with non-removable media
Model Number: OCZ-AGILITY3
Serial Number: OCZ-C93VFN4X0532CVMP
Firmware Revision: 2.22
...detailed information <snipped>
The first snipped line posted by onebuck is the Transport Layer (S)ATA or SSD or whatever.
sdparm -I /dev/sda | egrep -i 'model|transport:'
The option as stated for 'hdparm' is;
Quote:
-I Request identification info directly from the drive, which is displayed in a new expanded format with considerably more detail than with the older -i flag.
I snipped the transport data since the OP wanted just the model & serial;
Quote:
/dev/sda:
ATA device, with non-removable media
Model Number: OCZ-AGILITY3
Serial Number: OCZ-C93VFN4X0532CVMP
Firmware Revision: 2.22
Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Correct me if I am wrong but 'sdparm' supports the '-i' option for a inquiry;
that is off of an SSD drive.
this is bash, or command line so...
taking the information and seeing my HDD says sdd within it I use substring finding to see if it is in fact a ssd or not.
Code:
$ udevadm info --query=all --name=/dev/sda | grep "ID_MODEL"
E: ID_MODEL=Samsung_SSD_850_EVO_250GB
E: ID_MODEL_ENC=Samsung\x20SSD\x20850\x20EVO\x20250GB\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
//Now I set my test for "SSD"
$ [[ $(udevadm info --query=all --name=/dev/sda | grep "ID_MODEL" | awk 'FNR == 1 {print $2}') =~ "SSD" ]] && echo "is ssd"
is ssd
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.