LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 05-14-2014, 12:11 AM   #1
sundanat
LQ Newbie
 
Registered: May 2014
Posts: 5

Rep: Reputation: Disabled
how to get HDD and SSD serial number in linux using command line


Hi,

I need to calculate an algorithm using linux HDD or SSD serial number.

How can i get HDD or SSD serial number in linux?

Thanks,
Sundar.N
 
Old 05-14-2014, 12:56 AM   #2
rhoekstra
Member
 
Registered: Aug 2004
Location: The Netherlands
Distribution: RedHat 2, 3, 4, 5, Fedora, SuSE, Gentoo
Posts: 372

Rep: Reputation: 42
Smartctl -i /dev/sda
 
Old 05-14-2014, 01:11 AM   #3
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,568

Rep: Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349
or you could try using the output of "hdparm -i /dev/sda".

Last edited by 273; 05-14-2014 at 01:35 AM. Reason: Typo, it's hdparm
 
Old 05-14-2014, 01:27 AM   #4
sundanat
LQ Newbie
 
Registered: May 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks rhoekstra.

One more question, how can i find whether my linux machine using SSD or HDD?

Thanks,
sundar.N
 
Old 05-14-2014, 02:48 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,337

Rep: Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627
there is no direct way I think, but you can get the device model and look for information on the net about that device.
 
Old 05-14-2014, 05:27 AM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Summer Midwest USA, Central Illinois, Winter Central Florida
Distribution: Slackware«
Posts: 13,541
Blog Entries: 33

Rep: Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722
Member Response

Hi,

man hdparm;
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 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>
 
Old 05-14-2014, 06:19 AM   #7
gengisdave
Member
 
Registered: Dec 2013
Location: Turin, Italy
Distribution: slackware
Posts: 328

Rep: Reputation: 74
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:'
 
Old 05-18-2014, 08:53 AM   #8
onebuck
Moderator
 
Registered: Jan 2005
Location: Summer Midwest USA, Central Illinois, Winter Central Florida
Distribution: Slackware«
Posts: 13,541
Blog Entries: 33

Rep: Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722Reputation: 2722
Member Response

Hi,

Quote:
Originally Posted by gengisdave View Post
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;
Quote:
hdparm -i /dev/sda
/dev/sda:

Model=OCZ-AGILITY3, FwRev=2.22, SerialNo=OCZ-C93VFN4X0532CVMP<snip>
I do not think that 'I' is a valid option for 'sdparm'.
 
Old 05-18-2014, 05:52 PM   #9
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian
Posts: 1,054

Rep: Reputation: 281Reputation: 281Reputation: 281
You can check the rotation rate to see whether it's an SSD or HDD.
 
1 members found this post helpful.
Old 05-20-2014, 05:55 AM   #10
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.2
Posts: 7,809
Blog Entries: 58

Rep: Reputation: Disabled
lshw is another way:
Code:
       *-disk
             description: ATA Disk
             product: SAMSUNG HD161HJ
             physical id: 0.0.0
             bus info: scsi@0:0.0.0
             logical name: /dev/sda
             version: JF10
             serial: S0V3J90S146109
             size: 149GiB (160GB)
             capabilities: partitioned partitioned:dos
             configuration: ansiversion=5 sectorsize=512 signature=00073592
 
Old 03-09-2018, 03:39 PM   #11
bluegroper
LQ Newbie
 
Registered: Jul 2003
Posts: 4

Rep: Reputation: 0
Quote:
Originally Posted by sgosnell View Post
You can check the rotation rate to see whether it's an SSD or HDD.
Great answer. +1

Last edited by bluegroper; 03-09-2018 at 03:40 PM.
 
Old 03-09-2018, 03:55 PM   #12
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,943

Rep: Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141
Code:
udevadm info --query=all --name=/dev/sda
gets you a list of everything then pick what you're looking for then grep it.
Code:
$ udevadm info --query=all --name=/dev/sda | grep ID_SERIAL_SHORT
E: ID_SERIAL_SHORT=S22SNXAG928927N
then if you need to chop that leading part off.
Code:
$ udevadm info --query=all --name=/dev/sda | grep ID_SERIAL_SHORT | tr -d "ID_SERIAL_SHORT=:"
 22NXG928927N
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

Last edited by BW-userx; 03-09-2018 at 04:03 PM.
 
Old 03-09-2018, 04:18 PM   #13
jefro
Moderator
 
Registered: Mar 2008
Posts: 19,852

Rep: Reputation: 3086Reputation: 3086Reputation: 3086Reputation: 3086Reputation: 3086Reputation: 3086Reputation: 3086Reputation: 3086Reputation: 3086Reputation: 3086Reputation: 3086
Original post 2014.
 
Old 03-09-2018, 04:20 PM   #14
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,943

Rep: Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141
Oh I c Who reviled it
bluegroper
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command to get Serial Number Thalha Rahim Solaris / OpenSolaris 5 02-20-2018 10:28 AM
Linux HDD serial number from logical drive names sda sdb etc Avirup Linux - Software 3 08-19-2011 04:27 PM
[SOLVED] How to find out the serial number of my hard disk through command line on OpenSuse 11.2 ? TheIndependentAquarius Linux - Newbie 20 07-12-2010 06:36 AM
command to get the serial number of linux box bhatpp Linux - Newbie 4 09-19-2007 10:45 AM
Reading the HDD serial number DJFau▀ Linux - Hardware 1 06-06-2002 01:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 11:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration