way to identify physical drives

Red Squirrel

No Lifer
May 24, 2003
70,166
13,573
126
www.anyf.ca
Is there a way in Linux to identify which drive is which?

Lets say I have 4 HDDs, so they're /dev/hda /dev/hdc etc... is there a way to get a list of each one along with their serial number? And if I unplug one and run the command then it would go missing? I somehow put a 300GB drive instead of a 500GB one in my raid5 group and I need to figure out which drive it is, I can't read what it says on it until I remove it, which is a huge task due to how this case is setup.

This would also be handy if I get a failed drive.
 

Praetor

Diamond Member
Oct 14, 1999
4,498
4
81
I know there is a different way, but this is the first method that comes to my mind.

Smartmon tools will display the info you're looking for. ie

=== START OF INFORMATION SECTION ===
Model Family: Seagate Barracuda 7200.10 family
Device Model: ST3250820AS
Serial Number: 6QE0R02K
Firmware Version: 3.AAE
User Capacity: 250,059,350,016 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Sat Mar 15 22:21:46 2008 CDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===

It's the first thing that popped in because I just re-configured the notifications the other day.
 

Red Squirrel

No Lifer
May 24, 2003
70,166
13,573
126
www.anyf.ca
Actually that would be nice, I'm guessing the serial is the same that would appear on the drive itself right? Thats really all I need. Of course I have to remove them to see the number but at least I'll know for next time so I can take down the serial beforehand.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
$fdisk -l

That will give you enough information to identify drives in most cases I would think. Here is the output from my bind9/squid server...

mambazo:~$ fdisk -l

Disk /dev/hda: 120.0 GB, 120060444672 bytes
255 heads, 63 sectors/track, 14596 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 851 6835626 83 Linux
/dev/hda2 852 14596 110406712+ 5 Extended
/dev/hda5 852 1181 2650693+ 82 Linux swap / Solaris
/dev/hda6 1182 14596 107755956 83 Linux

Disk /dev/hdb: 60.0 GB, 60022480896 bytes
255 heads, 63 sectors/track, 7297 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 1 7297 58613121 83 Linux

 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
That will give you enough information to identify drives in most cases I would think. Here is the output from my bind9/squid server...

Not if you've got several unpartitioned drives all of the same model and size.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Originally posted by: Nothinman
That will give you enough information to identify drives in most cases I would think. Here is the output from my bind9/squid server...

Not if you've got several unpartitioned drives all of the same model and size.

It gives the device id and the respective size. So I would say it gives everything the OP could possibly need. Just as long as the op knows hda = primary master, hdb = primary slave, hdc = secondary master, hdd = secondary slave. And even if he didn't, I guess he does now!
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
It gives the device id and the respective size. So I would say it gives everything the OP could possibly need. Just as long as the op knows hda = primary master, hdb = primary slave, hdc = secondary master, hdd = secondary slave. And even if he didn't, I guess he does now!

But with libata taking over PATA and currently doing SATA those names are irrelevant since everything goes through the SCSI layer and even without libata they're affected by module loading order if you have more than one PATA controller.
 

Red Squirrel

No Lifer
May 24, 2003
70,166
13,573
126
www.anyf.ca
I noticed that the hda names and such change sometimes. Like when I added my PCI IDE card, it switched everything around. what used to be hdd was hdg and so on.

The 1st one seems to be what I want. I figured the command was smartmon but that does not seem to exist, so what is the command for that output?
 

Praetor

Diamond Member
Oct 14, 1999
4,498
4
81
Originally posted by: RedSquirrel
I noticed that the hda names and such change sometimes. Like when I added my PCI IDE card, it switched everything around. what used to be hdd was hdg and so on.

The 1st one seems to be what I want. I figured the command was smartmon but that does not seem to exist, so what is the command for that output?

smartctl -i (/dev/sdX or /dev/hdX)
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I noticed that the hda names and such change sometimes. Like when I added my PCI IDE card, it switched everything around. what used to be hdd was hdg and so on.

Which is why you shouldn't rely on them. LVM, UUIDs, filesystem labels, etc are all better ways to identify disks.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Originally posted by: Nothinman
That will give you enough information to identify drives in most cases I would think. Here is the output from my bind9/squid server...

Not if you've got several unpartitioned drives all of the same model and size.

True!