Listing all HDD serial numbers in your Linux computer is very important, this is easy with bash. Here is an example that gets this information. Use the 2>&1 parameter to redirect all errors to nothing. but this does work great.
┏jcartwright@jcartwright-System-Version╼╸╸╸╸╸╸╾
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━◉:~/Documents$ sudo hdparm -i /dev/sd* 2>&1 | grep Serial
Model=CT1000BX500SSD1, FwRev=M6CR054, SerialNo=2144E5E15CE3
Model=CT1000BX500SSD1, FwRev=M6CR054, SerialNo=2144E5E15CE3
Model=CT1000BX500SSD1, FwRev=M6CR054, SerialNo=2144E5E15CE3
Model=WDC WD10EZEX-00WN4A0, FwRev=01.01A01, SerialNo=WD-WMC6Y0H2UER3
Model=WDC WD10EZEX-00WN4A0, FwRev=01.01A01, SerialNo=WD-WMC6Y0H2UER3
Model=WDC WD10EZEX-00WN4A0, FwRev=01.01A01, SerialNo=WD-WMC6Y0H2UER3
Model=WDC WD10EZEX-00WN4A0, FwRev=01.01A01, SerialNo=WD-WMC6Y0H2UER3
Model=Fanxiang S101 512GB, FwRev=SN14546, SerialNo=MX_00000000000020321
Model=Fanxiang S101 512GB, FwRev=SN14546, SerialNo=MX_00000000000020321
Model=Fanxiang S101 512GB, FwRev=SN14546, SerialNo=MX_00000000000020321
And this is how to get just the serial numbers of your drives.
┏jcartwright@jcartwright-System-Version╼╸╸╸╸╸╸╾
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━◉:~/Documents$ sudo hdparm -i /dev/sd* 2>&1 | grep Serial | awk -F '=' '/SerialNo=/ {print $NF}'
2144E5E15CE3
2144E5E15CE3
2144E5E15CE3
WD-WMC6Y0H2UER3
WD-WMC6Y0H2UER3
WD-WMC6Y0H2UER3
WD-WMC6Y0H2UER3
MX_00000000000020321
MX_00000000000020321
MX_00000000000020321
This is a very useful Linux tip.
The only drive I could not read was the 2 Terabyte external drive I am using, I got this error.
┏jcartwright@jcartwright-System-Version╼╸╸╸╸╸╸╾
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━◉:~/Documents$ sudo fdisk -l /dev/sdd
Disk /dev/sdd: 2.73 TiB, 3000592981504 bytes, 5860533167 sectors
Disk model: Expansion Desk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 7323E864-207D-4B99-882A-01349863DDAC
Device Start End Sectors Size Type
/dev/sdd1 34 262177 262144 128M Microsoft reserved
/dev/sdd2 264192 5860532223 5860268032 2.7T Microsoft basic data
Partition 1 does not start on physical sector boundary.
But all of the other drives inside my computer were accessible to read the serial numbers, the external drive uses Microsoft NTFS and is partitioned strangely.