fsck.ext4 and badblocks

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

fsck.ext4 and badblocks

Post by ^rooker »

[PROBLEM]
A friend of mine had problems with her GNU/Linux system, and it turned out that the harddisk was suffering from I/O errors :(

[SOLUTION]
First of all: A harddisk that has bad blocks, should usually not be trusted anymore - and replaced as soon as possible.
In order to avoid further data damage, one can do a filesystem check (fsck) - scan for badblocks and mark them as not-to-be-used:
I ran a simple:

Code: Select all

$ fsck.ext4 -c -c /dev/sdx
The first "-c" checks for bad blocks, and adding it twice, tell fsck to mark them accordingly.

I've also found a nice quick example on "commandlinefu.com" on one can also try:

Code: Select all

$ fsck.ext4 -cDfty -C 0 /dev/sdx
Commandline arguments used:
-c ? check for bad sectors with badblocks program
-D ? optimize directories if possible
-f ? force check, even if filesystem seems clean
-t ? print timing stats (use -tt for more)
-y ? assume answer ?yes? to all questions
-C 0 ? print progress info to stdout
I shall also quote user "mtron"'s notice on that page:
NOTE: Never run fsck on a mounted partition!

Good luck!
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply