I am writing an fsck wrapper which first needs to check if the system is
in single user mode.
Under Linux, there appears to be a sysctl that shows whether the system
is in single user
mode: sysctl -n kern.singleuser. Is there some similar facility under
FreeBSD too ?
Thanks for any tips.
Manish Jain
_______________________________________________
freebsd-...@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questi...@freebsd.org"
I don't think there is a definite way to know. Single user mode is only
meant to be for interactive recovery.
When in single user mode PID 1 should be "/sbin/init -s" which becomes
"/sbin/init --" in multi user mode.
The next closet to knowing would be looking at mount, in single user
mode you will only have / mounted read only and /dev. It is rare for any
system to be past single user mode with only that mount setup but the
user can mount the filesystems before starting your script and still be
in single user mode.
You could maybe take a hint from the firstboot option. By default a file
called /firstboot is created and if it exists it means the system has
not been started since it was installed, then a series of setup steps
can be carried out.
You should note that you do not have to be in single user mode to run
fsck, it is in fact designed to run in the background even after a user
has logged in and started various tasks.
From man fsck -
If background checking is available, fsck is invoked twice. It is first
invoked at the traditional time, before the file systems are mounted,
with the -F flag to do checking on all the file systems that cannot do
background checking. It is then invoked a second time, after the system
has completed going multi-user, with the -B flag to do checking on all
the file systems that can do background checking.
--
FreeBSD - the place to B...Software Developing
Shane Ambler
who -r returns error