When dealing with aging enterprise drives like the Seagate Barracuda ES.2, a high reallocated sector count (1955 in your case) is a clear warning sign. The RAW_VALUE in SMART attribute #5 (Reallocated_Sector_Ct) represents the actual number of sectors the drive has remapped to its spare area.
# Sample SMART attribute showing critical values
5 Reallocated_Sector_Ct 0x0033 005 005 036 Pre-fail Always FAILING_NOW 1955
197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always - 21
198 Offline_Uncorrectable 0x0010 100 100 000 Old_age Offline - 21
The reason badblocks
returns empty results is that modern drives automatically remap bad sectors internally. The OS only sees the remapped LBA addresses, not the physical bad blocks. To get the actual mapping information, we need vendor-specific tools.
For Seagate drives, you can use smartctl
with extended options:
# First install smartmontools if needed
sudo apt-get install smartmontools
# Get detailed defect list
sudo smartctl -l defect /dev/sdX
# Alternative method for sector mapping
sudo smartctl -x /dev/sdX | grep -A 50 "Grown defects list"
If these commands don't return the defect list, try the Seagate SeaTools utility in DOS mode, which can access low-level drive information.
Once you have the sector list, calculate the affected zones. Here's a Python example to generate a partition scheme:
import math
def calculate_safe_partitions(defect_list, total_sectors):
# Sort defects and find clusters
defect_list.sort()
danger_zones = []
current_start = defect_list[0]
for i in range(1, len(defect_list)):
if defect_list[i] - defect_list[i-1] > 10000: # 5MB gap considered safe
danger_zones.append((current_start, defect_list[i-1]))
current_start = defect_list[i]
# Generate fdisk commands
commands = []
last_end = 2048 # start after GPT/MBR
for start, end in danger_zones:
if start - last_end > 2048: # minimum partition size
commands.append(f"n\n\n\n+{math.ceil((start - last_end)/2/1024)}M")
commands.append(f"n\n\n\n+{math.ceil((end - start + 10000)/2/1024)}M\np")
last_end = end + 10000
return "".join(commands)
If you can't get the exact defect list, consider using a filesystem that can handle bad sectors gracefully:
# Create XFS with special options
sudo mkfs.xfs -l lazy-count=1,size=16384b -m crc=0 /dev/sdX1
# Or for ext4 with bad blocks check
sudo mkfs.ext4 -c -c /dev/sdX1
Create a cron job to monitor the drive's condition:
#!/bin/bash
THRESHOLD=10 # Percentage increase in bad sectors
current=$(smartctl -A /dev/sdX | grep "Reallocated_Sector_Ct" | awk '{print $10}')
last=$(cat /var/log/smartd/sdX_last_count.log)
increase=$(( (current - last) * 100 / last ))
if [ $increase -gt $THRESHOLD ]; then
echo "Warning: Rapid degradation detected" | mail -s "Drive Alert" admin@example.com
fi
echo $current > /var/log/smartd/sdX_last_count.log
These partially failed drives can still be useful for:
- Temporary build servers
- Download caches
- Non-critical logging
- Scratch space for compression/encoding
- Testing destructive operations
When your Seagate Barracuda ES.2 (ST31000340NS) shows 1955 reallocated sectors in SMART data (ID#5), with 21 pending sectors (ID#197) and failing status, you're dealing with a drive that's actively remapping bad blocks. While conventional wisdom says to replace it immediately, enterprise environments with regular drive failures might benefit from temporary repurposing.
The key challenge is that badblocks -v /dev/sdX
won't show reallocated sectors because:
- They've already been remapped by the drive's firmware
- The OS only sees the logical block addresses, not physical sectors
- Pending sectors (ID#197) may not yet be visible to the OS
Use smartctl
with vendor-specific commands:
sudo smartctl -t select,0-max /dev/sdX # Force full surface scan
sudo smartctl -x /dev/sdX | grep -A 20 "Vendor Specific SMART"
For Seagate drives specifically, try the advanced logging:
sudo smartctl -l xerror,1 /dev/sdX # Show first error log
sudo smartctl -l xerror,2 /dev/sdX # Show second error log
Once you identify problematic zones, create partitions avoiding those areas:
parted /dev/sdX mklabel gpt
parted /dev/sdX mkpart primary ext4 0% 90% # Leave 10% buffer
parted /dev/sdX mkpart primary ext4 90% 100%
parted /dev/sdX set 2 lvm on # Mark as unused
Implement these checks in your monitoring system:
#!/bin/bash
THRESHOLD=100
REALLOC=$(smartctl -A /dev/sdX | grep Reallocated_Sector_Ct | awk '{print $10}')
if [ $REALLOC -gt $THRESHOLD ]; then
echo "WARNING: $REALLOC reallocated sectors on /dev/sdX" | mail -s "Drive Alert" admin@example.com
fi
Consider these non-critical applications:
- Swap space (with
discard
option enabled) - Temporary build directories in CI/CD pipelines
- Low-priority cache storage
- Non-essential logging partitions