LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 06-10-2002, 02:09 PM   #1
daver
LQ Newbie
 
Registered: Jun 2002
Posts: 2

Rep: Reputation: 0
Hard Drive Serial Number?


Is there a command in linux that will give the hard drive serial number? (hopefully this is a non-specific distribution command....)

Sorry for the simplicity of this question.... Linux Newbie.....
 
Old 06-10-2002, 02:17 PM   #2
Glockage
Member
 
Registered: Jan 2002
Distribution: Slackware 12.1
Posts: 40

Rep: Reputation: 15
If you have DOS on your machine, you can type "dir" in and it will list the serial number of the current drive and the conternets of the directory you are in, but for doing it in Linux, I could'nt tell you .
 
Old 06-10-2002, 02:43 PM   #3
daver
LQ Newbie
 
Registered: Jun 2002
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks, but, I knew the DOS command..... looking for Linux and Mac now....
 
Old 06-10-2002, 03:21 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well the serial number is presumably in /proc/ide/hdX/identify, as to a foraml way to get the data i don't know.

you can also get a decent more usable output from "hdparm -i /dev/hda":

Code:
[root@trevor chris]# hdparm -i /dev/hda

/dev/hda:

 Model=Maxtor 32049H2, FwRev=YAH814Y0, SerialNo=L22H2Q4C
 Config={ Fixed }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=57
 BuffType=DualPortCache, BuffSize=2048kB, MaxMultSect=16, MultSect=16
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=40021632
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes: pio0 pio1 pio2 pio3 pio4 
 DMA modes: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5 
 AdvancedPM=yes: disabled (255) WriteCache=enabled
 Drive Supports : ATA/ATAPI-6 T13 1410D revision 0 : ATA-1 ATA-2 ATA-3 ATA-4 ATA-5 ATA-6
 
Old 03-17-2004, 09:57 AM   #5
icwiener
LQ Newbie
 
Registered: Mar 2004
Location: Seoul
Distribution: k0NkreTix
Posts: 3

Rep: Reputation: 0
Have a look at the kernel header file "hdreg.h". There you can find a struct called "hd_driveid". It looks like this:
Code:
struct hd_driveid {
  unsigned short  config;         /* lots of obsolete bit flags */
          ...
  unsigned char   serial_no[20];  /* 0 = not_specified */
          ...
}
The output of /proc/ide/ideN/hdX look like this:
Quote:
045a 3fff c837 0010 8856 022a 003f ffff
0000 0000 5330 3147 4a31 3057 3430 3133
3436 2020 2020 2020 0003 1000 0004 5344
...
With perl you can extract this as following:
Code:
[root@k0Nkr3Tix /proc/ide/ide3/hdh]#
cat identify | perl -e '<>;($tmp = substr(<>,10,29).substr(<>,0,20) ) =~ s/\ //g;print chr(hex $_) foreach (unpack("a2" x 20,$tmp))'

# output : S01GJ10W401346

Last edited by icwiener; 03-17-2004 at 10:01 AM.
 
  


Reply



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
Nero 2.0.0.3 serial number TigerLinux Linux - Software 13 10-20-2005 03:13 AM
Serial ATA Hard Drive Configuration decious Linux - Hardware 2 09-10-2005 08:21 PM
command to show the hard drive serial #? AoiSora Linux - Newbie 1 02-17-2004 10:01 AM
USB hard drive rejects dev number mad2physicist Linux - Hardware 16 12-15-2003 12:11 PM
Floppy serial number k__ Linux - General 1 06-29-2002 10:29 PM

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

All times are GMT -5. The time now is 01:37 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
Open Source Consulting | Domain Registration