Difference between revisions of "Systemd FAQ"

From ArchWiki
Jump to: navigation, search
m (Note as tag.)
(FAQ: Updated link to TODO page, systemd Git development moved to GitHub on 2015-06-01)
 
(14 intermediate revisions by 10 users not shown)
Line 6: Line 6:
 
[[ja:Systemd FAQ]]
 
[[ja:Systemd FAQ]]
 
[[zh-CN:Systemd FAQ]]
 
[[zh-CN:Systemd FAQ]]
 +
 +
{{Related articles start}}
 +
{{Related|systemd}}
 +
{{Related|systemd/User}}
 +
{{Related|Daemons#List of daemons}}
 +
{{Related articles end}}
 +
 
== FAQ ==
 
== FAQ ==
  
For an up-to-date list of known issues, look at the upstream [http://cgit.freedesktop.org/systemd/systemd/tree/TODO TODO].
+
For an up-to-date list of known issues, look at the upstream [https://github.com/systemd/systemd/blob/master/TODO TODO].
 +
 
 +
=== Why do I get log messages on my console? ===
 +
 
 +
You must set the kernel loglevel yourself. Historically, {{ic|/etc/rc.sysinit}} did this for us and set dmesg loglevel to {{ic|3}}, which was a reasonably quiet loglevel. Either add {{ic|1=loglevel=3}} or {{ic|quiet}} to your [[kernel parameters]].
 +
 
 +
=== How do I change the default number of gettys? ===
 +
 
 +
Currently, only one getty is launched by default. If you switch to another tty, a getty will be launched there (socket-activation style). In other words, [Ctl] [Alt] [F2] will launch a new getty on tty2.
 +
 
 +
By default, the number of auto-activated gettys is capped at six. Thus [F7] through [F12] won't launch a getty.
 +
 
 +
If you want to change this behavior, then edit {{ic|/etc/systemd/logind.conf}} and change the value of {{ic|NAutoVTs}}. If you want all [F''x''] keys to start a getty, increase the value of NAutoVTs to 12. If you are [[Systemd#Forward_journald_to_.2Fdev.2Ftty12|forwarding journald to tty12]], increase the value of NAutoVTs to 11 (thus leaving tty12 free).
  
{{FAQ
+
You can also pre-activate gettys which will be running from boot.
|question=Why do I get log messages on my console?
+
|answer=You must set the kernel loglevel yourself. Historically, {{ic|/etc/rc.sysinit}} did this for us and set dmesg loglevel to {{ic|3}}, which was a reasonably quiet loglevel. Either add {{ic|1=loglevel=3}} or {{ic|quiet}} to your [[kernel parameters]].}}
+
  
{{FAQ
+
To add another pre-activated getty, simply place another symlink for instantiating another getty in the {{ic|/etc/systemd/system/getty.target.wants/}} directory:
|question=How do I change the number of gettys running by default?
+
|answer=To add another getty, simply place another symlink for instantiating another getty in the {{ic|/etc/systemd/system/getty.target.wants/}} directory:
+
  
 
  # ln -sf /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty9.service
 
  # ln -sf /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty9.service
Line 28: Line 43:
 
systemd does not use the {{ic|/etc/inittab}} file.
 
systemd does not use the {{ic|/etc/inittab}} file.
  
{{Note|As of systemd 30, only one getty will be launched by default. If you switch to another tty, a getty will be launched there (socket-activation style). You can still force additional agetty processes to start using the above methods.}}
+
=== How do I get more verbose output during boot? ===
  
Users may also change the number of gettys that may be auto-spawned by editing {{ic|/etc/systemd/logind.conf}} and changing the value of {{ic|NAutoVTs}}. By doing it this way, the on-demand spawning will be preserved, whereas the above method will simply have the gettys running from boot.}}
+
If you see no output at all in console after the initram message, this means you have the {{ic|quiet}} parameter in your kernel line. It's best to remove it, at least the first time you boot with systemd, to see if everything is ok. Then, you will see a list {{ic|[ OK ]}} in green or {{ic|[ FAILED ]}} in red.
  
{{FAQ
+
Any messages are logged to the system log and if you want to find out about the status of your system run {{ic|systemctl}} (no root privileges required) or look at the boot/system log with {{ic|journalctl}}.
|question=How do I get more verbose output during boot?
+
|answer=If you see no output at all in console after the initram message, this means you have the {{ic|quiet}} parameter in your kernel line. It's best to remove it, at least the first time you boot with systemd, to see if everything is ok. Then, You will see a list {{ic|[ OK ]}} in green or {{ic|[ FAILED ]}} in red.
+
  
Any messages are logged to the system log and if you want to find out about the status of your system run {{ic|systemctl}} (no root privileges required) or look at the boot/system log with {{ic|journalctl}}.}}
+
=== How do I avoid clearing the console after boot? ===
  
{{FAQ
+
Create a directory called {{ic|/etc/systemd/system/getty@.service.d}} and place {{ic|nodisallocate.conf}} in there to [[Systemd#Editing provided units|override]] the {{ic|TTYVTDisallocate}} option to {{ic|no}}.
|question=How do I avoid clearing the console after boot?
+
|answer=Create a custom {{ic|getty@tty1.service}} file by copying {{ic|/usr/lib/systemd/system/getty@.service}} to {{ic|/etc/systemd/system/getty@tty1.service}} and change {{ic|TTYVTDisallocate}} to {{ic|no}}.}}
+
  
{{FAQ
+
{{hc|/etc/systemd/system/getty@.service.d/nodisallocate.conf|2=
|question=What kernel options do I need to enable in my kernel in case I do not use the official Arch kernel?
+
[Service]
|answer=Kernels prior to 2.6.39 are unsupported.
+
TTYVTDisallocate=no
 +
}}
  
This is a partial list of required/recommended options, there might be more:
+
=== What kernel options are required for systemd? ===
  
{{bc|1='''General setup'''
+
Kernels prior to 3.0 are unsupported.  
CONFIG_FHANDLE=y
+
CONFIG_AUDIT=y (recommended)
+
CONFIG_AUDIT_LOGINUID_IMMUTABLE=y (not required, may break sysvinit compatibility)
+
CONFIG_CGROUPS=y
+
'''-> Namespaces support'''
+
    CONFIG_NET_NS=y (for private network)
+
'''Networking support -> Networking options'''
+
CONFIG_IPV6=[y<nowiki>|</nowiki>m] (highly recommended)
+
'''Device Drivers'''
+
'''-> Generic Driver Options'''
+
    CONFIG_UEVENT_HELPER_PATH=""
+
    CONFIG_DEVTMPFS=y
+
    CONFIG_DEVTMPFS_MOUNT=y (required if you don't use an initramfs)
+
'''-> Real Time Clock'''
+
    CONFIG_RTC_DRV_CMOS=y (highly recommended)
+
'''File systems'''
+
CONFIG_FANOTIFY=y (required for readahead)
+
CONFIG_AUTOFS4_FS=[y<nowiki>|</nowiki>m]
+
'''-> Pseudo filesystems'''
+
    CONFIG_TMPFS_POSIX_ACL=y (recommended, if you want to use pam_systemd.so)}}}}
+
  
{{FAQ
+
If you use a custom kernel, you will need to make sure that systemd's options are selected.
|question=What other units does a unit depend on?
+
 
|answer=For example, if you want to figure out which services a target like {{ic|multi-user.target}} pulls in, use something like this:  
+
If you are compiling a new kernel for use with an installed version of systemd, the required and recommended options are listed in the systemd README file {{ic|/usr/share/doc/systemd/README}}.
 +
 
 +
If you are preparing to install a new version of systemd and are running a custom kernel, the most recent version of the file can be found in the [http://cgit.freedesktop.org/systemd/systemd/tree/README the systemd git].
 +
 
 +
=== What other units does a unit depend on? ===
 +
 
 +
For example, if you want to figure out which services a target like {{ic|multi-user.target}} pulls in, use something like this:  
  
 
{{hc|$ systemctl show -p "Wants" multi-user.target|2=
 
{{hc|$ systemctl show -p "Wants" multi-user.target|2=
Wants=rc-local.service avahi-daemon.service rpcbind.service NetworkManager.service acpid.service dbus.service atd.service crond.service auditd.service ntpd.service udisks.service bluetooth.service cups.service wpa_supplicant.service getty.target modem-manager.service portreserve.service abrtd.service yum-updatesd.service upowerd.service test-first.service pcscd.service rsyslog.service haldaemon.service remote-fs.target plymouth-quit.service systemd-update-utmp-runlevel.service sendmail.service lvm2-monitor.service cpuspeed.service udev-post.service mdmonitor.service iscsid.service livesys.service livesys-late.service irqbalance.service iscsi.service}}
+
Wants=rc-local.service avahi-daemon.service rpcbind.service NetworkManager.service acpid.service dbus.service atd.service crond.service auditd.service ntpd.service udisks.service bluetooth.service org.cups.cupsd.service wpa_supplicant.service getty.target modem-manager.service portreserve.service abrtd.service yum-updatesd.service upowerd.service test-first.service pcscd.service rsyslog.service haldaemon.service remote-fs.target plymouth-quit.service systemd-update-utmp-runlevel.service sendmail.service lvm2-monitor.service cpuspeed.service udev-post.service mdmonitor.service iscsid.service livesys.service livesys-late.service irqbalance.service iscsi.service
 +
}}
  
Instead of {{ic|Wants}} you might also try {{ic|WantedBy}}, {{ic|Requires}}, {{ic|RequiredBy}}, {{ic|Conflicts}}, {{ic|ConflictedBy}}, {{ic|Before}}, {{ic|After}} for the respective types of dependencies and their inverse.}}
+
Instead of {{ic|Wants}} you might also try {{ic|WantedBy}}, {{ic|Requires}}, {{ic|RequiredBy}}, {{ic|Conflicts}}, {{ic|ConflictedBy}}, {{ic|Before}}, {{ic|After}} for the respective types of dependencies and their inverse.
  
{{FAQ
+
=== My computer shuts down, but the power stays on ===
|question=My computer shuts down, but the power stays on
+
|answer=Use:
+
  
$ systemctl poweroff
+
Use {{ic|systemctl poweroff}} instead of {{ic|systemctl halt}}.
  
Instead of {{ic|systemctl halt}}.}}
+
=== After migrating to systemd, why won't my fakeRAID mount? ===
  
{{FAQ
+
Be sure you use:
|question=After migrating to systemd, why won't my fakeRAID mount?
+
|answer=Be sure you use:
+
  
{{bc|# systemctl enable dmraid.service}}}}
+
# systemctl enable dmraid.service
  
{{FAQ
+
=== How can I make a script start during the boot process? ===
|question=How can I make a script start during the boot process?
+
 
|answer=Create a new file in {{ic|/etc/systemd/system}} (e.g. ''myscript''.service) and add the following contents:
+
Create a new file in {{ic|/etc/systemd/system}} (e.g. ''myscript''.service) and add the following contents:
  
 
  [Unit]
 
  [Unit]
Line 112: Line 107:
 
This example assumes you want your script to start up when the target multi-user is launched. Also do {{ic|chmod 755}} to your script to enable execute permissions if you haven't done so already.
 
This example assumes you want your script to start up when the target multi-user is launched. Also do {{ic|chmod 755}} to your script to enable execute permissions if you haven't done so already.
  
{{Note|In case you want to start a shell script, make sure you have {{ic|#!/bin/sh}} in the first line of the script. Do '''not''' write something like {{ic|<nowiki>ExecStart=/bin/sh /path/to/script.sh</nowiki>}} because that will not work.
+
{{Note|In case you want to start a shell script, make sure you have {{ic|#!/bin/sh}} in the first line of the script. Do '''not''' write something like {{ic|<nowiki>ExecStart=/bin/sh /path/to/script.sh</nowiki>}} because that will not work.}}
}}
+
}}
+
  
{{FAQ
+
=== Status of .service says "active (exited)" in green. (e.g. iptables) ===
|question=Status of .service says "active (exited)" in green. (e.g. iptables)
+
 
|answer=This is perfectly normal. In the case with iptables it is because there is no daemon to run, it is controlled in the kernel. Therefore, it exits after the rules have been loaded.
+
This is perfectly normal. In the case with iptables it is because there is no daemon to run, it is controlled in the kernel. Therefore, it exits after the rules have been loaded.
  
 
To check if your iptables rules have been loaded properly:
 
To check if your iptables rules have been loaded properly:
  
{{bc|# iptables --list}}}}
+
# iptables --list
 +
 
 +
=== "Failed to issue method call: File exists" error ===
  
{{FAQ
+
This happens when using {{ic|systemctl enable}} and the symlink it tries to create in {{ic|/etc/systemd/system/}} already exists. Typically this happens when switching from one display manager to another one (for instance GDM to KDM, which can be enabled with {{ic|gdm.service}} and {{ic|kdm.service}}, respectively) and the corresponding symlink {{ic|/etc/systemd/system/display-manager.service}} already exists.
|question={{ic|Failed to issue method call: File exists}} error
+
|answer=This happens when using {{ic|systemctl enable}} and the symlink it tries to create in {{ic|/etc/systemd/system/}} already exists. Typically this happens when switching from one display manager to another one (for instance GDM to KDM, which can be enabled with {{ic|gdm.service}} and {{ic|kdm.service}}, respectively) and the corresponding symlink {{ic|/etc/systemd/system/display-manager.service}} already exists.
+
  
To solve this problem, either first disable the relevent display manager before enabling the new one, or use {{ic|systemctl -f enable}} to overwrite an existing symlink.}}
+
To solve this problem, either first disable the relevant display manager before enabling the new one, or use {{ic|systemctl -f enable}} to overwrite an existing symlink.

Latest revision as of 14:35, 31 January 2016

FAQ

For an up-to-date list of known issues, look at the upstream TODO.

Why do I get log messages on my console?

You must set the kernel loglevel yourself. Historically, /etc/rc.sysinit did this for us and set dmesg loglevel to 3, which was a reasonably quiet loglevel. Either add loglevel=3 or quiet to your kernel parameters.

How do I change the default number of gettys?

Currently, only one getty is launched by default. If you switch to another tty, a getty will be launched there (socket-activation style). In other words, [Ctl] [Alt] [F2] will launch a new getty on tty2.

By default, the number of auto-activated gettys is capped at six. Thus [F7] through [F12] won't launch a getty.

If you want to change this behavior, then edit /etc/systemd/logind.conf and change the value of NAutoVTs. If you want all [Fx] keys to start a getty, increase the value of NAutoVTs to 12. If you are forwarding journald to tty12, increase the value of NAutoVTs to 11 (thus leaving tty12 free).

You can also pre-activate gettys which will be running from boot.

To add another pre-activated getty, simply place another symlink for instantiating another getty in the /etc/systemd/system/getty.target.wants/ directory:

# ln -sf /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty9.service
# systemctl start getty@tty9.service

To remove a getty, simply remove the getty symlinks you want to get rid of in the /etc/systemd/system/getty.target.wants/ directory:

# rm /etc/systemd/system/getty.target.wants/getty@{tty5,tty6}.service
# systemctl stop getty@tty5.service getty@tty6.service

systemd does not use the /etc/inittab file.

How do I get more verbose output during boot?

If you see no output at all in console after the initram message, this means you have the quiet parameter in your kernel line. It's best to remove it, at least the first time you boot with systemd, to see if everything is ok. Then, you will see a list [ OK ] in green or [ FAILED ] in red.

Any messages are logged to the system log and if you want to find out about the status of your system run systemctl (no root privileges required) or look at the boot/system log with journalctl.

How do I avoid clearing the console after boot?

Create a directory called /etc/systemd/system/getty@.service.d and place nodisallocate.conf in there to override the TTYVTDisallocate option to no.

/etc/systemd/system/getty@.service.d/nodisallocate.conf
[Service]
TTYVTDisallocate=no

What kernel options are required for systemd?

Kernels prior to 3.0 are unsupported.

If you use a custom kernel, you will need to make sure that systemd's options are selected.

If you are compiling a new kernel for use with an installed version of systemd, the required and recommended options are listed in the systemd README file /usr/share/doc/systemd/README.

If you are preparing to install a new version of systemd and are running a custom kernel, the most recent version of the file can be found in the the systemd git.

What other units does a unit depend on?

For example, if you want to figure out which services a target like multi-user.target pulls in, use something like this:

$ systemctl show -p "Wants" multi-user.target
Wants=rc-local.service avahi-daemon.service rpcbind.service NetworkManager.service acpid.service dbus.service atd.service crond.service auditd.service ntpd.service udisks.service bluetooth.service org.cups.cupsd.service wpa_supplicant.service getty.target modem-manager.service portreserve.service abrtd.service yum-updatesd.service upowerd.service test-first.service pcscd.service rsyslog.service haldaemon.service remote-fs.target plymouth-quit.service systemd-update-utmp-runlevel.service sendmail.service lvm2-monitor.service cpuspeed.service udev-post.service mdmonitor.service iscsid.service livesys.service livesys-late.service irqbalance.service iscsi.service

Instead of Wants you might also try WantedBy, Requires, RequiredBy, Conflicts, ConflictedBy, Before, After for the respective types of dependencies and their inverse.

My computer shuts down, but the power stays on

Use systemctl poweroff instead of systemctl halt.

After migrating to systemd, why won't my fakeRAID mount?

Be sure you use:

# systemctl enable dmraid.service

How can I make a script start during the boot process?

Create a new file in /etc/systemd/system (e.g. myscript.service) and add the following contents:

[Unit]
Description=My script

[Service]
ExecStart=/usr/bin/my-script

[Install]
WantedBy=multi-user.target 

Then:

# systemctl enable myscript.service

This example assumes you want your script to start up when the target multi-user is launched. Also do chmod 755 to your script to enable execute permissions if you haven't done so already.

Note: In case you want to start a shell script, make sure you have #!/bin/sh in the first line of the script. Do not write something like ExecStart=/bin/sh /path/to/script.sh because that will not work.

Status of .service says "active (exited)" in green. (e.g. iptables)

This is perfectly normal. In the case with iptables it is because there is no daemon to run, it is controlled in the kernel. Therefore, it exits after the rules have been loaded.

To check if your iptables rules have been loaded properly:

# iptables --list

"Failed to issue method call: File exists" error

This happens when using systemctl enable and the symlink it tries to create in /etc/systemd/system/ already exists. Typically this happens when switching from one display manager to another one (for instance GDM to KDM, which can be enabled with gdm.service and kdm.service, respectively) and the corresponding symlink /etc/systemd/system/display-manager.service already exists.

To solve this problem, either first disable the relevant display manager before enabling the new one, or use systemctl -f enable to overwrite an existing symlink.