units: drop runlevel[0-6].target

This commit is contained in:
Yu Watanabe
2025-04-21 09:47:04 +09:00
parent dc1505555b
commit e58ba80a40
6 changed files with 7 additions and 65 deletions

View File

@@ -11,13 +11,7 @@ Also check out the [Tips & Tricks](/TIPS_AND_TRICKS)!
**Q: How do I change the current runlevel?**
A: In systemd runlevels are exposed via "target units". You can change them like this:
```sh
# systemctl isolate runlevel5.target
```
Note however, that the concept of runlevels is a bit out of date, and it is usually nicer to use modern names for this. e.g.:
A: The concept of runlevels is obsolete. A set of target units are exposed that carry similar semantics, e.g. runlevel 5 -> `graphical.target`:
```sh
# systemctl isolate graphical.target

View File

@@ -49,10 +49,6 @@
<para>Note that compatibility is quite comprehensive but not 100%, for more details see <ulink
url="https://systemd.io/INCOMPATIBILITIES">Compatibility with SysV</ulink>.</para>
<para>SysV runlevels have corresponding systemd targets
(<filename>runlevel<replaceable>X</replaceable>.target</filename>). The wrapper unit that is generated
will be wanted by those targets which correspond to runlevels for which the script is enabled.</para>
<para><command>systemd</command> does not support SysV scripts as part of early boot, so all wrapper
units are ordered after <filename>basic.target</filename>.</para>

View File

@@ -73,10 +73,6 @@
<filename>remote-fs.target</filename>,
<filename>rescue.target</filename>,
<filename>rpcbind.target</filename>,
<filename>runlevel2.target</filename>,
<filename>runlevel3.target</filename>,
<filename>runlevel4.target</filename>,
<filename>runlevel5.target</filename>,
<filename>shutdown.target</filename>,
<filename>sigpwr.target</filename>,
<filename>sleep.target</filename>,
@@ -627,9 +623,6 @@
<citerefentry><refentrytitle>systemd-logind</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
<command>org.freedesktop.login1.Manager.PowerOff</command> D-Bus method
directly.</para>
<para><filename>runlevel0.target</filename> is an alias for
this target unit, for compatibility with SysV.</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -646,9 +639,6 @@
<para>See
<citerefentry><refentrytitle>systemd-reboot.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
for further details of the operation this target pulls in.</para>
<para><filename>runlevel6.target</filename> is an alias for this target unit, for compatibility
with SysV.</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -707,28 +697,11 @@
<filename>multi-user.target</filename>, this target could be seen as
<filename>single-user.target</filename>.</para>
<para><filename>runlevel1.target</filename> is an alias for this target unit, for
compatibility with SysV.</para>
<para>Use the <literal>systemd.unit=rescue.target</literal> kernel command line option
to boot into this mode. A short alias for this kernel command line option is
<literal>1</literal>, for compatibility with SysV.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>runlevel2.target</filename></term>
<term><filename>runlevel3.target</filename></term>
<term><filename>runlevel4.target</filename></term>
<term><filename>runlevel5.target</filename></term>
<listitem>
<para>These are targets that are called whenever the SysV
compatibility code asks for runlevel 2, 3, 4, 5,
respectively. It is a good idea to make this an alias for
(i.e. symlink to) <filename>graphical.target</filename>
(for runlevel 5) or <filename>multi-user.target</filename>
(the others).</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>shutdown.target</filename></term>
<listitem>

View File

@@ -45,10 +45,7 @@
for examples and descriptions of standard systemd targets.</para>
<para>Target units provide a more flexible replacement for SysV runlevels in the classic SysV init
system. For compatibility reasons special target units such as <filename>runlevel3.target</filename>
exist which are used by the SysV runlevel compatibility code in systemd, see
<citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
details.</para>
system.</para>
<para>Note that a target unit file must not be empty, lest it be considered a masked unit. It is
recommended to provide a [Unit] section which includes informative <varname>Description=</varname> and

View File

@@ -326,7 +326,6 @@ systemd.special.xml ./refsect1[title="Units managed by the system service manage
systemd.special.xml ./refsect1[title="Units managed by the system service manager"]/refsect2[title="Special Passive System Units "]/variablelist/varlistentry[term="remote-fs-pre.target"]
systemd.special.xml ./refsect1[title="Units managed by the system service manager"]/refsect2[title="Special System Units"]/variablelist/varlistentry[term="rescue.target"]
systemd.special.xml ./refsect1[title="Units managed by the system service manager"]/refsect2[title="Special Passive System Units "]/variablelist/varlistentry[term="rpcbind.target"]
systemd.special.xml ./refsect1[title="Units managed by the system service manager"]/refsect2[title="Special System Units"]/variablelist/varlistentry[term="runlevel2.target"]
systemd.special.xml ./refsect1[title="Units managed by the system service manager"]/refsect2[title="Special System Units"]/variablelist/varlistentry[term="shutdown.target"]
systemd.special.xml ./refsect1[title="Units managed by the system service manager"]/refsect2[title="Special System Units"]/variablelist/varlistentry[term="sigpwr.target"]
systemd.special.xml ./refsect1[title="Units managed by the system service manager"]/refsect2[title="Special System Units"]/variablelist/varlistentry[term="sleep.target"]

View File

@@ -1,7 +1,5 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
with_runlevels = conf.get('HAVE_SYSV_COMPAT') == 1
units = [
{ 'file' : 'basic.target' },
{ 'file' : 'blockdev@.target' },
@@ -51,7 +49,7 @@ units = [
},
{
'file' : 'graphical.target',
'symlinks' : ['default.target'] + (with_runlevels ? ['runlevel5.target'] : []),
'symlinks' : ['default.target'],
},
{ 'file' : 'halt.target' },
{
@@ -144,20 +142,14 @@ units = [
'conditions' : ['ENABLE_MACHINED'],
},
{ 'file' : 'modprobe@.service' },
{
'file' : 'multi-user.target',
'symlinks' : with_runlevels ? ['runlevel2.target', 'runlevel3.target', 'runlevel4.target'] : [],
},
{ 'file' : 'multi-user.target' },
{ 'file' : 'network-online.target' },
{ 'file' : 'network-pre.target' },
{ 'file' : 'network.target' },
{ 'file' : 'nss-lookup.target' },
{ 'file' : 'nss-user-lookup.target' },
{ 'file' : 'paths.target' },
{
'file' : 'poweroff.target',
'symlinks' : with_runlevels ? ['runlevel0.target'] : [],
},
{ 'file' : 'poweroff.target' },
{ 'file' : 'printer.target' },
{
'file' : 'proc-sys-fs-binfmt_misc.automount',
@@ -182,7 +174,7 @@ units = [
},
{
'file' : 'reboot.target',
'symlinks' : ['ctrl-alt-del.target'] + (with_runlevels ? ['runlevel6.target'] : []),
'symlinks' : ['ctrl-alt-del.target'],
},
{
'file' : 'remote-cryptsetup.target',
@@ -202,10 +194,7 @@ units = [
'symlinks' : ['initrd-root-device.target.wants/'],
},
{ 'file' : 'rescue.service.in' },
{
'file' : 'rescue.target',
'symlinks' : with_runlevels ? ['runlevel1.target'] : [],
},
{ 'file' : 'rescue.target' },
{ 'file' : 'rpcbind.target' },
{ 'file' : 'serial-getty@.service.in' },
{ 'file' : 'shutdown.target' },
@@ -983,10 +972,4 @@ else
dbussessionservicedir / 'org.freedesktop.systemd1.service'))
endif
if conf.get('HAVE_SYSV_COMPAT') == 1
foreach i : [1, 2, 3, 4, 5]
install_emptydir(systemunitdir / 'runlevel@0@.target.wants'.format(i))
endforeach
endif
subdir('user')