Fix a corrupt Hard Disk
Sometimes, hard-disks (HDDs) have hiccups. This post mentions some common steps I use to get out of such situations.
-
Check if you indeed have a HDD problem. A common symptom is if
touch test
or simple I/O commands like that hang up and cannot be killed. Such processes show up with a “D” status inhtop
, and they cannot be interrupted with even withSIGKILL
. You will also not be able toumount
the disk. -
If you reboot the computer at this stage, it will get stuck in an
fsck
check while booting and never get past that. So the best is to comment out the HDD’s entry from/etc/fstab
before rebooting. -
If you forgot to do that, Ubuntu will usually put you into a root shell after showing something like “Welcome to emergency mode”. Use this to comment out the
fstab
entry for the HDDreboot
. -
Now you should be in a working environment with the HDD plugged in, but not mounted.
-
Find out the drive device (e.g.
/dev/sde1
) usingsudo fdisk -l
. -
If it is an
ext4
disk, use thefsck
tool to fix it. -
If it is an NTFS disk, use
sudo ntfsfix <device>
. Although, as mentioned here, that is only a temporary fix. -
The more appropriate fix is to use
chkdsk.exe
on a Windows computer:chkdsk /r <DRIVE LETTER>:
. Note: It seems likechkdsk.exe
assumes the entire disk is full while estimating the time for fixing, so don’t be scared if it estimates a crazy long time. Things go much faster for the empty sectors of the HDD. -
Uncomment the HDD’s entry in
/etc/fstab
, and if you fixed it correctly, you should be good to go!