[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: e2fsck -c to check for bad blocks



On Wed, 13 Feb 2008 11:12:52 -0500
Haines Brown <brownh@hartford-hwp.com> wrote:

> I gather one can use the e2fsck with -c option to have it call
> /sbin/badblocks to report bad blocks on an unmounted partition. 


This  option  causes  e2fsck  to  use  badblocks(8) program to do a
read-only scan of the device in order to find any bad blocks.  If any
bad blocks are found, they are added to the bad block inode to prevent
them from being allocated to a file or directory.  If this option is
specified twice, then the bad block scan will be done using a
non-destructive read-write test.

> 
> 1. Although the -c option causes fsck to use badblocks to identify any
> bad blocks present, does e2fsck then proceed to use this information to
> fix corruption as usual? That is, how does 
> 
>           # e2fsck -cy /dev/sda1
> 
> differ from simply:
> 
>           # e2fsck -y /dev/sda1
>            

Yes, it does fix it. "they are added to the bad block inode"

> 2. If badblocks is non-destructive, why does the targeted filesystem
> have to be unmounted? 

Does it have to be? What does -f say? fsck always complains if the fs
is mounted.

Note  that  in  general it is not safe to run e2fsck on mounted
filesystems. The only exception is if the -n option is specified, and
-c, -l, or -L options are not specified.   However, even if it is safe
to do so, the results printed by e2fsck are not valid if the
filesystem  is  mounted. If e2fsck  asks whether  or  not you should
check a filesystem which is mounted, the only correct answer is
‘‘no’’.  Only experts who really know what they are doing should
consider answering this question in any other way.

Badblocks may be non-destructive, but adding the found blocks to the 
inode may be bad. You don't know what fsck will do other than running 
badblocks.

> 
> 3. While e2fsck is run on an unmounted file system, the man page says,
> "If this [-c] option is specified twice, then the bad block scan will be
> done using a non-destructive read-write test." Does this "specified
> twice" simply mean "-cc"? If the test is non-destructive, can it be run
> on a mounted filesystem? I assume not, but wanted to be sure.

correct.

> 
> 4. Both badblocks and e2fsck -c can identify bad blocks as part of a
> check of hard disk viability. Is the difference only that while
> badblocks just reports bad blocks, e2fsck -c actually goes ahead and
> tries to fix them? 

correct.

>  
> -- 
>  
>        Haines Brown, KB1GRM
> 

Attachment: pgpWVqYFLzmFT.pgp
Description: PGP signature


Reply to: