The Linux disk names (e.g. sda1, hdb3, etc.) are not reliable—they may be changed if there are hardware changes, such an adding or removing a disk. Additionally, the order for the Linux device names is not always the same as the order of SATA poets. For example, the disk connected to SATA port 0 (first port) is not always sda.
It is possibly that you are in a situation like this:
I find one disk failed on my server which have several ones installed. I know the disk’s name in Linux (e.g. sda, sdb). However, the Linux disk name to SATA port mapping does not follow the same order. Now, I want to find out the failed disks. How to quickly find out them and which SATA port are these failed disks connected to?
Map the Linux disk names to serial numbers
Table of Contents
Fortunately, there are other names/IDs that we can make use of to identify a failed disk in Linux. The device serial ID is unique for all disks and we can find out the failed disks by their serial numbers.
On Linux, to find a disk’s serial number, we can run this command.
# hdparm -i /dev/sdb | grep Serial
Here, we use sdb as the example.
One example output is like this:
Model=ST31000528AS, FwRev=CC38, SerialNo=5VP5DYYY
(the last 3 digits are anonymized).
hdparm is not installed, you need to first install it:
# yum install hdparm
By this method, we can easily map the Linux disk names to serial numbers.
Find the failed disks by their serial numbers
After opening the server box, we can easily find out the failed disks according to their serial numbers. The manufacturers usually print the disks’ serial numbers on the disk label.
Bonus: mounting disk partitions NOT by its device name
For the similar reason, it is a good idea to identify disk or disk partitions by their UUIDs instead of Linux device names to avoid situations that Linux can not find the disks. Two examples are the configuration in grub’s config file and the
/etc/fstab for automatic disk partition mounting. The format as follow can be understood by most of the tools in Linux:
YYYYY is the UUID for the disk.
All disks’ UUIDs can be listed by: