「systemd」- System and Service Manager

认识

官网:https://systemd.io/
文档:https://systemd.io/
仓库:https://github.com/systemd/systemd

systemd is a suite of basic building blocks for a Linux system. It provides a system and service manager that runs as PID 1 and starts the rest of the system. systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux control groups, maintains mount and automount points, and implements an elaborate transactional dependency-based service control logic. systemd supports SysV and LSB init scripts and works as a replacement for sysvinit. Other parts include a logging daemon, utilities to control basic system configuration like the hostname, date, locale, maintain a list of logged-in users and running containers and virtual machines, system accounts, runtime directories and settings, and daemons to manage simple network configuration, network time synchronization, log forwarding, and name resolution. See Lennart’s blog story for a longer introduction, and the three status updates since then. Also see the Wikipedia article. If you are wondering whether systemd is for you, please have a look at this comparison of init systems by one of the creators of systemd. systemd 是现代 Linux 系统中的标准初始化系统,负责启动用户空间进程和服务,以及管理系统资源和进程。简而言之,systemd 是个 GNU/Linux 操作系统上的系统和服务管理器。

Spelling

Yes, it is written systemd, not system D or System D, or even SystemD. And it isn’t system d either. Why? Because it’s a system daemon, and under Unix/Linux those are in lower case, and get suffixed with a lower case d. And since systemd manages the system, it’s called systemd. It’s that simple. But then again, if all that appears too simple to you, call it (but never spell it!) System Five Hundred since D is the roman numeral for 500 (this also clarifies the relation to System V, right?). The only situation where we find it OK to use an uppercase letter in the name (but don’t like it either) is if you start a sentence with systemd. On high holidays you may also spell it sÿstëmd. But then again, Système D is not an acceptable spelling and something completely different (though kinda fitting).

组成

Unit

systemd 使用了一种称为”unit”的概念,用来描述系统组件和服务。

性质

它提供了许多功能,包括并行启动、单个进程管理多个服务、事件通知、快速启动、日志记录和跟踪等。
systemd 还提供了一个单一的接口来管理所有系统配置和服务,而不是像早期的初始化系统那样使用多个脚本文件。

container/nspawn tools/systemd-nspawn

https://0pointer.de/blog/projects/socket-activated-containers.html

https://0pointer.net/blog/systemd-for-administrators-part-xxi.html

https://systemd.io/CONTAINER_INTERFACE/

https://wiki.archlinux.org/title/Systemd-nspawn

构建

安装 systemd 的方法

使用源码安装

参考 LFS/Systemd-231: http://www.linuxfromscratch.org/lfs/view/7.10-systemd/chapter06/systemd.html

从发行版的源中安装

较新的发行版中已经预装了 systemd,不需要手动安装。

# Kali GNU/Linux Rolling
apt-get install systemd

应用

最初,systemd 是由 Red Hat 开发的,现在已经成为了许多 Linux 发行版的标准。