Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jun 2018 08:47:52 +0100
From:      Steve O'Hara-Smith <steve@sohara.org>
To:        Manish Jain <jude.obscure@yandex.com>
Cc:        jungle Boogie <jungleboogie0@gmail.com>, FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: How to detect single user mode in FreeBSD ?
Message-ID:  <20180614084752.bd90d2277cdcaf099c501bdc@sohara.org>
In-Reply-To: <89bc6774-aa0d-6704-71a1-6b8eea8ae3b5@yandex.com>
References:  <e9731c0f-1269-8919-836a-29b9a2f6b0dc@yandex.com> <CAKE2PDsJqX5g61wYGhKxXv6CMNbdFVLTCvfhG5FY06o6cqw10Q@mail.gmail.com> <89bc6774-aa0d-6704-71a1-6b8eea8ae3b5@yandex.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Thu, 14 Jun 2018 05:59:16 +0530
Manish Jain <jude.obscure@yandex.com> wrote:

> On 06/14/18 05:09, jungle Boogie wrote:
> > Describe the problem you want to solve, not how.
> 
> The problem is this:
> 
> I am writing a shell script which can run fsck on all UFS / ext2 /ext4 
> hard disk partitions listed in /etc/fstab.

	The one mounted on / is going to be a problem in Linux.

	I'm not sure I see the point in such a script though, the boot time
checks have always been adequate in my experience but hey you want it so
fine.

> The script should be portable and be able to run no matter whether the 
> OS running is FreeBSD or Linux. The only thing that matters is that the 
> commands fsck_ufs / fsck.ext2 and fsck.ext4 are available.

	Fine.

> Ideally, the script should run only under single user mode, or else bail 
> out immediately.

	Why ? It would be far more sensible for the script to check each
filesystem to see if it is mounted and run fsck if it is not. That way it
will run correctly at any time, including in single user with filesystems
mounted which is a perfectly feasible condition.

> Linux has a clean way to find out whether the system is in single user 
> mode. I would think, no matter what others on this list have said, 
> sysctl under FreeBSD too should have a variable for indicating single 
> user mode. But there currently is not any.

	I can't think of any time when single user mode is the correct
thing to be checking for before doing something.

-- 
Steve O'Hara-Smith <steve@sohara.org>



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20180614084752.bd90d2277cdcaf099c501bdc>