How to detect single user mode in FreeBSD ?
steve at sohara.org
Thu Jun 14 07:47:56 UTC 2018
On Thu, 14 Jun 2018 05:59:16 +0530
Manish Jain <jude.obscure at 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
> 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.
> 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 at sohara.org>
More information about the freebsd-questions