Ubuntu有8个运行级别(0-6和S),我想添加运行级别7。

我做了以下事情:

1.-创建了文件夹 /etc/rc7.d / ,其中包含一些指向 /etc/init.d /

的符号链接

2.-创建文件 /etc/event.d/rc7 这是它的内容:

# 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

我认为这就足够了,但 telinit 7 仍然会抛出此错误: telinit:非法运行级别:7

有帮助吗?

解决方案

你不能;运行级别被硬编码到实用程序中。但你为什么需要?运行级别4基本上未使用。虽然这不是最好的想法,但你可以重新使用运行级别3或运行级别5,具体取决于你是否总是/从不使用X.

请注意,某些* nix系统支持超过6个运行级别,但Linux不是其中之一。

其他提示

我不确定如何添加它们(从不需要),但我非常确定 / etc / inittab 是你添加运行级别的地方。

虽然我不得不同意Zathrus的观点,但是其他的运行级别可用但尚未使用。在Debian上,真的只使用了1和2。不过,我不确定Ubuntu是如何设置的。但是,如果您有特定目的,应该可以这样做。我从来没有这么做过。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top