Detect and swap out a failing Linux hard drive
Detecting
/dev/sda -a -m youremail@example.com
#/etc/mail.rc
set sendmail="/usr/bin/msmtp -t"
Oh no, you're getting errors
Offline unrecoverable sector errors and current pending sectors: the drive is losing places where it can read/write, and you likely have data corruption
Error count is going up: replace the drive
The process
Buy a new hard drive
Have a USB → SATA adapter of some sort
Partition the new drive to be the same as the old drive
Mount the new partitions on wherever (like /mnt
)
rsync -vra --progress /old/partition/* /old/partition/.??* /new/partition
Get the blkid
of the new drive/partitions
Edit /etc/fstab
and replace the existing UUID
s or PARTUUID
s with the new ones
Reboot the machine
Everything should work
Power down the machine
Swap the drives
Power up the machine
You should be good to go
Destroying the old drive