When provisioning new servers, especially from third-party providers, verifying hardware authenticity is crucial. Many hosting companies reuse older drives to cut costs, which can impact performance and reliability. The smartctl utility provides direct access to drive manufacturing data through SMART attributes.
First ensure smartmontools is installed:
# Debian/Ubuntu
sudo apt install smartmontools
# RHEL/CentOS
sudo yum install smartmontools
For drives that support the ATA IDENTIFY command:
sudo smartctl -i /dev/sdX | grep -i "date"
This typically returns output like:
Model Family: Western Digital RE4 Serial ATA
Device Model: WDC WD1502FAEX-007BA0
Serial Number: WD-WMAWZ0087178
LU WWN Device Id: 5 0014ee 0045678d0
Firmware Version: 05.01D05
User Capacity: 1,500,301,910,016 bytes [1.50 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 7200 rpm
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA8-ACS (minor revision not indicated)
SATA Version is: SATA 2.6, 3.0 Gb/s
Local Time is: Thu Sep 14 15:32:45 2023 UTC
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Date of Manufacture: Week 24 of 2012
When manufacture date isn't directly available, calculate from power-on hours:
sudo smartctl -A /dev/sdX | grep Power_On_Hours
Then use the manufacturer's MTBF rating to estimate age. For example:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
9 Power_On_Hours 0x0032 085 085 000 Old_age Always - 12540
12,540 hours equals approximately 1.43 years of continuous operation.
For comprehensive drive health and age analysis:
sudo smartctl -x /dev/sdX
Key fields to examine:
- Power_Cycle_Count
- Start_Stop_Count
- Total_LBAs_Written
- Media_Wearout_Indicator
Create a bash script for batch processing:
#!/bin/bash
for drive in /dev/sd?; do
echo "Checking $drive..."
manuf_date=$(sudo smartctl -i $drive | grep -i "date" | cut -d':' -f2)
power_hours=$(sudo smartctl -A $drive | grep Power_On_Hours | awk '{print $10}')
echo "Manufacture Date:$manuf_date"
echo "Power On Hours: $power_hours"
echo "--------------------------"
done
Manufacturers use different encoding:
- Western Digital: "Week YY of YYYY"
- Seagate: Julian date codes (YYDDD)
- Hitachi: "YYYY-MM-DD" format
For Seagate drives, convert with:
date -d "2020-01-01 + $((julian_code - 1)) days" +"%Y-%m-%d"
If the drive doesn't support SMART or returns invalid data:
- Check physical drive labels (requires physical access)
- Query vendor APIs using serial numbers
- Use alternative tools like hdparm or sg_logs
When provisioning servers from third-party providers, you might encounter used hard drives with unknown usage history. The smartctl
utility from the smartmontools
package provides valuable insights into drive health and age.
The most reliable indicators of drive age are:
- Power_On_Hours: Total active hours
- Power_Cycle_Count: Number of power cycles
- Start_Stop_Count: Spin-up/down cycles
- Manufacture_Date: Available on some drives
First, identify your drives:
lsblk
sudo fdisk -l
Then check SMART data (replace /dev/sdX with your device):
sudo smartctl -i /dev/sdX
sudo smartctl -A /dev/sdX
sudo smartctl -x /dev/sdX
For a quick age estimate:
sudo smartctl -a /dev/sdX | grep -E "Power_On_Hours|Power_Cycle_Count|Start_Stop_Count|Manufacture"
Example output parsing script:
#!/bin/bash
DRIVE="/dev/sda"
HOURS=$(sudo smartctl -A $DRIVE | grep Power_On_Hours | awk '{print $10}')
CYCLES=$(sudo smartctl -A $DRIVE | grep Power_Cycle_Count | awk '{print $10}')
MFG_DATE=$(sudo smartctl -i $DRIVE | grep "Date" | head -1 | awk '{print $NF}')
echo "Drive: $DRIVE"
echo "Manufacture Date: $MFG_DATE"
echo "Power On Hours: $HOURS ("$(($HOURS/24))" days)"
echo "Power Cycles: $CYCLES"
For comprehensive drive health assessment:
sudo smartctl --health /dev/sdX
sudo smartctl --test=short /dev/sdX
sudo smartctl --log=selftest /dev/sdX
Create a cron job to log drive statistics:
0 * * * * /usr/sbin/smartctl -A /dev/sdX | grep -E "Power_On_Hours" >> /var/log/drive_age.log
Typical enterprise HDD lifespan:
- Consumer drives: 20,000-30,000 hours
- Enterprise drives: 50,000+ hours
- High cycles (>50,000) indicate heavy usage
Some vendors provide additional data:
# For Seagate drives:
sudo smartctl -v 7,raw48:54 -v 8,raw48:54 /dev/sdX
# For Western Digital:
sudo smartctl -v 0x24 -v 0x25 /dev/sdX