Linux
沒有default.target,systemd如何啟動?
systemd 文件和各種線上資源都聲明 systemd 應該(預設情況下)啟動名為“default.target”的“特殊”目標。可以通過 systemctl set-default 更改此設置,這基本上是從 default.target 到所需目標的符號連結。
但是在我的系統中沒有這樣的文件。沒有/etc/systemd/system/default.target,沒有/usr/lib/systemd/system/default.target(實際上這個文件在整個系統中是不存在的)。系統仍在啟動。我的問題是怎麼可能?
(當然我可以自己做一個符號連結,我只是想知道如何在沒有 default.target 的情況下定義一個預設值)
附加資訊:
# systemctl get-default graphical.target
所以我的預設目標是graphics.target。但它在哪裡(以及如何)定義?
# find /usr/lib -iname "default.target" # no results # find /etc -iname "default.target" # no results # lsb_release -a LSB Version: n/a Distributor ID: Gentoo Description: Gentoo Base System release 2.4.1 Release: 2.4.1 Codename: n/a # systemctl list-units --type=target UNIT LOAD ACTIVE SUB DESCRIPTION basic.target loaded active active Basic System getty.target loaded active active Login Prompts graphical.target loaded active active Graphical Interface local-fs-pre.target loaded active active Local File Systems (Pre) local-fs.target loaded active active Local File Systems machines.target loaded active active Containers multi-user.target loaded active active Multi-User System network-online.target loaded active active Network is Online network.target loaded active active Network nss-lookup.target loaded active active Host and Network Name Lookups paths.target loaded active active Paths remote-fs.target loaded active active Remote File Systems slices.target loaded active active Slices sockets.target loaded active active Sockets sound.target loaded active active Sound Card swap.target loaded active active Swap sysinit.target loaded active active System Initialization timers.target loaded active active Timers LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 18 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'.
Gentoo將 systemd 文件的位置更改
/lib/systemd
為 2017 年 7 月。在我的系統上,我可以在以下位置看到預設符號連結/lib/systemd/system
:$ ls -l /lib/systemd/system/default.target lrwxrwxrwx 1 root root 16 Apr 2 15:48 /lib/systemd/system/default.target -> graphical.target
如果您添加符號連結
/etc/systemd/system
(就像這樣systemctl set-default
做),它將覆蓋分發的預設設置。