Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Apr 2020 15:31:44 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Scott <freebsd-lists-5@thismonkey.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Should fsck honour "failok" in fstab as mount does?
Message-ID:  <20200421153144.d45a889b.freebsd@edvax.de>
In-Reply-To: <20200421071319.GA98163@thismonkey.com>
References:  <20200421071319.GA98163@thismonkey.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Tue, 21 Apr 2020 17:13:20 +1000, Scott wrote:
> mount ignores failed mount attempts when "failok" is specified as an option 
> in /etc/fstab allowing the boot process to continue.
> 
> However, fsck does not, and I think it should.  It shouldn't mark an FS as 
> clean, obviously, just not drop into single-user mode - let mount do that 
> when it tries to mount an FS without the "failok" option.

In my opinion, this sounds wrong. If a filesystem is damaged,
it's generally a bad idea to boot from it or mount it, as
it often leads to inconsistencies, strange errors, and other
things definitely not desired. Background fsck doesn't really
work. The file /etc/fstab is the filesystem table intended
for use with mount; the fact that fsck uses it is just a nice
side effect, but not its primary use. That's why the options
field is intended for the mount command.

>From "man 5 fstab":

     The fourth field, (fs_mntops), describes the mount options associated
     with the file system. 

This matches the behaviour intended with the "failok" option.
It is intended for the mount program.

Again from "man 5 fstab":

     If the option ``failok'' is specified, the system will ignore any error
     which happens during the mount of that filesystem, which would otherwise
     cause the system to drop into single user mode.  This option is imple-
     mented by the mount(8) command and will not be passed to the kernel.

Nothing here is related to fsck.

The effect that the system drops into single-user mode is
also intended. When fsck is invoked - upon filesystem error -
it will automatically repair minor defects, and afterwards
the system will continue booting. In case of major defects
the system operator is expected to make decisions. It _might_
be possible that he does not want fsck to attempt any further
repair, and instead relapse to other tools (data recovery,
or restore from backup right away). Certain aspects of this
behaviour can be controlled with the followint variables
in /etc/rc.conf, for example:

	background_fsck="NO"	# never!
	fsck_y_enable="YES"	# always say "yes"
	fsck_y_flags="-f"	# force fsck

This will always force fsck to perform a full check and
repair, and answer "yes" whenever needed, in case the
initial preen ("minor defects repair mode") fails. The
equivalent is:

	# fsck -y -f <filesystem>

Keep in mind this is not always intended! That's why
there is the single user mode, to allow a human decision.

If you don't want fsck to stumble upon a damaged filesystem,
do not include it in /etc/fstab. You can still use a custom
rc.d-style script or an entry in /etc/rc.local if you wish
to "maybe mount" non-vital or optional filesystems later on.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20200421153144.d45a889b.freebsd>