bootup

package: systemd

title: bootup(7)

summary: System bootup process

text:
# bootup(7)

## NAME
bootup - System bootup process

## DESCRIPTION
A number of different components are involved in the boot of a Linux system. Immediately after power-up, the system firmware will do minimal hardware initialization, and hand control over to a boot loader (e.g. systemd-boot(7) or GRUB[1]) stored on a persistent storage device. This boot loader will then invoke an OS kernel from disk (or the network). On systems using EFI or other types of firmware, this firmware may also load the kernel directly.

The kernel (optionally) mounts an in-memory file system, often generated by dracut(8), which looks for the root file system. Nowadays this is usually implemented as an initramfs — a compressed archive which is extracted when the kernel boots up into a lightweight in-memory file system based on tmpfs, but in the past normal file systems using an in-memory block device (ramdisk) were used, and the name "initrd" is still used to describe both concepts. It's the boot loader or the firmware that loads both the kernel and initrd/initramfs images into memory, but the kernel which interprets it as a file system. systemd(1) may be used to manage services in the initrd, similarly to the real system.

After the root file system is found and mounted, the initrd hands over control to the host's system manager (such as systemd(1)) stored in the root file system, which is then responsible for probing all remaining hardware, mounting all necessary file systems and spawning all configured services.

On shutdown, the system manager stops all services, unmounts all file systems (detaching the storage technologies backing them), and then (optionally) jumps back into the initrd code which unmounts/detaches the root file system and the storage it resides on. As a last step, the system is powered down.

Additional information about the system boot process may be found in boot(7).

## SYSTEM MANAGER BOOTUP
At boot, the system manager on the OS image is responsible for initializing the required file systems, services and drivers that are necessary for operation of the system. On systemd(1) systems, this process is split up in various discrete steps which are exposed as target units. (See systemd.target(5) for detailed information about target units.) The boot-up process is highly parallelized so that the order in which specific target units are reached is not deterministic, but still adheres to a limited amount of ordering structure.

When systemd starts up the system, it will activate all units that are dependencies of default.target (as well as recursively all dependencies of these dependencies). Usually, default.target is simply an alias of graphical.target or multi-user.target, depending on whether the system is configured for a graphical UI or only for a text console. To enforce minimal ordering between the units pulled in, a number of well-known target units are available, as listed on systemd.special(7).

The following chart is a structural overview of these well-known units and their position in the boot-up logic. The arrows describe which units are pulled in and ordered before which other units. Units near the top are started before units nearer to the bottom of the chart.

```
                             cryptsetup-pre.target veritysetup-pre.target

                                                  |
(various low-level                                v

 API VFS mounts:             (various cryptsetup/veritysetup devices...)

 mqueue, configfs,                                |    |

 debugfs, ...)                                    v    |

 |                                  cryptsetup.target  |

 |  (various swap                                 |    |    remote-fs-pre.target

 |   devices...)                                  |    |     |        |

 |    |                                           |    |     |        v

 |    v                       local-fs-pre.target |    |     |  (network file systems)

 |  swap.target                       |           |    v     v                 |

 |    |                               v           |  remote-cryptsetup.target  |

 |    |  (various low-level  (various mounts and  |  remote-veritysetup.target |

 |    |   services: udevd,    fsck services...)   |             |    remote-fs.target

 |    |   tmpfiles, random            |           |             |             /

 |    |   seed, sysctl, ...)          v           |             |            /

 |    |      |                 local-fs.target    |             |           /

 |    |      |                        |           |             |          /

 \____|______|_______________   ______|___________/             |         /

                             \ /                                |        /

                              v                                 |       /

                       sysinit.target                           |      /

                              |                                 |     /

       ______________________/|\_____________________           |    /

      /              |        |      |               \          |   /

      |              |        |      |               |          |  /

      v              v        |      v               |          | /

 (various       (various      |  (various            |          |/

  timers...)      paths...)   |   sockets...)        |          |

      |              |        |      |               |          |

      v              v        |      v               |          |
timers.target  paths.target   |  sockets.target      |          |

      |              |        |      |               v          |

      v              \_______ | _____/         rescue.service   |

                             \|/                     |          |

                              v                      v          |

                          basic.target         rescue.target    |

                              |                                 |

                      ________v____________________             |

                     /              |              \            |

                     |              |              |            |

                     v              v              v            |

                 display-    (various system   (various system  |

             manager.service     services        services)      |

                     |         required for        |            |

                     |        graphical UIs)       v            v

                     |              |            multi-user.target
emergency.service    |              |              |

        |            \_____________ | _____________/

        v                          \|/
emergency.target                    v

                              graphical.target
```

Target units that are commonly used as boot targets are emphasized. These units are good choices as goal targets, for example by passing them to the systemd.unit= kernel command line option (see systemd(1)) or by symlinking default.target to them.

timers.target is pulled-in by basic.target asynchronously. This allows timers units to depend on services which become only available later in boot.

## USER MANAGER STARTUP
The system manager starts the user@uid.service unit for each user, which launches a separate unprivileged instance of systemd for each user — the user manager. Similarly to the system manager, the user manager starts units which are pulled in by default.target. The following chart is a structural overview of the well-known user units. For non-graphical sessions, default.target is used. Whenever the user logs into a graphical session, the login manager will start the graphical-session.target target that is used to pull in units required for the graphical session. A number of targets (shown on the right side) are started when specific hardware is available to the user.

```
    (various           (various         (various

     timers...)         paths...)        sockets...)    (sound devices)

         |                  |                 |               |

         v                  v                 v               v

   timers.target      paths.target     sockets.target    sound.target

         |                  |                 |

         \______________   _|_________________/         (bluetooth devices)

                        \ /                                   |

                         V                                    v

                   basic.target                          bluetooth.target

                         |

              __________/ \_______                      (smartcard devices)

             /                    \                           |

             |                    |                           v

             |                    v                      smartcard.target

             v            graphical-session-pre.target

 (various user services)          |                       (printers)

             |                    v                           |

             |       (services for the graphical session)     v

             |                    |                       printer.target

             v                    v

      default.target      graphical-session.target
```

## BOOTUP IN THE INITIAL RAM DISK (INITRD)
The initial RAM disk implementation (initrd) can be set up using systemd as well. In this case, boot up inside the initrd follows the following structure.

systemd detects that it is run within an initrd by checking for the file /etc/initrd-release. The default target in the initrd is initrd.target. The bootup process begins identical to the system manager bootup (see above) until it reaches basic.target. From there, systemd approaches the special target initrd.target. Before any file systems are mounted, it must be determined whether the system will resume from hibernation or proceed with normal boot. This is accomplished by systemd-hibernate-resume@.service which must be finished before local-fs-pre.target, so no filesystems can be mounted before the check is complete. When the root device becomes available, initrd-root-device.target is reached. If the root device can be mounted at /sysroot, the sysroot.mount unit becomes active and initrd-root-fs.target is reached. The service initrd-parse-etc.service scans /sysroot/etc/fstab for a possible /usr/ mount point and additional entries marked with the x-initrd.mount option. All entries found are mounted below /sysroot, and initrd-fs.target is reached. The service initrd-cleanup.service isolates to the initrd-switch-root.target, where cleanup services can run. As the very last step, the initrd-switch-root.service is activated, which will cause the system to switch its root to /sysroot.

```
                                               : (beginning identical to above)

                                               :

                                               v

                                         basic.target

                                               |                                 emergency.service

                        ______________________/|                                         |

                       /                       |                                         v

                       |            initrd-root-device.target                    emergency.target

                       |                       |

                       |                       v

                       |                  sysroot.mount

                       |                       |

                       |                       v

                       |             initrd-root-fs.target

                       |                       |

                       |                       v

                       v            initrd-parse-etc.service

                (custom initrd                 |

                 services...)                  v

                       |            (sysroot-usr.mount and

                       |             various mounts marked

                       |               with fstab option

                       |              x-initrd.mount...)

                       |                       |

                       |                       v

                       |                initrd-fs.target

                       \______________________ |

                                              \|

                                               v

                                          initrd.target

                                               |

                                               v

                                     initrd-cleanup.service

                                          isolates to

                                    initrd-switch-root.target

                                               |

                                               v

                        ______________________/|

                       /                       v

                       |        initrd-udevadm-cleanup-db.service

                       v                       |

                (custom initrd                 |

                 services...)                  |

                       \______________________ |

                                              \|

                                               v

                                   initrd-switch-root.target

                                               |

                                               v

                                   initrd-switch-root.service

                                               |

                                               v

                                     Transition to Host OS
```

## SYSTEM MANAGER SHUTDOWN
System shutdown with systemd also consists of various target units with some minimal ordering structure applied:

```
                                  (conflicts with  (conflicts with

                                    all system     all file system

                                     services)     mounts, swaps,

                                         |           cryptsetup/

                                         |           veritysetup

                                         |          devices, ...)

                                         |                |

                                         v                v

                                  shutdown.target    umount.target

                                         |                |

                                         \_______   ______/

                                                 \ /

                                                  v

                                         (various low-level

                                              services)

                                                  |

                                                  v

                                            final.target

                                                  |

            _____________________________________/ \_________________________________

           /                         |                        |                      \

           |                         |                        |                      |

           v                         v                        v                      v
systemd-reboot.service   systemd-poweroff.service   systemd-halt.service   systemd-kexec.service

           |                         |                        |                      |

           v                         v                        v                      v

    reboot.target             poweroff.target            halt.target           kexec.target
```

Commonly used system shutdown targets are emphasized.

Note that systemd-halt.service(8), systemd-reboot.service, systemd-poweroff.service and systemd-kexec.service will transition the system and server manager (PID 1) into the second phase of system shutdown (implemented in the systemd-shutdown binary), which will unmount any remaining file systems, kill any remaining processes and release any other remaining resources, in a simple and robust fashion, without taking any service or unit concept into account anymore. At that point, regular applications and resources are generally terminated and released already, the second phase hence operates only as safety net for everything that couldn't be stopped or released for some reason during the primary, unit-based shutdown phase described above.

## SEE ALSO
systemd(1), boot(7), systemd.special(7), systemd.target(5), systemd-halt.service(8), dracut(8)

## NOTES
1.

GRUB

https://www.gnu.org/software/grub/


daemon

title: daemon(7)

summary: Writing and packaging system daemons

text:
# daemon(7)

## NAME
daemon - Writing and packaging system daemons

## DESCRIPTION
A daemon is a service process that runs in the background and supervises the system or provides functionality to other processes. Traditionally, daemons are implemented following a scheme originating in SysV Unix. Modern daemons should follow a simpler yet more powerful scheme (here called "new-style" daemons), as implemented by systemd(1). This manual page covers both schemes, and in particular includes recommendations for daemons that shall be included in the systemd init system.

### SysV Daemons
When a traditional SysV daemon starts, it should execute the following steps as part of the initialization. Note that these steps are unnecessary for new-style daemons (see below), and should only be implemented if compatibility with SysV is essential.

1.Close all open file descriptors except standard input, output, and error (i.e. the first three file descriptors 0, 1, 2). This ensures that no accidentally passed file descriptor stays around in the daemon process. On Linux, this is best implemented by iterating through /proc/self/fd, with a fallback of iterating from file descriptor 3 to the value returned by getrlimit() for RLIMIT_NOFILE.

2.Reset all signal handlers to their default. This is best done by iterating through the available signals up to the limit of _NSIG and resetting them to SIG_DFL.

3.Reset the signal mask using sigprocmask().

4.Sanitize the environment block, removing or resetting environment variables that might negatively impact daemon runtime.

5.Call fork(), to create a background process.

6.In the child, call setsid() to detach from any terminal and create an independent session.

7.In the child, call fork() again, to ensure that the daemon can never re-acquire a terminal again. (This relevant if the program — and all its dependencies — does not carefully specify `O_NOCTTY` on each and every single `open()` call that might potentially open a TTY device node.)

8.Call exit() in the first child, so that only the second child (the actual daemon process) stays around. This ensures that the daemon process is re-parented to init/PID 1, as all daemons should be.

9.In the daemon process, connect /dev/null to standard input, output, and error.

10.In the daemon process, reset the umask to 0, so that the file modes passed to open(), mkdir() and suchlike directly control the access mode of the created files and directories.

11.In the daemon process, change the current directory to the root directory (/), in order to avoid that the daemon involuntarily blocks mount points from being unmounted.

12.In the daemon process, write the daemon PID (as returned by getpid()) to a PID file, for example /run/foobar.pid (for a hypothetical daemon "foobar") to ensure that the daemon cannot be started more than once. This must be implemented in race-free fashion so that the PID file is only updated when it is verified at the same time that the PID previously stored in the PID file no longer exists or belongs to a foreign process.

13.In the daemon process, drop privileges, if possible and applicable.

14.From the daemon process, notify the original process started that initialization is complete. This can be implemented via an unnamed pipe or similar communication channel that is created before the first fork() and hence available in both the original and the daemon process.

15.Call exit() in the original process. The process that invoked the daemon must be able to rely on that this exit() happens after initialization is complete and all external communication channels are established and accessible.

The BSD daemon() function should not be used, as it implements only a subset of these steps.

A daemon that needs to provide compatibility with SysV systems should implement the scheme pointed out above. However, it is recommended to make this behavior optional and configurable via a command line argument to ease debugging as well as to simplify integration into systems using systemd.

### New-Style Daemons
Modern services for Linux should be implemented as new-style daemons. This makes it easier to supervise and control them at runtime and simplifies their implementation.

For developing a new-style daemon, none of the initialization steps recommended for SysV daemons need to be implemented. New-style init systems such as systemd make all of them redundant. Moreover, since some of these steps interfere with process monitoring, file descriptor passing and other functionality of the init system, it is recommended not to execute them when run as new-style service.

Note that new-style init systems guarantee execution of daemon processes in a clean process context: it is guaranteed that the environment block is sanitized, that the signal handlers and mask is reset and that no left-over file descriptors are passed. Daemons will be executed in their own session, with standard input connected to /dev/null and standard output/error connected to the systemd-journald.service(8) logging service, unless otherwise configured. The umask is reset.

It is recommended for new-style daemons to implement the following:

1.If SIGTERM is received, shut down the daemon and exit cleanly.

2.If SIGHUP is received, reload the configuration files, if this applies.

3.Provide a correct exit code from the main daemon process, as this is used by the init system to detect service errors and problems. It is recommended to follow the exit code scheme as defined in the LSB recommendations for SysV init scripts[1].

4.If possible and applicable, expose the daemon's control interface via the D-Bus IPC system and grab a bus name as last step of initialization.

5.For integration in systemd, provide a .service unit file that carries information about starting, stopping and otherwise maintaining the daemon. See systemd.service(5) for details.

6.As much as possible, rely on the init system's functionality to limit the access of the daemon to files, services and other resources, i.e. in the case of systemd, rely on systemd's resource limit control instead of implementing your own, rely on systemd's privilege dropping code instead of implementing it in the daemon, and similar. See systemd.exec(5) for the available controls.

7.If D-Bus is used, make your daemon bus-activatable by supplying a D-Bus service activation configuration file. This has multiple advantages: your daemon may be started lazily on-demand; it may be started in parallel to other daemons requiring it — which maximizes parallelization and boot-up speed; your daemon can be restarted on failure without losing any bus requests, as the bus queues requests for activatable services. See below for details.

8.If your daemon provides services to other local processes or remote clients via a socket, it should be made socket-activatable following the scheme pointed out below. Like D-Bus activation, this enables on-demand starting of services as well as it allows improved parallelization of service start-up. Also, for state-less protocols (such as syslog, DNS), a daemon implementing socket-based activation can be restarted without losing a single request. See below for details.

9.If applicable, a daemon should notify the init system about startup completion or status updates via the sd_notify(3) interface.

10.Instead of using the syslog() call to log directly to the system syslog service, a new-style daemon may choose to simply log to standard error via fprintf(), which is then forwarded to syslog by the init system. If log levels are necessary, these can be encoded by prefixing individual log lines with strings like "<4>" (for log level 4 "WARNING" in the syslog priority scheme), following a similar style as the Linux kernel's printk() level system. For details, see sd-daemon(3) and systemd.exec(5).

11.As new-style daemons are invoked without a controlling TTY (but as their own session leaders) care should be taken to always specify `O_NOCTTY` on `open()` calls that possibly reference a TTY device node, so that no controlling TTY is accidentally acquired.

These recommendations are similar but not identical to the Apple MacOS X Daemon Requirements[2].

## ACTIVATION
New-style init systems provide multiple additional mechanisms to activate services, as detailed below. It is common that services are configured to be activated via more than one mechanism at the same time. An example for systemd: bluetoothd.service might get activated either when Bluetooth hardware is plugged in, or when an application accesses its programming interfaces via D-Bus. Or, a print server daemon might get activated when traffic arrives at an IPP port, or when a printer is plugged in, or when a file is queued in the printer spool directory. Even for services that are intended to be started on system bootup unconditionally, it is a good idea to implement some of the various activation schemes outlined below, in order to maximize parallelization. If a daemon implements a D-Bus service or listening socket, implementing the full bus and socket activation scheme allows starting of the daemon with its clients in parallel (which speeds up boot-up), since all its communication channels are established already, and no request is lost because client requests will be queued by the bus system (in case of D-Bus) or the kernel (in case of sockets) until the activation is completed.

### Activation on Boot
Old-style daemons are usually activated exclusively on boot (and manually by the administrator) via SysV init scripts, as detailed in the LSB Linux Standard Base Core Specification[1]. This method of activation is supported ubiquitously on Linux init systems, both old-style and new-style systems. Among other issues, SysV init scripts have the disadvantage of involving shell scripts in the boot process. New-style init systems generally employ updated versions of activation, both during boot-up and during runtime and using more minimal service description files.

In systemd, if the developer or administrator wants to make sure that a service or other unit is activated automatically on boot, it is recommended to place a symlink to the unit file in the .wants/ directory of either multi-user.target or graphical.target, which are normally used as boot targets at system startup. See systemd.unit(5) for details about the .wants/ directories, and systemd.special(7) for details about the two boot targets.

### Socket-Based Activation
In order to maximize the possible parallelization and robustness and simplify configuration and development, it is recommended for all new-style daemons that communicate via listening sockets to employ socket-based activation. In a socket-based activation scheme, the creation and binding of the listening socket as primary communication channel of daemons to local (and sometimes remote) clients is moved out of the daemon code and into the init system. Based on per-daemon configuration, the init system installs the sockets and then hands them off to the spawned process as soon as the respective daemon is to be started. Optionally, activation of the service can be delayed until the first inbound traffic arrives at the socket to implement on-demand activation of daemons. However, the primary advantage of this scheme is that all providers and all consumers of the sockets can be started in parallel as soon as all sockets are established. In addition to that, daemons can be restarted with losing only a minimal number of client transactions, or even any client request at all (the latter is particularly true for state-less protocols, such as DNS or syslog), because the socket stays bound and accessible during the restart, and all requests are queued while the daemon cannot process them.

New-style daemons which support socket activation must be able to receive their sockets from the init system instead of creating and binding them themselves. For details about the programming interfaces for this scheme provided by systemd, see sd_listen_fds(3) and sd-daemon(3). For details about porting existing daemons to socket-based activation, see below. With minimal effort, it is possible to implement socket-based activation in addition to traditional internal socket creation in the same codebase in order to support both new-style and old-style init systems from the same daemon binary.

systemd implements socket-based activation via .socket units, which are described in systemd.socket(5). When configuring socket units for socket-based activation, it is essential that all listening sockets are pulled in by the special target unit sockets.target. It is recommended to place a WantedBy=sockets.target directive in the [Install] section to automatically add such a dependency on installation of a socket unit. Unless DefaultDependencies=no is set, the necessary ordering dependencies are implicitly created for all socket units. For more information about sockets.target, see systemd.special(7). It is not necessary or recommended to place any additional dependencies on socket units (for example from multi-user.target or suchlike) when one is installed in sockets.target.

### Bus-Based Activation
When the D-Bus IPC system is used for communication with clients, new-style daemons should employ bus activation so that they are automatically activated when a client application accesses their IPC interfaces. This is configured in D-Bus service files (not to be confused with systemd service unit files!). To ensure that D-Bus uses systemd to start-up and maintain the daemon, use the SystemdService= directive in these service files to configure the matching systemd service for a D-Bus service. e.g.: For a D-Bus service whose D-Bus activation file is named org.freedesktop.RealtimeKit.service, make sure to set SystemdService=rtkit-daemon.service in that file to bind it to the systemd service rtkit-daemon.service. This is needed to make sure that the daemon is started in a race-free fashion when activated via multiple mechanisms simultaneously.

### Device-Based Activation
Often, daemons that manage a particular type of hardware should be activated only when the hardware of the respective kind is plugged in or otherwise becomes available. In a new-style init system, it is possible to bind activation to hardware plug/unplug events. In systemd, kernel devices appearing in the sysfs/udev device tree can be exposed as units if they are tagged with the string "systemd". Like any other kind of unit, they may then pull in other units when activated (i.e. plugged in) and thus implement device-based activation. systemd dependencies may be encoded in the udev database via the SYSTEMD_WANTS= property. See systemd.device(5) for details. Often, it is nicer to pull in services from devices only indirectly via dedicated targets. Example: Instead of pulling in bluetoothd.service from all the various bluetooth dongles and other hardware available, pull in bluetooth.target from them and bluetoothd.service from that target. This provides for nicer abstraction and gives administrators the option to enable bluetoothd.service via controlling a bluetooth.target.wants/ symlink uniformly with a command like enable of systemctl(1) instead of manipulating the udev ruleset.

### Path-Based Activation
Often, runtime of daemons processing spool files or directories (such as a printing system) can be delayed until these file system objects change state, or become non-empty. New-style init systems provide a way to bind service activation to file system changes. systemd implements this scheme via path-based activation configured in .path units, as outlined in systemd.path(5).

### Timer-Based Activation
Some daemons that implement clean-up jobs that are intended to be executed in regular intervals benefit from timer-based activation. In systemd, this is implemented via .timer units, as described in systemd.timer(5).

### Other Forms of Activation
Other forms of activation have been suggested and implemented in some systems. However, there are often simpler or better alternatives, or they can be put together of combinations of the schemes above. Example: Sometimes, it appears useful to start daemons or .socket units when a specific IP address is configured on a network interface, because network sockets shall be bound to the address. However, an alternative to implement this is by utilizing the Linux IP_FREEBIND/IPV6_FREEBIND socket option, as accessible via FreeBind=yes in systemd socket files (see systemd.socket(5) for details). This option, when enabled, allows sockets to be bound to a non-local, not configured IP address, and hence allows bindings to a particular IP address before it actually becomes available, making such an explicit dependency to the configured address redundant. Another often suggested trigger for service activation is low system load. However, here too, a more convincing approach might be to make proper use of features of the operating system, in particular, the CPU or I/O scheduler of Linux. Instead of scheduling jobs from userspace based on monitoring the OS scheduler, it is advisable to leave the scheduling of processes to the OS scheduler itself. systemd provides fine-grained access to the CPU and I/O schedulers. If a process executed by the init system shall not negatively impact the amount of CPU or I/O bandwidth available to other processes, it should be configured with CPUSchedulingPolicy=idle and/or IOSchedulingClass=idle. Optionally, this may be combined with timer-based activation to schedule background jobs during runtime and with minimal impact on the system, and remove it from the boot phase itself.

## INTEGRATION WITH SYSTEMD

### Writing systemd Unit Files
When writing systemd unit files, it is recommended to consider the following suggestions:

1.If possible, do not use the Type=forking setting in service files. But if you do, make sure to set the PID file path using PIDFile=. See systemd.service(5) for details.

2.If your daemon registers a D-Bus name on the bus, make sure to use Type=dbus in the service file if possible.

3.Make sure to set a good human-readable description string with Description=.

4.Do not disable DefaultDependencies=, unless you really know what you do and your unit is involved in early boot or late system shutdown.

5.Normally, little if any dependencies should need to be defined explicitly. However, if you do configure explicit dependencies, only refer to unit names listed on systemd.special(7) or names introduced by your own package to keep the unit file operating system-independent.

6.Make sure to include an [Install] section including installation information for the unit file. See systemd.unit(5) for details. To activate your service on boot, make sure to add a WantedBy=multi-user.target or WantedBy=graphical.target directive. To activate your socket on boot, make sure to add WantedBy=sockets.target. Usually, you also want to make sure that when your service is installed, your socket is installed too, hence add Also=foo.socket in your service file foo.service, for a hypothetical program foo.

### Installing systemd Service Files
At the build installation time (e.g. make install during package build), packages are recommended to install their systemd unit files in the directory returned by pkg-config systemd --variable=systemdsystemunitdir (for system services) or pkg-config systemd --variable=systemduserunitdir (for user services). This will make the services available in the system on explicit request but not activate them automatically during boot. Optionally, during package installation (e.g. rpm -i by the administrator), symlinks should be created in the systemd configuration directories via the enable command of the systemctl(1) tool to activate them automatically on boot.

Packages using autoconf(1) are recommended to use a configure script excerpt like the following to determine the unit installation path during source configuration:

```
PKG_PROG_PKG_CONFIG
AC_ARG_WITH([systemdsystemunitdir],

     [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,

     [with_systemdsystemunitdir=auto])
AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [

     def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)

     AS_IF([test "x$def_systemdsystemunitdir" = "x"],

   [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],

    [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])

    with_systemdsystemunitdir=no],

   [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
AS_IF([test "x$with_systemdsystemunitdir" != "xno"],

      [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
```

This snippet allows automatic installation of the unit files on systemd machines, and optionally allows their installation even on machines lacking systemd. (Modification of this snippet for the user unit directory is left as an exercise for the reader.)

Additionally, to ensure that make distcheck continues to work, it is recommended to add the following to the top-level Makefile.am file in automake(1)-based projects:

```
AM_DISTCHECK_CONFIGURE_FLAGS = \

  --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
```

Finally, unit files should be installed in the system with an automake excerpt like the following:

```
if HAVE_SYSTEMD
systemdsystemunit_DATA = \

  foobar.socket \

  foobar.service
endif
```

In the rpm(8) .spec file, use snippets like the following to enable/disable the service during installation/deinstallation. This makes use of the RPM macros shipped along systemd. Consult the packaging guidelines of your distribution for details and the equivalent for other package managers.

At the top of the file:

```
BuildRequires: systemd
%{?systemd_requires}
```

And as scriptlets, further down:

```
%post
%systemd_post foobar.service foobar.socket
%preun
%systemd_preun foobar.service foobar.socket
%postun
%systemd_postun
```

If the service shall be restarted during upgrades, replace the "%postun" scriptlet above with the following:

```
%postun
%systemd_postun_with_restart foobar.service
```

Note that "%systemd_post" and "%systemd_preun" expect the names of all units that are installed/removed as arguments, separated by spaces. "%systemd_postun" expects no arguments. "%systemd_postun_with_restart" expects the units to restart as arguments.

To facilitate upgrades from a package version that shipped only SysV init scripts to a package version that ships both a SysV init script and a native systemd service file, use a fragment like the following:

```
%triggerun -- foobar < 0.47.11-1
if /sbin/chkconfig --level 5 foobar ; then

  /bin/systemctl --no-reload enable foobar.service foobar.socket >/dev/null 2>&1 || :
fi
```

Where 0.47.11-1 is the first package version that includes the native unit file. This fragment will ensure that the first time the unit file is installed, it will be enabled if and only if the SysV init script is enabled, thus making sure that the enable status is not changed. Note that chkconfig is a command specific to Fedora which can be used to check whether a SysV init script is enabled. Other operating systems will have to use different commands here.

## PORTING EXISTING DAEMONS
Since new-style init systems such as systemd are compatible with traditional SysV init systems, it is not strictly necessary to port existing daemons to the new style. However, doing so offers additional functionality to the daemons as well as simplifying integration into new-style init systems.

To port an existing SysV compatible daemon, the following steps are recommended:

1.If not already implemented, add an optional command line switch to the daemon to disable daemonization. This is useful not only for using the daemon in new-style init systems, but also to ease debugging.

2.If the daemon offers interfaces to other software running on the local system via local AF_UNIX sockets, consider implementing socket-based activation (see above). Usually, a minimal patch is sufficient to implement this: Extend the socket creation in the daemon code so that sd_listen_fds(3) is checked for already passed sockets first. If sockets are passed (i.e. when sd_listen_fds() returns a positive value), skip the socket creation step and use the passed sockets. Secondly, ensure that the file system socket nodes for local AF_UNIX sockets used in the socket-based activation are not removed when the daemon shuts down, if sockets have been passed. Third, if the daemon normally closes all remaining open file descriptors as part of its initialization, the sockets passed from the init system must be spared. Since new-style init systems guarantee that no left-over file descriptors are passed to executed processes, it might be a good choice to simply skip the closing of all remaining open file descriptors if sockets are passed.

3.Write and install a systemd unit file for the service (and the sockets if socket-based activation is used, as well as a path unit file, if the daemon processes a spool directory), see above for details.

4.If the daemon exposes interfaces via D-Bus, write and install a D-Bus activation file for the service, see above for details.

## PLACING DAEMON DATA
It is recommended to follow the general guidelines for placing package files, as discussed in file-hierarchy(7).

## SEE ALSO
systemd(1), sd-daemon(3), sd_listen_fds(3), sd_notify(3), daemon(3), systemd.service(5), file-hierarchy(7)

## NOTES
1.

LSB recommendations for SysV init scripts

http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html

2.

Apple MacOS X Daemon Requirements

https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html


file-hierarchy

title: file-hierarchy(7)

summary: File system hierarchy overview

text:
# file-hierarchy(7)

## NAME
file-hierarchy - File system hierarchy overview

## DESCRIPTION
Operating systems using the systemd(1) system and service manager are organized based on a file system hierarchy inspired by UNIX, more specifically the hierarchy described in the File System Hierarchy[1] specification and hier(7), with various extensions, partially documented in the XDG Base Directory Specification[2] and XDG User Directories[3]. This manual page describes a more generalized, though minimal and modernized subset of these specifications that defines more strictly the suggestions and restrictions systemd makes on the file system hierarchy.

Many of the paths described here can be queried with the systemd-path(1) tool.

## GENERAL STRUCTURE
/

The file system root. Usually writable, but this is not required. Possibly a temporary file system ("tmpfs"). Not shared with other hosts (unless read-only).

/boot/

The boot partition used for bringing up the system. On EFI systems, this is possibly the EFI System Partition (ESP), also see systemd-gpt-auto-generator(8). This directory is usually strictly local to the host, and should be considered read-only, except when a new kernel or boot loader is installed. This directory only exists on systems that run on physical or emulated hardware that requires boot loaders.

/efi/

If the boot partition /boot/ is maintained separately from the EFI System Partition (ESP), the latter is mounted here. Tools that need to operate on the EFI system partition should look for it at this mount point first, and fall back to /boot/ — if the former doesn't qualify (for example if it is not a mount point or does not have the correct file system type MSDOS_SUPER_MAGIC).

/etc/

System-specific configuration. This directory may or may not be read-only. Frequently, this directory is pre-populated with vendor-supplied configuration files, but applications should not make assumptions about this directory being fully populated or populated at all, and should fall back to defaults if configuration is missing.

/home/

The location for normal user's home directories. Possibly shared with other systems, and never read-only. This directory should only be used for normal users, never for system users. This directory and possibly the directories contained within it might only become available or writable in late boot or even only after user authentication. This directory might be placed on limited-functionality network file systems, hence applications should not assume the full set of file API is available on this directory. Applications should generally not reference this directory directly, but via the per-user $HOME environment variable, or via the home directory field of the user database.

/root/

The home directory of the root user. The root user's home directory is located outside of /home/ in order to make sure the root user may log in even without /home/ being available and mounted.

/srv/

The place to store general server payload, managed by the administrator. No restrictions are made how this directory is organized internally. Generally writable, and possibly shared among systems. This directory might become available or writable only very late during boot.

/tmp/

The place for small temporary files. This directory is usually mounted as a "tmpfs" instance, and should hence not be used for larger files. (Use /var/tmp/ for larger files.) This directory is usually flushed at boot-up. Also, files that are not accessed within a certain time may be automatically deleted. If applications find the environment variable $TMPDIR set, they should use the directory specified in it instead of /tmp/ (see environ(7) and IEEE Std 1003.1[4] for details).

Since /tmp/ is accessible to other users of the system, it is essential that files and subdirectories under this directory are only created with mkstemp(3), mkdtemp(3), and similar calls. For more details, see Using /tmp/ and /var/tmp/ Safely[5].

## RUNTIME DATA
/run/

A "tmpfs" file system for system packages to place runtime data in. This directory is flushed on boot, and generally writable for privileged programs only. Always writable.

/run/log/

Runtime system logs. System components may place private logs in this directory. Always writable, even when /var/log/ might not be accessible yet.

/run/user/

Contains per-user runtime directories, each usually individually mounted "tmpfs" instances. Always writable, flushed at each reboot and when the user logs out. User code should not reference this directory directly, but via the $XDG_RUNTIME_DIR environment variable, as documented in the XDG Base Directory Specification[2].

## VENDOR-SUPPLIED OPERATING SYSTEM RESOURCES
/usr/

Vendor-supplied operating system resources. Usually read-only, but this is not required. Possibly shared between multiple hosts. This directory should not be modified by the administrator, except when installing or removing vendor-supplied packages.

/usr/bin/

Binaries and executables for user commands that shall appear in the $PATH search path. It is recommended not to place binaries in this directory that are not useful for invocation from a shell (such as daemon binaries); these should be placed in a subdirectory of /usr/lib/ instead.

/usr/include/

C and C++ API header files of system libraries.

/usr/lib/

Static, private vendor data that is compatible with all architectures (though not necessarily architecture-independent). Note that this includes internal executables or other binaries that are not regularly invoked from a shell. Such binaries may be for any architecture supported by the system. Do not place public libraries in this directory, use $libdir (see below), instead.

/usr/lib/arch-id/

Location for placing dynamic libraries into, also called $libdir. The architecture identifier to use is defined on Multiarch Architecture Specifiers (Tuples)[6] list. Legacy locations of $libdir are /usr/lib/, /usr/lib64/. This directory should not be used for package-specific data, unless this data is architecture-dependent, too. To query $libdir for the primary architecture of the system, invoke:

```
# systemd-path system-library-arch
```

/usr/share/

Resources shared between multiple packages, such as documentation, man pages, time zone information, fonts and other resources. Usually, the precise location and format of files stored below this directory is subject to specifications that ensure interoperability.

/usr/share/doc/

Documentation for the operating system or system packages.

/usr/share/factory/etc/

Repository for vendor-supplied default configuration files. This directory should be populated with pristine vendor versions of all configuration files that may be placed in /etc/. This is useful to compare the local configuration of a system with vendor defaults and to populate the local configuration with defaults.

/usr/share/factory/var/

Similar to /usr/share/factory/etc/, but for vendor versions of files in the variable, persistent data directory /var/.

## PERSISTENT VARIABLE SYSTEM DATA
/var/

Persistent, variable system data. Must be writable. This directory might be pre-populated with vendor-supplied data, but applications should be able to reconstruct necessary files and directories in this subhierarchy should they be missing, as the system might start up without this directory being populated. Persistency is recommended, but optional, to support ephemeral systems. This directory might become available or writable only very late during boot. Components that are required to operate during early boot hence shall not unconditionally rely on this directory.

/var/cache/

Persistent system cache data. System components may place non-essential data in this directory. Flushing this directory should have no effect on operation of programs, except for increased runtimes necessary to rebuild these caches.

/var/lib/

Persistent system data. System components may place private data in this directory.

/var/log/

Persistent system logs. System components may place private logs in this directory, though it is recommended to do most logging via the syslog(3) and sd_journal_print(3) calls.

/var/spool/

Persistent system spool data, such as printer or mail queues.

/var/tmp/

The place for larger and persistent temporary files. In contrast to /tmp/, this directory is usually mounted from a persistent physical file system and can thus accept larger files. (Use /tmp/ for small ephemeral files.) This directory is generally not flushed at boot-up, but time-based cleanup of files that have not been accessed for a certain time is applied. If applications find the environment variable $TMPDIR set, they should use the directory specified in it instead of /var/tmp/ (see environ(7) for details).

The same security restrictions as with /tmp/ apply: mkstemp(3), mkdtemp(3), and similar calls should be used. For further details about this directory, see Using /tmp/ and /var/tmp/ Safely[5].

## VIRTUAL KERNEL AND API FILE SYSTEMS
/dev/

The root directory for device nodes. Usually, this directory is mounted as a "devtmpfs" instance, but might be of a different type in sandboxed/containerized setups. This directory is managed jointly by the kernel and systemd-udevd(8), and should not be written to by other components. A number of special purpose virtual file systems might be mounted below this directory.

/dev/shm/

Place for POSIX shared memory segments, as created via shm_open(3). This directory is flushed on boot, and is a "tmpfs" file system. Since all users have write access to this directory, special care should be taken to avoid name clashes and vulnerabilities. For normal users, shared memory segments in this directory are usually deleted when the user logs out. Usually, it is a better idea to use memory mapped files in /run/ (for system programs) or $XDG_RUNTIME_DIR (for user programs) instead of POSIX shared memory segments, since these directories are not world-writable and hence not vulnerable to security-sensitive name clashes.

/proc/

A virtual kernel file system exposing the process list and other functionality. This file system is mostly an API to interface with the kernel and not a place where normal files may be stored. For details, see proc(5). A number of special purpose virtual file systems might be mounted below this directory.

/proc/sys/

A hierarchy below /proc/ that exposes a number of kernel tunables. The primary way to configure the settings in this API file tree is via sysctl.d(5) files. In sandboxed/containerized setups, this directory is generally mounted read-only.

/sys/

A virtual kernel file system exposing discovered devices and other functionality. This file system is mostly an API to interface with the kernel and not a place where normal files may be stored. In sandboxed/containerized setups, this directory is generally mounted read-only. A number of special purpose virtual file systems might be mounted below this directory.

/sys/fs/cgroup/

A virtual kernel file system exposing process control groups (cgroups). This file system is an API to interface with the kernel and not a place where normal files may be stored. On current systems running in the default "unified" mode, this directory serves as the mount point for the "cgroup2" filesystem, which provides a unified cgroup hierarchy for all resource controllers. On systems with non-default configurations, this directory may instead be a tmpfs filesystem containing mount points for various "cgroup" (v1) resource controllers; in such configurations, if "cgroup2" is mounted it will be mounted on /sys/fs/cgroup/unified/, but cgroup2 will not have resource controllers attached. In sandboxed/containerized setups, this directory may either not exist or may include a subset of functionality.

## COMPATIBILITY SYMLINKS
/bin/, /sbin/, /usr/sbin/

These compatibility symlinks point to /usr/bin/, ensuring that scripts and binaries referencing these legacy paths correctly find their binaries.

/lib/

This compatibility symlink points to /usr/lib/, ensuring that programs referencing this legacy path correctly find their resources.

/lib64/

On some architecture ABIs, this compatibility symlink points to $libdir, ensuring that binaries referencing this legacy path correctly find their dynamic loader. This symlink only exists on architectures whose ABI places the dynamic loader in this path.

/var/run/

This compatibility symlink points to /run/, ensuring that programs referencing this legacy path correctly find their runtime data.

## HOME DIRECTORY
User applications may want to place files and directories in the user's home directory. They should follow the following basic structure. Note that some of these directories are also standardized (though more weakly) by the XDG Base Directory Specification[2]. Additional locations for high-level user resources are defined by xdg-user-dirs[3].

~/.cache/

Persistent user cache data. User programs may place non-essential data in this directory. Flushing this directory should have no effect on operation of programs, except for increased runtimes necessary to rebuild these caches. If an application finds $XDG_CACHE_HOME set, it should use the directory specified in it instead of this directory.

~/.config/

Application configuration and state. When a new user is created, this directory will be empty or not exist at all. Applications should fall back to defaults should their configuration or state in this directory be missing. If an application finds $XDG_CONFIG_HOME set, it should use the directory specified in it instead of this directory.

~/.local/bin/

Executables that shall appear in the user's $PATH search path. It is recommended not to place executables in this directory that are not useful for invocation from a shell; these should be placed in a subdirectory of ~/.local/lib/ instead. Care should be taken when placing architecture-dependent binaries in this place, which might be problematic if the home directory is shared between multiple hosts with different architectures.

~/.local/lib/

Static, private vendor data that is compatible with all architectures.

~/.local/lib/arch-id/

Location for placing public dynamic libraries. The architecture identifier to use is defined on Multiarch Architecture Specifiers (Tuples)[6] list.

~/.local/share/

Resources shared between multiple packages, such as fonts or artwork. Usually, the precise location and format of files stored below this directory is subject to specifications that ensure interoperability. If an application finds $XDG_DATA_HOME set, it should use the directory specified in it instead of this directory.

## UNPRIVILEGED WRITE ACCESS
Unprivileged processes generally lack write access to most of the hierarchy.

The exceptions for normal users are /tmp/, /var/tmp/, /dev/shm/, as well as the home directory $HOME (usually found below /home/) and the runtime directory $XDG_RUNTIME_DIR (found below /run/user/) of the user, which are all writable.

For unprivileged system processes, only /tmp/, /var/tmp/ and /dev/shm/ are writable. If an unprivileged system process needs a private writable directory in /var/ or /run/, it is recommended to either create it before dropping privileges in the daemon code, to create it via tmpfiles.d(5) fragments during boot, or via the StateDirectory= and RuntimeDirectory= directives of service units (see systemd.unit(5) for details).

/tmp/, /var/tmp/ and /dev/shm/ should be mounted nosuid and nodev, which means that set-user-id mode and character or block special devices are not interpreted on those file systems. In general it is not possible to mount them noexec, because various programs use those directories for dynamically generated or optimized code, and with that flag those use cases would break. Using this flag is OK on special-purpose installations or systems where all software that may be installed is known and doesn't require such functionality. See the discussion of nosuid/nodev/noexec in mount(8) and PROT_EXEC in mmap(2).

## NODE TYPES
Unix file systems support different types of file nodes, including regular files, directories, symlinks, character and block device nodes, sockets and FIFOs.

It is strongly recommended that /dev/ is the only location below which device nodes shall be placed. Similarly, /run/ shall be the only location to place sockets and FIFOs. Regular files, directories and symlinks may be used in all directories.

## SYSTEM PACKAGES
Developers of system packages should follow strict rules when placing their files in the file system. The following table lists recommended locations for specific types of files supplied by the vendor.

Table 1. System package vendor files locations

Directory

Purpose

/usr/bin/

Package executables that shall appear in the $PATH executable search path, compiled for any of the supported architectures compatible with the operating system. It is not recommended to place internal binaries or binaries that are not commonly invoked from the shell in this directory, such as daemon binaries. As this directory is shared with most other packages of the system, special care should be taken to pick unique names for files placed here, that are unlikely to clash with other package's files.

/usr/lib/arch-id/

Public shared libraries of the package. As above, be careful with using too generic names, and pick unique names for your libraries to place here to avoid name clashes.

/usr/lib/package/

Private static vendor resources of the package, including private binaries and libraries, or any other kind of read-only vendor data.

/usr/lib/arch-id/package/

Private other vendor resources of the package that are architecture-specific and cannot be shared between architectures. Note that this generally does not include private executables since binaries of a specific architecture may be freely invoked from any other supported system architecture.

/usr/include/package/

Public C/C++ APIs of public shared libraries of the package.

Additional static vendor files may be installed in the

/usr/share/ hierarchy to the locations defined by the various relevant specifications.

The following directories shall be used by the package for local configuration and files created during runtime:

Table 2. System package variable files locations

Directory

Purpose

/etc/package/

System-specific configuration for the package. It is recommended to default to safe fallbacks if this configuration is missing, if this is possible. Alternatively, a tmpfiles.d(5) fragment may be used to copy or symlink the necessary files and directories from /usr/share/factory/ during boot, via the "L" or "C" directives.

/run/package/

Runtime data for the package. Packages must be able to create the necessary subdirectories in this tree on their own, since the directory is flushed automatically on boot. Alternatively, a tmpfiles.d(5) fragment may be used to create the necessary directories during boot, or the RuntimeDirectory= directive of service units may be used to create them at service startup (see systemd.unit(5) for details).

/run/log/package/

Runtime log data for the package. As above, the package needs to make sure to create this directory if necessary, as it will be flushed on every boot.

/var/cache/package/

Persistent cache data of the package. If this directory is flushed, the application should work correctly on next invocation, though possibly slowed down due to the need to rebuild any local cache files. The application must be capable of recreating this directory should it be missing and necessary. To create an empty directory, a tmpfiles.d(5) fragment or the CacheDirectory= directive of service units (see systemd.unit(5)) may be used.

/var/lib/package/

Persistent private data of the package. This is the primary place to put persistent data that does not fall into the other categories listed. Packages should be able to create the necessary subdirectories in this tree on their own, since the directory might be missing on boot. To create an empty directory, a tmpfiles.d(5) fragment or the StateDirectory= directive of service units (see systemd.unit(5)) may be used.

/var/log/package/

Persistent log data of the package. As above, the package should make sure to create this directory if necessary, possibly using tmpfiles.d(5) or LogsDirectory= (see systemd.unit(5)), as it might be missing.

/var/spool/package/

Persistent spool/queue data of the package. As above, the package should make sure to create this directory if necessary, as it might be missing.

## USER PACKAGES
Programs running in user context should follow strict rules when placing their own files in the user's home directory. The following table lists recommended locations in the home directory for specific types of files supplied by the vendor if the application is installed in the home directory. (User applications installed system-wide are covered by the rules outlined above for vendor files.)

Table 3. Vendor package file locations under the home directory of the user

Directory

Purpose

~/.local/bin/

Package executables that shall appear in the $PATH executable search path. It is not recommended to place internal executables or executables that are not commonly invoked from the shell in this directory, such as daemon executables. As this directory is shared with most other packages of the user, special care should be taken to pick unique names for files placed here, that are unlikely to clash with other package's files.

~/.local/lib/arch-id/

Public shared libraries of the package. As above, be careful with using overly generic names, and pick unique names for your libraries to place here to avoid name clashes.

~/.local/lib/package/

Private, static vendor resources of the package, compatible with any architecture, or any other kind of read-only vendor data.

~/.local/lib/arch-id/package/

Private other vendor resources of the package that are architecture-specific and cannot be shared between architectures.

Additional static vendor files may be installed in the

~/.local/share/ hierarchy, mirroring the subdirectories specified in the section "Vendor-supplied operating system resources" above.

The following directories shall be used by the package for per-user local configuration and files created during runtime:

Table 4. User package variable file locations

Directory

Purpose

~/.config/package/

User-specific configuration and state for the package. It is required to default to safe fallbacks if this configuration is missing.

$XDG_RUNTIME_DIR/package/

User runtime data for the package.

~/.cache/package/

Persistent cache data of the package. If this directory is flushed, the application should work correctly on next invocation, though possibly slowed down due to the need to rebuild any local cache files. The application must be capable of recreating this directory should it be missing and necessary.

## SEE ALSO
systemd(1),

hier(7), systemd-path(1), systemd-gpt-auto-generator(8), sysctl.d(5), tmpfiles.d(5), pkg-config(1), systemd.unit(5)

## NOTES
1.

File System Hierarchy

http://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html

2.

XDG Base Directory Specification

http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

3.

XDG User Directories

https://www.freedesktop.org/wiki/Software/xdg-user-dirs/

4.

IEEE Std 1003.1

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03

5.

Using /tmp/ and /var/tmp/ Safely

https://systemd.io/TEMPORARY_DIRECTORIES

6.

Multiarch Architecture Specifiers (Tuples)

https://wiki.debian.org/Multiarch/Tuples


kernel-command-line

title: kernel-command-line(7)

summary: Kernel command line parameters

text:
# kernel-command-line(7)

## NAME
kernel-command-line - Kernel command line parameters

## SYNOPSIS
/proc/cmdline

## DESCRIPTION
The kernel, the initial RAM disk (initrd) and basic userspace functionality may be configured at boot via kernel command line arguments. In addition, various systemd tools look at the EFI variable "SystemdOptions" (if available). Both sources are combined, but the kernel command line has higher priority. Please note that the EFI variable is only used by systemd tools, and is ignored by the kernel and other user space tools, so it is not a replacement for the kernel command line.

For command line parameters understood by the kernel, please see kernel-parameters.html[1] and bootparam(7).

For command line parameters understood by the initial RAM disk, please see dracut.cmdline(7), or the documentation of the specific initrd implementation of your installation.

## CORE OS COMMAND LINE ARGUMENTS
systemd.unit=, rd.systemd.unit=, systemd.dump_core, systemd.early_core_pattern=, systemd.crash_chvt, systemd.crash_shell, systemd.crash_reboot, systemd.confirm_spawn, systemd.service_watchdogs, systemd.show_status, systemd.status_unit_format=, systemd.log_target=, systemd.log_level=, systemd.log_location=, systemd.log_color, systemd.default_standard_output=, systemd.default_standard_error=, systemd.setenv=, systemd.machine_id=, systemd.unified_cgroup_hierarchy, systemd.legacy_systemd_cgroup_controller

Parameters understood by the system and service manager to control system behavior. For details, see systemd(1).

systemd.mask=, systemd.wants=, systemd.debug_shell

Additional parameters understood by systemd-debug-generator(8), to mask or start specific units at boot, or invoke a debug shell on tty9.

systemd.run=, systemd.run_success_action=, systemd.run_failure_action=

Additional parameters understood by systemd-run-generator(8), to run a command line specified on the kernel command line as system service after booting up.

systemd.early_core_pattern=

During early boot, the generation of core dump files is disabled until a core dump handler (if any) takes over. This parameter allows specifying an absolute path where core dump files should be stored until a handler is installed. The path should be absolute and may contain specifiers, see core(5) for details.

systemd.restore_state=

This parameter is understood by several system tools to control whether or not they should restore system state from the previous boot. For details, see systemd-backlight@.service(8) and systemd-rfkill.service(8).

systemd.volatile=

This parameter controls whether the system shall boot up in volatile mode. Takes a boolean argument, or the special value "state". If false (the default), normal boot mode is selected, the root directory and /var/ are mounted as specified on the kernel command line or /etc/fstab, or otherwise configured. If true, full state-less boot mode is selected. In this case the root directory is mounted as volatile memory file system ("tmpfs"), and only /usr/ is mounted from the file system configured as root device, in read-only mode. This enables fully state-less boots were the vendor-supplied OS is used as shipped, with only default configuration and no stored state in effect, as /etc/ and /var/ (as well as all other resources shipped in the root file system) are reset at boot and lost on shutdown. If this setting is set to "state" the root file system is mounted read-only, however /var/ is mounted as a volatile memory file system ("tmpfs"), so that the system boots up with the normal configuration applied, but all state reset at boot and lost at shutdown. If this setting is set to "overlay" the root file system is set up as "overlayfs" mount combining the read-only root directory with a writable "tmpfs", so that no modifications are made to disk, but the file system may be modified nonetheless with all changes being lost at reboot. For details, see systemd-volatile-root.service(8) and systemd-fstab-generator(8).

quiet

Parameter understood by both the kernel and the system and service manager to control console log verbosity. For details, see systemd(1).

debug

Parameter understood by both the kernel and the system and service manager to control console log verbosity. For details, see systemd(1).

-b, rd.emergency, emergency, rd.rescue, rescue, single, s, S, 1, 2, 3, 4, 5

Parameters understood by the system and service manager, as compatibility and convenience options. For details, see systemd(1).

locale.LANG=, locale.LANGUAGE=, locale.LC_CTYPE=, locale.LC_NUMERIC=, locale.LC_TIME=, locale.LC_COLLATE=, locale.LC_MONETARY=, locale.LC_MESSAGES=, locale.LC_PAPER=, locale.LC_NAME=, locale.LC_ADDRESS=, locale.LC_TELEPHONE=, locale.LC_MEASUREMENT=, locale.LC_IDENTIFICATION=

Parameters understood by the system and service manager to control locale and language settings. For details, see systemd(1).

fsck.mode=, fsck.repair=

Parameters understood by the file system checker services. For details, see systemd-fsck@.service(8).

quotacheck.mode=

Parameter understood by the file quota checker service. For details, see systemd-quotacheck.service(8).

systemd.journald.forward_to_syslog=, systemd.journald.forward_to_kmsg=, systemd.journald.forward_to_console=, systemd.journald.forward_to_wall=

Parameters understood by the journal service. For details, see systemd-journald.service(8).

vconsole.keymap=, vconsole.keymap_toggle=, vconsole.font=, vconsole.font_map=, vconsole.font_unimap=

Parameters understood by the virtual console setup logic. For details, see vconsole.conf(5).

udev.log_level=, rd.udev.log_level=, udev.children_max=, rd.udev.children_max=, udev.exec_delay=, rd.udev.exec_delay=, udev.event_timeout=, rd.udev.event_timeout=, udev.timeout_signal=, rd.udev.timeout_signal=, udev.blockdev_read_only, rd.udev.blockdev_read_only, net.ifnames=, net.naming-scheme=

Parameters understood by the device event managing daemon. For details, see systemd-udevd.service(8).

plymouth.enable=

May be used to disable the Plymouth boot splash. For details, see plymouth(8).

luks=, rd.luks=, luks.crypttab=, rd.luks.crypttab=, luks.name=, rd.luks.name=, luks.uuid=, rd.luks.uuid=, luks.options=, rd.luks.options=, luks.key=, rd.luks.key=

Configures the LUKS full-disk encryption logic at boot. For details, see systemd-cryptsetup-generator(8).

fstab=, rd.fstab=

Configures the /etc/fstab logic at boot. For details, see systemd-fstab-generator(8).

root=, rootfstype=, rootflags=, ro, rw

Configures the root file system and its file system type and mount options, as well as whether it shall be mounted read-only or read-write initially. For details, see systemd-fstab-generator(8).

mount.usr=, mount.usrfstype=, mount.usrflags=

Configures the /usr file system (if required) and its file system type and mount options. For details, see systemd-fstab-generator(8).

veritytab=, rd.veritytab=, roothash=, systemd.verity=, rd.systemd.verity=, systemd.verity_root_data=, systemd.verity_root_hash=, systemd.verity.root_options=

Configures the integrity protection root hash for the root file system, and other related parameters. For details, see systemd-veritysetup-generator(8).

systemd.gpt_auto=, rd.systemd.gpt_auto=

Configures whether GPT based partition auto-discovery shall be attempted. For details, see systemd-gpt-auto-generator(8).

systemd.default_timeout_start_sec=

Overwrites the default start job timeout DefaultTimeoutStartSec= at boot. For details, see systemd-system.conf(5).

systemd.watchdog_device=

Overwrites the watchdog device path WatchdogDevice=. For details, see systemd-system.conf(5).

systemd.cpu_affinity=

Overrides the CPU affinity mask for the service manager and the default for all child processes it forks. This takes precedence over CPUAffinity=, see systemd-system.conf(5) for details.

modules_load=, rd.modules_load=

Load a specific kernel module early at boot. For details, see systemd-modules-load.service(8).

resume=, resumeflags=

Enables resume from hibernation using the specified device and mount options. All fstab(5)-like paths are supported. For details, see systemd-hibernate-resume-generator(8).

systemd.firstboot=

Takes a boolean argument, defaults to on. If off, systemd-firstboot.service(8) will not query the user for basic system settings, even if the system boots up for the first time and the relevant settings are not initialized yet. Not to be confused with systemd.condition-first-boot= (see below), which overrides the result of the ConditionFirstBoot= unit file condition, and thus controls more than just systemd-firstboot.service behaviour.

systemd.condition-needs-update=

Takes a boolean argument. If specified, overrides the result of ConditionNeedsUpdate= unit condition checks. See systemd.unit(5) for details.

systemd.condition-first-boot=

Takes a boolean argument. If specified, overrides the result of ConditionFirstBoot= unit condition checks. See systemd.unit(5) for details. Not to be confused with systemd.firstboot= which only controls behaviour of the systemd-firstboot.service system service but has no effect on the condition check (see above).

systemd.clock-usec=

Takes a decimal, numeric timestamp in µs since January 1st 1970, 00:00am, to set the system clock to. The system time is set to the specified timestamp early during boot. It is not propagated to the hardware clock (RTC).

systemd.random-seed=

Takes a base64 encoded random seed value to credit with full entropy to the kernel's random pool during early service manager initialization. This option is useful in testing environments where delays due to random pool initialization in entropy starved virtual machines shall be avoided. Note that if this option is used the seed is accessible to unprivileged programs from /proc/cmdline. This option is hence a security risk when used outside of test systems, since the (possibly) only seed used for initialization of the kernel's entropy pool might be easily acquired by unprivileged programs.

It is recommended to pass 512 bytes of randomized data (as that matches the Linux kernel pool size), which may be generated with a command like the following:

```
dd if=/dev/urandom bs=512 count=1 status=none | base64 -w 0
```

Again: do not use this option outside of testing environments, it's a security risk elsewhere, as secret key material derived from the entropy pool can possibly be reconstructed by unprivileged programs.

systemd.hostname=

Accepts a hostname to set during early boot. If specified takes precedence over what is set in /etc/hostname. Note that this does not bar later runtime changes to the hostname, it simply controls the initial hostname set during early boot.

## SEE ALSO
systemd(1), systemd-system.conf(5), bootparam(7), dracut.cmdline(7), systemd-debug-generator(8), systemd-fsck@.service(8), systemd-quotacheck.service(8), systemd-journald.service(8), systemd-vconsole-setup.service(8), systemd-udevd.service(8), plymouth(8), systemd-cryptsetup-generator(8), systemd-veritysetup-generator(8), systemd-fstab-generator(8), systemd-gpt-auto-generator(8), systemd-volatile-root.service(8), systemd-modules-load.service(8), systemd-backlight@.service(8), systemd-rfkill.service(8), systemd-hibernate-resume-generator(8), systemd-firstboot.service(8), bootctl(1)

## NOTES
1.

kernel-parameters.html

https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html