Soporte #3157
Acelaración del arranque
#1 Actualizado por Nacho Sancho hace alrededor de 3 años
Traza con una máquina virtual:
- UN ARRANQUE CON EL DAILY DANDO MAL
root@vxtestnacho:~# systemd-analyze
Bootup is not yet finished. Please try again later.
root@vxtestnacho:~# systemd-analyze
Startup finished in 2.738s (kernel) + 46.606s (userspace) = 49.344s
graphical.target reached after 10.264s in userspace
root@vxtestnacho:~# systemd-analyze blame
41.967s apt-daily.service
7.700s vboxadd.service
7.606s plymouth-quit-wait.service
1.519s dev-mapper-lubuntu\x2d\x2dvg\x2droot.device
1.283s apt-daily-upgrade.service
1.116s networkd-dispatcher.service
......
root@vxtestnacho:~# systemd-analyze critical-chain
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
graphical.target @10.264s
└─lightdm.service @9.969s +290ms
└─vboxadd.service @2.267s +7.700s
└─basic.target @1.797s
└─sockets.target @1.797s
└─uuidd.socket @1.797s
└─sysinit.target @1.792s
└─swap.target @1.791s
└─dev-mapper-lubuntu\x2d\x2dvg\x2dswap_1.swap @1.779s +12ms
└─dev-mapper-lubuntu\x2d\x2dvg\x2dswap_1.device @1.776s
- OTRO ARRANQUE, SI APT-DAILY ARRANCADO
root@vxtestnacho:~# systemd-analyze
Startup finished in 3.075s (kernel) + 10.455s (userspace) = 13.530s
graphical.target reached after 10.432s in userspace
root@vxtestnacho:~# systemd-analyze critical-chain
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
└─lightdm.service @10.206s +224ms
└─vboxadd.service @2.188s +8.016s
└─basic.target @2.174s
└─sockets.target @2.174s
└─cups.socket @2.174s
└─sysinit.target @2.160s
└─swap.target @2.159s
└─dev-mapper-lubuntu\x2d\x2dvg\x2dswap_1.swap @2.140s +18ms
└─dev-mapper-lubuntu\x2d\x2dvg\x2dswap_1.device @2.137s
- DESPUÉS DE LA FALLA
root@vxtestnacho:~# systemd-analyze
Startup finished in 2.696s (kernel) + 7.864s (userspace) = 10.561s
graphical.target reached after 7.855s in userspace
root@vxtestnacho:~# systemd-analyze critical-chain
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
graphical.target @7.855s
└─lightdm.service @7.667s +186ms
└─vboxadd.service @1.750s +5.912s
└─basic.target @1.526s
└─sockets.target @1.526s
└─avahi-daemon.socket @1.526s
└─sysinit.target @1.518s
└─swap.target @1.517s
└─dev-mapper-lubuntu\x2d\x2dvg\x2dswap_1.swap @1.505s +11ms
└─dev-mapper-lubuntu\x2d\x2dvg\x2dswap_1.device @1.503s
Descripción
Comprando arranques en diferentes máquinas, hemos detectado servicios que provocan un arranque más lento del entorno gráfico (graphical.target)
Para realizar las mediciones hemos tomado los siguientes datos:
Resumen del tiempo de arranque (kernel, carga del stack gráfico y entorno de usuario):
root@vitalinux:~# systemd-analyze Startup finished in 5.517s (kernel) + 1min 56.786s (userspace) = 2min 2.304s graphical.target reached after 53.841s in userspace
Con blame podemos ordenar por servicios más lentos y rápidos
root@vitalinux:~# systemd-analyze blame 1min 12.046s apt-daily.service 17.629s systemd-journal-flush.service 13.239s networkd-dispatcher.service ....
O detalle del target más costoso:
root@vitalinux:~# systemd-analyze critical-chain The time after the unit is active or started is printed after the "@" character. The time the unit takes to start is printed after the "+" character. graphical.target @53.841s └─multi-user.target @53.840s └─smbd.service @52.028s +1.811s └─nmbd.service @44.006s +8.020s └─network-online.target @44.002s └─NetworkManager-wait-online.service @34.367s +9.634s └─NetworkManager.service @25.053s +9.254s └─dbus.service @25.130s └─basic.target @24.755s └─sockets.target @24.755s └─dbus.socket @24.613s └─sysinit.target @24.612s └─systemd-timesyncd.service @22.817s +1.794s └─systemd-tmpfiles-setup.service @22.277s +520ms └─systemd-journal-flush.service @4.646s +17.629s └─systemd-journald.service @4.061s +584ms └─syslog.socket @4.060s └─system.slice @3.762s └─-.slice @3.740sTras varias pruebas, comprobamos que los siguientes servicios demoran mucho el arranque, y no son necesarios (para mejorar la experiencia de usuario)
- NetworkManager-wait-online.service -> Parece ser que sirve para esperar a que haya red para hacer la carga de entorno gráfico (así poder por ejemplo tener la red disponible en el lightdm o nada más arrancar). Si se deshabilita se cargará a posteriori con el Network Manager
- smbd.service y nmbd.service -> Servicios que no son necesarios de forma general, ya que no se comparten por samba siendo Vitlainux server (como cliente, tenemos el smbclient que no requiere de samba)
- apt-daily.service y apt-daily-upgrade.service -> Las actualizaciones ya las comprobamos con migasfree
Se crea una falla que se aplicará una sola vez, por si acaso de momento, deshabilitando dichos servicios