在Debian上,/usr/lib/systemd/*/*.service安装了一些系统服务,例如:
/usr/lib/systemd/user/org.gnome.Evince.service
/usr/lib/systemd/user/pulseaudio.service
/usr/lib/systemd/user/gpg-agent.service其他服务(实际上更多)在/lib/systemd/*/*.service中
/lib/systemd/system/networking.service
/lib/systemd/system/sddm.service
/lib/systemd/system/apache2.service
/lib/systemd/system/dm-event.service
/lib/systemd/system/ModemManager.service/lib/systemd中有文件夹:
/lib/systemd/network/
/lib/systemd/system/
/lib/systemd/system-generators/
/lib/systemd/system-preset/
/lib/systemd/system-shutdown/
/lib/systemd/system-sleep//usr/lib/systemd:
/usr/lib/systemd/boot/
/usr/lib/systemd/catalog/
/usr/lib/systemd/scripts/
/usr/lib/systemd/system/
/usr/lib/systemd/user/
/usr/lib/systemd/user-environment-generators/
/usr/lib/systemd/user-generators/
/usr/lib/systemd/user-preset/那么,这两个目录有什么区别呢?Systemd文件根本没有提到/lib/systemd。
它是由发行版还是软件上游选择的地方?例如,对于Apache Debian使用/lib/systemd/system/apache2.service,但是建筑 /usr/lib/systemd/system/apache.service (看起来buildroot也使用/lib/systemd )。
它是否受到/usr合并的影响?
每个人都关心/usr/lib/systemd/system和/etc/system/之间的差异 (它触及了这个话题显示Units of installed packages的路径是特定于发行版的- Centos 7使用/usr/lib/systemd/system,Debian /lib/systemd/system,但Debian使用两种路径)。
发布于 2019-11-02 07:34:05
消息来源回答了这个问题,它确实受到/usr合并的影响,请参见LOOKUP_PATHS_SPLIT_USR:
src/便携式/portable.c:we force looking inside of /lib/systemd/system/ for units too, as we might be compiled for a split-usr system but the image might be a legacy-usr one
/* Then, send unit file data to the parent (or/and add it to the hashmap).
* For that we use our usual unit discovery logic. Note that we force looking
* inside of /lib/systemd/system/ for units too, as we might be
* compiled for a split-usr system but the image might be a legacy-usr one. */
r = lookup_paths_init(&paths, UNIT_FILE_SYSTEM, LOOKUP_PATHS_SPLIT_USR, where);(为提高可读性而重新格式化的注释)
src/shared/path-lookup.c:添加"/lib/systemd/system" if标志LOOKUP_PATHS_SPLIT_USR
case UNIT_FILE_SYSTEM:
add = strv_new(
/* If you modify this you also want to modify
* systemdsystemunitpath= in systemd.pc.in! */
...
"/usr/local/lib/systemd/system",
SYSTEM_DATA_UNIT_PATH,
"/usr/lib/systemd/system",
STRV_IFNOTNULL(flags & LOOKUP_PATHS_SPLIT_USR ? "/lib/systemd/system" : NULL),
...src/core/systemd.pc.in:/usr/lib/systemd/system和/lib/systemd/system
systemdsystemunitpath=${systemdsystemconfdir}:/etc/systemd/system:\
/run/systemd/system\:/usr/local/lib/systemd/system:${systemdsystemunitdir}\:
/usr/lib/systemd/system:/lib/systemd/system(为了更好的可读性而重新格式化)
来自799b210267 (“路径查找:将标志添加到可选的强制检查拆分-usr单元dirs”)的提交消息:
When we look into a portable service image it might contain the unit
files in split-usr directories rather than merged-usr directories as on
the host. Hence, let#s add a flag that checking all dirs can be forced.https://unix.stackexchange.com/questions/550001
复制相似问题