04-psyche.tot...@icloud.com writes:
> Thanks Stuart for all these thoughts. That's a lot of great ideas.
>
> Let me try to clarify a few things:
>
> - change `do_fsck` to `do_fsck -y`
> ---------------------------------------------
>   I assume you mean Line 410. That seems like a great idea.
>   Do I understand correctly that the normal behaviour for this `do_fsck` is 
> to run the check, and mark filesystems dirty, and then enter single-user mode?
>   Whereas if I replace it with `do_fsck -y `, the filesystems will not be 
> marked dirty, and it will not enter singe user mode?

More or less.

If the filesystem is already marked dirty (ie. has been mounted
read-write and was not cleanly unmounted) then fsck will check it
and mark it as clean or, if its problems are too much, abort without
making any changes.

Including the -y option makes fsck fix some problems that are common
and often harmless without giving up. Most of the time when plain
fsck fails you will simply run fsck -y yourself anyway.

But it's useful to know if a regular fsck was not enough to repair
the filesystem because it should then be examined manually as files
might have been lost or damaged.

> - starting network and sshd in single user mode
> ----------------------------------------------------------------
>       In /etc/profile, I guess I can add something like:
>
>            if [IS_SINGLE_USER_MODE]; then
>               sh /etc/netstart
>                 rcctl start sshd
>            fi
>
> does that seem reasonable?
>
> (I have to figure out how to check if I am in user mode)

I would create a script to do it by hand. Someone has to press a
key to enter single user mode after all, they might as well also
run an activation script. This means you won't have to put any kind
of dangerous magic in the shell profile.

I have a feeling sshd may require more system state to have been
set up though, and pf in particular will not have been configured.

You will have to read /etc/rc and figure out which parts you need
then test it thoroughly. Consider what happens when /etc/netstart
runs while the router is still booting, for example, or when the
enter-presser has tripped over the ethernet cable.

Matthew

Reply via email to