views:

704

answers:

2

Ubuntu has 8 run levels (0-6 and S), I want to add the run level 7.

I have done the following:

1.- Created the folder /etc/rc7.d/, which contains some symbolic links to /etc/init.d/

2.- Created the file /etc/event.d/rc7 This is its content:

# rc7 - runlevel 7 compatibility
#
# This task runs the old sysv-rc runlevel 7 ("multi-user") scripts.  It
# is usually started by the telinit compatibility wrapper.

start on runlevel 7

stop on runlevel [!7]

console output
script
    set $(runlevel --set 7 || true)
    if [ "$1" != "unknown" ]; then
        PREVLEVEL=$1
        RUNLEVEL=$2
        export PREVLEVEL RUNLEVEL
    fi

    exec /etc/init.d/rc 7
end script

I thought that would be enough, but telinit 7 still throws this error: telinit: illegal runlevel: 7

+2  A: 

You cannot; the runlevels are hardcoded into the utilities. But why do you need to? Runlevel 4 is essentially unused. And while it's not the best idea, you could repurpose either runlevel 3 or runlevel 5 depending on if you always/never use X.

Note that some *nix systems have support for more than 6 runlevels, but Linux is not one of them.

Zathrus
According to Debian's init page, runlevels up to 9 are valid. I would assume the same is true for Ubuntu.
Michael Johnson
A: 

I'm not sure how to add them (never needed to), but I'm pretty sure /etc/inittab is where you'd add runlevels.

Although I'd have to agree with Zathrus that other runlevels are available but unused. On Debian, only 1 and 2 are used, really. I'm not sure how Ubuntu has it set up, though. However, if you have a specific purpose, it should be possible to do. I've just never had to.

Michael Johnson