I was investigating and issue with duplicity when I stumbled with systemd-analyze
.
So I started to see what was contributing for my boot time and after that I started too see how to improved.
This is by no means a guide, but just what I changed to improve.
You can use sudo systemd-analyze blame
to see load time for every programs that loads at boot time and sudo systemd-analyze critical-chain
to basically see the critical programs that you could focus on.
The results, or how you interpret them depends on your system and what you need to load.
My critical-chain (before)
sudo systemd-analyze critical-chain
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.
graphical.target @19.908s
└─multi-user.target @19.908s
└─cups-browsed.service @19.908s
└─org.cups.cupsd.service @19.606s +299ms
└─network-online.target @19.598s
└─network.target @19.597s
└─dhcpcd@eno1.service @2.841s +16.755s
└─basic.target @2.828s
└─sockets.target @2.827s
└─snapd.socket @2.826s +792us
└─sysinit.target @2.820s
└─systemd-timesyncd.service @2.321s +498ms
└─systemd-tmpfiles-setup.service @2.210s +48ms
└─local-fs.target @2.203s
└─var-lib-snapd-snap-core18-1880.mount @1.603s +598ms
└─dev-loop10.device @2.200s +38ms
From this I saw 2 things to focus:
- I’m not really using snaps right now
- dhcpcd is taking 16s ou the 19s
Disabling ou removing programs you don’t need
By looking at your results, if you see something your are not really using you can disable the service ou remove the program.
In my case I removed snapd
.
yay -Rns snapd
Replacing dhcpcd with systemd-networkd
Digging around I saw somebody suggesting using systemd-networkd instead of dhcpcd. I gave it a try.
I disabled the service (including NetworkManager):
sudo systemctl disable dhcpcd@eno1.service
sudo systemctl disable NetworkManager-wait-online
sudo systemctl disable NetworkManager
Also removed nm-applet
from my startup list in i3
.
# exec --no-startup-id nm-applet
Enabling systemd-networkd
As always check the wiki for more details.
You must create a configuration file for each of your network cards. In my case I’m only using a wired connection.
sudo vi /etc/systemd/network/20-wired.network
[Match]
Name=eno1
[Network]
DHCP=yes
And the enable the service:
sudo systemctl enable systemd-networkd
sudo systemctl enable systemd-resolved
I also installed a notification service:
yay -S networkd-notify-git
And added it to my i3
startup list:
exec --no-startup-id networkd-notify
My critical-chain (after)
It’s better for sure and I learned a few new things.
sudo systemd-analyze critical-chain
The time when unit became active or started is printed after>
The time the unit took to start is printed after the "+" cha>
graphical.target @9.564s
└─multi-user.target @9.564s
└─cups-browsed.service @9.563s
└─org.cups.cupsd.service @9.402s +159ms
└─network-online.target @9.400s
└─systemd-networkd-wait-online.service @1.533s +7.86>
└─systemd-networkd.service @1.046s +484ms
└─systemd-udevd.service @502ms +535ms
└─systemd-tmpfiles-setup-dev.service @470ms +2>
└─kmod-static-nodes.service @383ms +13ms
└─systemd-journald.socket @377ms
└─system.slice @367ms
└─-.slice @367ms