1) How does one change the default runlevel? When Ubuntu boots, it
boots into runlevel 2. I'd like it to boot into runlevel 5. With
/etc/inittab I would modify the "id:" line.
2) How does one re-read the /etc/even.d files? With inittab, I would
type 'init -q'. In upstart I modified the /etc/event.d/rc-default
file, changing 2 to 5. However, if I type "init 1" and then exit from
runlevel 1, Ubuntu still goes into runlevel 2. According to the docs,
any changes in events should be automatic:
http://upstart.ubuntu.com/faq.html#reload
3) How does one specify a different runlevel at boot time? With init
I would simply specify the run level at the end of the kernel line.
That doesn't work in Ubuntu.
4) How does one enter Emergency mode? Before upstart one could
specify -b and only a minimal number of drivers were installed, e.g.
no networking.
Any pointers appreciated.
Regards,
- Robert
Anyway, seems he wrote something about /etc/event.d:
http://www.linux.com/feature/125977?theme=print
I haven't read it yet, but what you need might be there.
Sean
--
Thu, 28 Feb 2008 08:18:53 -0600
Here's the specific info you need. Interesting....
Under SysVinit, the initdefault entry in the /etc/inittab file
tells init which runlevel to bring the system to when it comes
up. Ubuntu does not include an inittab file and, by default,
the Upstart init daemon (using the rc-default task) boots the
system to multiuser mode (runlevel 2, the default runlevel).
If you want the system to boot to a different runlevel, create
an inittab file. The following file causes the system to boot
to single-user mode (runlevel S):
$ cat /etc/inittab :id:S:initdefault:
When the system comes up in single-user (recovery) mode, if
the root account on the system is unlocked, init requests the
root password before displaying the root prompt. Otherwise it
displays the root prompt without requesting a password.
Never set the system to boot to runlevel 0 or 6, as it will
not come up properly. To boot to multiuser mode (runlevel 2),
remove the inittab file if it exists or create the inittab
file shown in the example and replace the S with a 2.
Sean
--
Thu, 28 Feb 2008 08:41:06 -0600
Why does that design sound so very wrong?
What's worse is that I don't think it will work. Below is the actual
rc-default script. If I create an /etc/inittab file, it would be the
sed line that would change the default runlevel. Yet, I changed the
2's to 5's in the script and Ubuntu still boots into runlevel 2.
<quote>
# rc-default script
start on stopped rcS
script
runlevel --reboot || true
if grep -q -w -- "-s\|single\|S" /proc/cmdline; then
telinit S
elif [ -r /etc/inittab ]; then
RL="$(sed -n -e
"/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)"
if [ -n "$RL" ]; then
telinit $RL
else
telinit 2
fi
else
telinit 2
fi
end script
<quote>
Regards,
- Robert
Yep, I tested it too and it won't boot into any other runlevel. I
have to put this off for a while, and I don't recall if you
mentioned this, but you might find some info here:
http://upstart.ubuntu.com/index.html
Sean
--
Thu, 28 Feb 2008 09:24:47 -0600
Thanks for testing it. Nice to see confirmation.
> I have to put this off for a while,
I understand. Like you this is going on the back burner for now.
Being able to change runlevels is really useful for debugging services
and drivers. It's unfortunate that changing runlevels doesn't work or
doesn't work as expected with upstart.
> and I don't recall if you
> mentioned this, but you might find some info here:
>
> http://upstart.ubuntu.com/index.html
Yup. That's where I've been reading and haven't found anything really
helpful there. There might be nuggets in the wiki page, but I haven't
fully explored that, yet. I'll post to the forums and see what I can
get from there.
Regards,
- Robert
Maybe a little sleep helps. Tried it today and it works as expected.
So, I modified the script to this:
<quote>
# rc - runlevel compatibility
#
# This task guesses what the "default runlevel" should be and starts the
# appropriate script.
start on stopped rcS
script
def_RL=4
runlevel --reboot || true
if grep -q -w -- "-s\|single\|S" /proc/cmdline; then
telinit S
elif [ -r /etc/inittab ]; then
RL="$(sed -n -e
"/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)"
if [ -n "$RL" ]; then
telinit $RL
else
telinit $def_RL
fi
else
telinit $def_RL
fi
end script
</quote>
To change the default runlevel, I change the value of def_RL.
Regards,
- Robert
I changed my default RL to 5 and then modified what starts up in
different runlevels:
sudo apt-get install sysv-rc-conf
sudo sysv-rc-conf --list
sudo sysv-rc-conf --level 2 gdm off
If you are familiar with chkconfig from fedora or red hat, then you'll
fell (mostly) at home with sysv-rc-conf.
Regards,
- Robert
Thanks Robert. This is really good to know.
Sean
--
Thu, 28 Feb 2008 15:48:09 -0600
Might as well modify the /etc/event.d/rc-default script to handle this, too:
<quote>
# rc - runlevel compatibility
#
# This task guesses what the "default runlevel" should be and starts the
# appropriate script.
start on stopped rcS
script
def_RL=5
runlevel --reboot || true
RL="$(< /proc/cmdline tr ' ' '\n' | grep -v '[^0-9]' | tail -1 || true)"
if [ -n "$RL" ] ; then
RL=$RL
elif grep -q -w -- "-s\|single\|S" /proc/cmdline; then
RL=S
elif [ -r /etc/inittab ]; then
RL="$(sed -n -e
"/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)"
if [ -n "$RL" ]; then
RL=$RL
else
RL=$def_RL
fi
else
RL=$def_RL
fi
telinit $RL
end script
</quote>
Now you can change the default runlevel by changing the value of
def_RL and you can boot into a different runlevel by putting the
runlevel number on the kernel line.
The logic's a bit contorted, but it works. Fell free to refactor.
Regards,
- Robert
Slightly easier to read code:
http://ubuntuforums.org/showpost.php?p=4426474
Regards,
- Robert