ubuntu:boot:speed_up_boot
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ubuntu:boot:speed_up_boot [2019/11/25 22:06] – peter | ubuntu:boot:speed_up_boot [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Ubuntu - Boot - Speed up boot ====== | ====== Ubuntu - Boot - Speed up boot ====== | ||
+ | |||
+ | ===== Check startup time ===== | ||
+ | |||
+ | Check how long it takes to boot: | ||
+ | |||
+ | <code bash> | ||
+ | systemd-analyze time | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Startup finished in 16.619s (firmware) + 10.201s (loader) + 36.729s (kernel) + 41.034s (userspace) = 1min 44.586s | ||
+ | graphical.target reached after 23.396s in userspace | ||
+ | </ | ||
+ | |||
+ | This shows how long it takes for the Linux kernel and base system services to load. | ||
+ | |||
+ | It shows you how much time is required, from the moment the kernel is loaded until you are dropped to the Linux console. | ||
+ | |||
+ | It doesn’t account for the time your graphical interface requires to boot up. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Check startup time for the graphical interface to initialize ===== | ||
+ | |||
+ | You can also see the time required by the graphical interface to initialize with this command: | ||
+ | |||
+ | <code bash> | ||
+ | systemd-analyze critical-chain graphical.target | ||
+ | </ | ||
+ | |||
+ | returns | ||
+ | |||
+ | <code bash> | ||
+ | The time after the unit is active or started is printed after the " | ||
+ | The time the unit takes to start is printed after the " | ||
+ | |||
+ | graphical.target @23.396s | ||
+ | └─multi-user.target @23.396s | ||
+ | └─libvirt-guests.service @23.378s +18ms | ||
+ | └─libvirtd.service @3.189s +20.187s | ||
+ | └─network.target @3.189s | ||
+ | └─NetworkManager.service @2.333s +855ms | ||
+ | └─dbus.service @2.223s | ||
+ | └─basic.target @2.207s | ||
+ | └─sockets.target @2.207s | ||
+ | └─docker.socket @2.206s +965us | ||
+ | └─sysinit.target @2.203s | ||
+ | └─apparmor.service @1.458s +745ms | ||
+ | └─local-fs.target @1.457s | ||
+ | └─run-user-1000-gvfs.mount @15.641s | ||
+ | └─run-user-1000.mount @14.700s | ||
+ | └─swap.target @1.607s | ||
+ | └─dev-mapper-ubuntu\x2d\x2dvg\x2dswap_1.swap @1.565s +36ms | ||
+ | └─dev-mapper-ubuntu\x2d\x2dvg\x2dswap_1.device @1.565s | ||
+ | </ | ||
+ | |||
+ | |||
+ | This shows that the graphical user interface loaded in 23.396 seconds. | ||
+ | |||
+ | <WRAP info> | ||
+ | This doesn’t account for the time required to load desktop utilities. | ||
+ | |||
+ | To enable/ | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Check which services takes most time ===== | ||
+ | |||
+ | |||
+ | Use the following command to check which service takes most of time | ||
+ | |||
+ | <code bash> | ||
+ | systemd-analyze blame | ||
+ | </ | ||
+ | |||
+ | returns | ||
+ | |||
+ | <code bash> | ||
+ | | ||
+ | | ||
+ | | ||
+ | 5.774s systemd-networkd-wait-online.service | ||
+ | 3.654s docker.service | ||
+ | 1.841s apt-daily-upgrade.service | ||
+ | 1.820s snapd.service | ||
+ | 1.487s plymouth-quit-wait.service | ||
+ | 993ms dev-mapper-ubuntu\x2d\x2dvg\x2droot.device | ||
+ | 855ms NetworkManager.service | ||
+ | 768ms fwupd.service | ||
+ | 752ms udisks2.service | ||
+ | 745ms apparmor.service | ||
+ | 736ms networkd-dispatcher.service | ||
+ | 725ms snap-gnome\x2dcalculator-544.mount | ||
+ | 710ms networking.service | ||
+ | 697ms thermald.service | ||
+ | 680ms snap-netbeans-10.mount | ||
+ | 674ms snap-gnome\x2dlogs-81.mount | ||
+ | 661ms systemd-resolved.service | ||
+ | 643ms systemd-timesyncd.service | ||
+ | 642ms systemd-logind.service | ||
+ | 558ms ModemManager.service | ||
+ | 550ms apport.service | ||
+ | 544ms gpu-manager.service | ||
+ | 528ms motd-news.service | ||
+ | 502ms grub-common.service | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | |||
+ | <WRAP info> | ||
+ | You can navigate the list with your arrow keys or **PAGE UP** and **PAGE DOWN**. | ||
+ | |||
+ | Press **q** to quit. | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Check the critical chain ===== | ||
+ | |||
+ | Analyze each major process to determine how long it takes to run. | ||
+ | |||
+ | For example, to get further information on the AppArmor Service, to see if you can disable it or speed it up, use: | ||
+ | |||
+ | <code bash> | ||
+ | systemctl status apparmor.service | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | < | ||
+ | ● apparmor.service - AppArmor initialization | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | | ||
+ | Process: 1181 ExecStart=/ | ||
+ | Main PID: 1181 (code=exited, | ||
+ | |||
+ | Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable. | ||
+ | </ | ||
+ | |||
+ | Also check the journal: | ||
+ | |||
+ | <code bash> | ||
+ | journalctl -u apparmor.service | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | < | ||
+ | -- Logs begin at Sun 2019-11-24 02:17:01 GMT, end at Mon 2019-11-25 21:05:42 GMT. -- | ||
+ | -- No entries -- | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Disabling auto-start of services during boot ===== | ||
+ | |||
+ | If you want to disable auto-starting of services during boot you can use the following command: | ||
+ | |||
+ | <code bash> | ||
+ | sudo systemctl disable some-time-eater-service.service --now | ||
+ | </ | ||
+ | |||
+ | However, you might want to see which other services needs the service in question. To check use the following command | ||
+ | |||
+ | <code bash> | ||
+ | systemctl list-dependencies some-service.service --reverse | ||
+ | </ | ||
+ | |||
+ | Note: Replace **some-service.service** with actual service name. | ||
+ | |||
+ | <WRAP important> | ||
+ | |||
+ | **WARNING: | ||
+ | |||
+ | Try to see what those may be: | ||
+ | |||
+ | <code bash> | ||
+ | systemd-analyze blame | grep some-service | ||
+ | </ | ||
+ | |||
+ | If you want to completely disable it, read the next section. | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Disabling services completely ===== | ||
+ | |||
+ | If you want to completely disable a service so that it can't be started, you should use mask instead of disable. Like this | ||
+ | |||
+ | <code bash> | ||
+ | sudo systemctl mask < | ||
+ | </ | ||
+ | |||
+ | Replace the < | ||
+ | |||
+ | The difference between mask and disable is mask make a service completely disable, you can't start it. You must unmask to start it with systemd (you can still start with service). | ||
+ | |||
+ | For example, after masking the some-service service, if you tried start it with systemctl the following message is shown | ||
+ | |||
+ | Failed to start some-service.service: | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Re-enable a service ===== | ||
+ | |||
+ | If you want to re-enable a service: | ||
+ | |||
+ | <code bash> | ||
+ | sudo systemctl unmask < | ||
+ | sudo systemctl enable < | ||
+ | </ | ||
+ | |||
ubuntu/boot/speed_up_boot.1574719569.txt.gz · Last modified: 2020/07/15 09:30 (external edit)