This is a very small note that as there is nothing more permanent than temporary, the most trivial (at first glance) task takes the most time.
On Friday morning, an acquaintance asked with the question "How to rebuild the world in single-mode on a remote server without KVM?"
“To write a script in / etc / rc that executes / etc / netstart && service sshd start in the part executed in single-mode, and then everything is as usual,” I replied in no vain.
But after two hours the question was repeated and it turned out that everything was not so trivial.
I don’t know if it was just my delusion or, after all, in early versions of FreeBSD / etc / rc it was partially executed in single-mode (for the sake of fairness, I never had to check it), but in 10-ke it really doesn’t work.
So, the task:# uname -opr
FreeBSD 10.1-STABLE amd64
It is necessary to switch from multi-mode to single-mode and get access via ssh.
Go:Once in single-user mode, no scripts are executed, we fix this mistake. Edit the init sources.
Add the path to our script to /usr/src/sbin/init/pathnames.h
#define _PATH_MYSINGLE "/etc/rc.my_single"
In / usr/src/sbin/init/init.c in the function
single_user add the call
run_script(_PATH_MYSINGLE)
It must be placed somewhere before calling open_console ().
The script itself is called:
/etc/rc.my_single
We collect, set, reboot (maybe there is a way to restart init without rebooting, but I didn’t try my luck on the remote machine):
cd /usr/src/sbin/init && make && make install && shutdown -r now
After downloading to multi-mode to go to single "
shutdown now " or "
init 1 " on an amateur.
Well, then everything is as usual.
ps: Maybe I'm complicating everything and is there an easier way?