When working with storage systems in Linux environments, developers frequently encounter the need to uniquely identify hard drives. The serial number appears to be the most straightforward identifier, but its actual uniqueness characteristics warrant closer examination.
Let's analyze the example from smartctl
output:
Serial number: 6SE1ZCSR0000B121LU63
This 20-character alphanumeric string follows manufacturer-specific patterns. For Seagate SAS drives, the first characters typically represent:
- First 2-3 digits: Manufacturer plant code
- Next 4-5 digits: Date/week of manufacture
- Remaining digits: Unique sequential number
Here's a Python script to check for duplicate serials in your system:
import subprocess
import re
def get_drive_serials():
result = subprocess.run(['lsblk', '-d', '-o', 'NAME'], stdout=subprocess.PIPE)
drives = [d for d in result.stdout.decode().split('\n') if d.startswith('sd')]
serials = {}
for drive in drives:
smart = subprocess.run(['smartctl', '-i', f'/dev/{drive}'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = smart.stdout.decode()
match = re.search(r'Serial Number:\s+(\S+)', output)
if match:
serial = match.group(1)
if serial in serials:
print(f"DUPLICATE FOUND: {serial} on {drive} and {serials[serial]}")
serials[serial] = drive
return serials
if __name__ == '__main__':
get_drive_serials()
Different vendors implement serial numbers differently:
Vendor | Format | Uniqueness Scope |
---|---|---|
Seagate | 20-22 alphanumeric | Global (claimed) |
Western Digital | 12-14 alphanumeric | Per model |
Samsung | 12-digit | Global (verified) |
Toshiba | 8-10 alphanumeric | Per production batch |
For absolute uniqueness guarantees, consider these Linux commands:
# Get WWN (World Wide Name) for Fibre Channel/SAS
sg_vpd -p di /dev/sdX | grep "Vendor identification"
# Get UUID for filesystems
blkid -o value -s UUID /dev/sdX1
When building storage management tools, consider:
- Always combine vendor+model+serial for reliable identification
- Implement fallback to WWN/UUID for critical applications
- Handle cases where serial numbers might be missing (virtual drives)
In SAN environments, the Serial Number might be insufficient due to:
- Storage array virtualization masking actual drive serials
- Multi-path configurations showing same drive multiple times
- Vendor-specific extensions to SCSI/SATA standards
When examining storage devices programmatically using tools like smartctl
, the serial number appears as a key identifier:
# smartctl -a /dev/sdb | grep "Serial number"
Serial number: 6SE1ZCSR0000B121LU63
Manufacturers implement serial number schemes differently:
- Enterprise drives: Typically use globally unique identifiers
- Consumer drives: May use model-specific numbering schemes
- OEM drives: Sometimes share numbering pools across vendors
To programmatically verify uniqueness across your infrastructure:
#!/bin/bash
# Scan all SATA/SAS devices and collect serials
declare -A serial_db
for dev in /dev/sd[a-z]; do
serial=$(smartctl -i "$dev" | awk '/Serial number:/ {print $3}')
if [[ -n "${serial_db[$serial]}" ]]; then
echo "Duplicate found: $serial on $dev and ${serial_db[$serial]}"
else
serial_db["$serial"]=$dev
fi
done
Analysis of common patterns:
Vendor | Format | Uniqueness Scope |
---|---|---|
Seagate | 6SE1ZCSR0000B121LU63 | Global |
Western Digital | WX31A1234567 | Per model/year |
Toshiba | Z12345A67890 | Global |
When building inventory systems:
# Python example for unique hardware identification
import subprocess
import re
def get_drive_ids():
drives = {}
output = subprocess.check_output(["smartctl", "--scan"])
for line in output.decode().split('\n'):
if '/dev/' in line:
dev = line.split()[0]
info = subprocess.check_output(["smartctl", "-i", dev])
serial = re.search(r'Serial Number:\s+(.*)', info.decode())
if serial:
drives[dev] = serial.group(1).strip()
return drives
Key resources for verification:
- Seagate SAS IO Specification Manual (Section 4.3.1)
- ANSI INCITS 513-2015 (SCSI Standards)
- NVMe Specification 1.4 (Unique Identifier requirements)