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

Re: Check journal is replayable ?

On Dec 02, 2002  17:10 +0000, John Vickers wrote:
> Is there a simple way, at a shell script level, of finding out whether an
> ext3 fs has a sane journal, other than mounting it or running a full fsck ?

Yes, "tune2fs -l <dev> | grep 'features:.*needs_recovery'", but reading
further you do not actually need it.

> I may quite well be missing a few things here, but what I think I'd like is
> some option extra to e2fsck that says "if this is a journalled filesystem,
> and it was shut down uncleanly, just replay the journal and check for
> immediately obvious problems, but don't bother scanning the whole filesystem
> unless there's a '-f' in sight".

That is how e2fsck already works, no need to change anything.  By default
it will replay the journal, and then check the superblock for errors.  If
no error is marked in the superblock, it is done in a second or so[*].

Just doing this with the above script isn't enough, since errors can also
be stored in the journal header in case of very serious errors, and the
un-recovered filesystem superblock will _appear_ to be fine, but the
filesystem really needs a full check.

[*] There is also a feature of ext2/3 that allows you to specify full
    filesystem checks after a certain number of mounts/time.  Some
    people turn this off in the mistaken thought that "it has a journal,
    I don't need no stinking fsck on my filesystems".  However, a journal
    is no protection against disk, memory, CPU, or kernel errors, so doing
    periodic full fscks can help find errors before they cause cascading
    data corruption on your filesystem, or get detected right in the middle
    of some important work and make your system unusable.  If you don't like
    the "every 20 mounts" full fsck, change it with "tune2fs -c" to be some
    longer interval.

> AFAICT, the usual way of handling ext3 filesystems seems to be to mark them
> with fs_passno=0, so they never get fscked from the init scripts - but the
> journal gets replayed, and a few things get checked at mount time.

That is just plain wrong, since it will skip full checking if there was an
error detected in the filesystem.

> If mount fails - because something horrible really did happen - then the
> /etc/rc.sysinit doesn't seem to have any way of coping, or dropping to an
> interactive shell.

That's why you should have passno != 0 for all ext3 filesystems, so that
e2fsck has a chance to check the superblock before the filesystem is

Cheers, Andreas
Andreas Dilger

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