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 testor 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 toumountthe disk. -
If you reboot the computer at this stage, it will get stuck in an
fsckcheck while booting and never get past that. So the best is to comment out the HDD’s entry from/etc/fstabbefore 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
fstabentry 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
ext4disk, use thefscktool 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.exeon a Windows computer:chkdsk /r <DRIVE LETTER>:. Note: It seems likechkdsk.exeassumes 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!