ubuntuupstartrunlevel

How do I add another run level (level 7) in Ubuntu?


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


Solution

  • 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.