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

Re: fsck fails (then succeeds)

On Sat, Jun 14, 2003 at 09:21:31PM +0100, Geoff wrote:
> It was definitely this part of of checkfs that I saw, so it
> was an error higher than 2.
> if [ "$error_value" -gt 2 ]
> then

OK, that's the bug in the Linux From Scratch scripts.  From the fsck
man page:

       The exit code returned by fsck is the sum of the following conditions:
            0    - No errors
            1    - File system errors corrected
            2    - System should be rebooted

Newer versions of e2fsck will return an exit status of 3 (filesystem
errors corrected, system should be rebooted), when the root filesystem
has been modified.  This is because even though the root filesystem is
mounted read-only, it is still mounted, and so the kernel may have
cached some filesystem fields which were modified by e2fsck.  If the
root filesystem were remounted read-write, then some of e2fsck's fixes
could get undone when the cached (incorrect) values held in the kernel
get written back to disk.

So what the Linux From Scratch init scripts should do is check to see
if the exit status is 2 or 3, and automatically reboot.

> I am as sure as I can be that there was no fsck output
> printed before I saw that. The check was past 90% and (I
> think), past 95%- the point at which (on my system at
> least), it is only a couple seconds from completion, and I
> was staring at the screen.

There must have been some fsck output, since the only way the fsck
would have returned a non-zero exit status would have been because it
had detected some kind of filesystem inconsistency, and fixed it.

> In case, you, or Ted is interested, I extracted the relevant
> parts of the kern.log, and I am attaching them with
> comments.

Unfortunately, there is nothing of interest in kern.log; what's
necessary is the output from e2fsck.

Note: in the latest versions of e2fsprogs, there is a program which
can help save the output of e2fsck, although it doesn't necessary help
in the case where there is root filesystem corruption, since /var
never gets mounted read-write.  (This, by the way, is why I strongly
encourage a small -- ~128 meg -- root partition, with separate
partitions for /usr and with /var either being a symlink to /usr/var
or its own separate partition.  That way, it's much less likely that
the root partition will get corrupted, since it's much smaller and
there is much less changing on it.)  Anyway, the name of the program
is called "logsave", and you use it as follows:

	logsave -as /var/log/e2fsck.log e2fsck -ACa

Logsave is much like "e2fsck -ACa | tee /var/log/e2fsck.log", except
that if the /var/log directory does not exist, or the filesystem for
/var/log is mounted read-only, logsave will spool the output of e2fsck
in memory, and wait until /var/log/e2fsck.log is writeable, and only
then append the output to the specified logfile.

						- Ted

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