Restarting init without rebooting

Willie Viljoen will at unfoldings.net
Mon Apr 21 23:21:44 PDT 2003


On Tuesday 22 April 2003 7:39, someone, possibly Sunil Sunder Raj, typed:
(Top post moved to bottom)
> >There is supposed to be a way of restarting init, after modifications of
> >say an rc.* file, by sending a SIGHUP, I think avoiding the need to
> >reboot.

> kill -HUP pid
> wher pid is the pid of the inetd process.

Sunil, this is to restart the internet super server (inetd). Joe wanted to 
restart init (the stage of booting and system management just after the 
kernel)

Joe, sadly BSD init will not restart as some SysV flavours will do, however, 
if you are at the console (NOT over a network connection, but a serial 
console counts too), there is a way to emulate the behaviour you would get 
from a SysV init.

First, as root, do this (note the omission of switches):

# shutdown now

The system should now kill off processes and if your console is set to be 
insecure in /etc/ttys(5), init will ask for your root password to enter 
single user mode.

Now you will be asked for a shell. Normally I prefer csh, but I'd recommend 
going with the defeault of /bin/sh for single user mode, various reasons.

Once in single user mode, you will see:

#

Now, your only real option is to conduct some single user operations on the 
system, and reboot. You may also reinvoke rc however. Note that this can be 
troublesome, as some things in system startup really need only happen once. 
If you want to do this, first make sure to unmount all file systems in 
fstab(5), except for root. Do this:

# umount -A

Now, to attempt the restart, enter:

# sh /etc/rc

It's important that you use sh here. Even if you selected to use csh for 
your shell, you MUST invoke /etc/rc with sh.

The system should now start performing the general booting procedures. This 
is pretty much a reboot, but it won't kill your uptime (which I am assuming 
is what you wish to preserve)

Give this a try.
Will

-- 
Willie Viljoen
Freelance IT Consultant

214 Paul Kruger Avenue, Universitas
Bloemfontein
9321
South Africa

+27 51 522 15 60
+27 51 522 44 36 (after hours)
+27 82 404 03 27 (mobile)

will at unfoldings.net


More information about the freebsd-questions mailing list