What I mean under the question is: is there a way to dump the ordered list (like pstree does for processes) to see how systemd executed the supplied set of units, i.e. the tree after the dependencies were resolved and jobs were queued for the execution? I know that you can do it by analysing systemd state data, but is there a quick way to see such a tree? It would help a lot in failure investigation (e.g. if you see that the boot process was stuck on some unit you would be able to pinpoint the approximate location for your deeper investigation.
systemd-analyze is your friend.
systemd-analyze critical-chain outputs blocking tree of daemons.
Mine for example:
graphical.target @20.211s └─multi-user.target @20.211s └─nginx.service @19.348s +862ms └─network.target @19.347s └─NetworkManager.service @10.315s +9.031s └─basic.target @10.312s └─timers.target @10.311s └─systemd-tmpfiles-clean.timer @10.311s └─sysinit.target @10.295s └─systemd-update-utmp.service @10.167s +127ms └─systemd-tmpfiles-setup.service @10.124s +41ms └─local-fs.target @10.097s └─home-entd-Downloads.mount @10.093s +2ms └─home.mount @9.326s +672ms └─firstname.lastname@example.org @8.472s +696ms └─dev-sda6.device @8.471s
NetworkManager in example basically holding entire bootup.
If you want to have more detailed view you can render entire execution chain in a svg file.
systemd-analyze plot > something.svg outputs entire chain (120+ modules) as progress bars to high-res svg file which show states, that are blocked and another problems.
Finally you have
systemd-analyze dot tool which outputs dot file which outputs entire hierarchy:
systemd-analyze dot | dot -Tpng -o stuff.png
with dot tool you can output it as ps and svg files too.
All of above tools are built-in in systemd-analyze tool which comes by default with systemd in archlinux at least. I think there is some 3rd party projects dealing with it too.
Not sure I properly understand the question, but there are tree visualizations available with the following commands :
sudo systemctl status
And also :
sudo systemctl list-dependencies
Hope this helps :)
Also, it might be useful for other purposes to build a tree of the systemctl symlinks folders:
It was actually really useful to figure out old / buggy units that were slowing down my system startup, to disable them afterwards using the
systemctl disable command.
That said I really agree with the OP that this basic functionality should be given via command-line tools, and not a graphical tool... What if you cannot start X ? How you deal with your svg file then ?
Actually, there is a way. If you cannot use
scp (ssh tool) to fetch your file on another computer,
fbi might actually help you :)
sudo systemd-analyze plot > /home/user/startup.svg fbi /home/user/startup.svg
Worked in my TTYs. Just navigate inside the picture with arrows. There are zooming options, to list do
Again I hope this helps. It is available in Archlinux and Ubuntu repos.
EDIT 2 :
fbi doesn't work over ssh. You can do X forwarding like this
ssh -Y user@server, but you need a X server running on your remote server.
The best bet here is to use
sshfs. It works GREAT in userspace, for instance with nautilus. There's a little configuration to do, see:
sudo vim /etc/fuse.conf #type a, uncomment the user_allow_other line and ESC :wq sudo mkdir /mnt/yourmountingdir sudo chown user:user /mnt/yourmountingdir sshfs email@example.com:/home/user /mnt/yourmountingdir/ -o allow_other #Asks for host trusting and password sudo fusermount -u /mnt/yourmountingdir/ #To disconnect and unmount
May still not fully answering your question but try with
systemd-analyze critical-chain --fuzz 1h
Note you can also specify units to see their critical-chain, so you're not limited to the multi-user.target
systemd-analyze critical-chain network.target local-fs.target
Hope this helps