Arranque

de

Linux

ADMINISTRACIÓN LINUX

Un runlevel es uno de los modos en que un sistema basado en Unix corre.

 

Cada runlevel tiene un conjunto de servicios que inician o se detienen.

 

Los servicios están configurados mediante scripts que reciben start stop o status como parámetro.

ADMINISTRACIÓN LINUX

Runlevels

ADMINISTRACIÓN LINUX

Runlevels

Runlevel Modo Acción
0 Halt Detiene el sistema
1 Single User Para reparación (solo accede root)
2 Multi User Terminales seriales
3 Multi User c/red Sistema en producción
4 personalizable
5 Gráfico Desktop
6 Reboot Reinicio

ADMINISTRACIÓN LINUX

Runlevels

Problemas o desventajas:

  • Boot secuencial
  • No gestiona dependencias
  • No "conoce" el status actual del sistema
  • No reacciona ante cambios (ej. hot swap)
  • Agregados: inetd (superdaemon)

Opciones para init

  • OpenRC - Gentoo
  • Upstart - Ubuntu
  • Systemd - Redhat, Debian, Ubuntu y más !

ADMINISTRACIÓN LINUX

systemd

ADMINISTRACIÓN LINUX

Antecedentes

Systemd

  • No es KISS
  • Perspectiva y control unificado
  • Exclusivo para Linux (kernel)
  • Tiene journal interno 
  • Más complejidad propia
    (PID 1¿falla generalizada?)

Lennart Poettering

lanzamiento inicial: 30 abril de 2010

ADMINISTRACIÓN LINUX

Lennart Poettering

Systemd

  • No es KISS
  • Perspectiva y control unificado
  • Exclusivo para Linux (kernel)
  • Tiene journal interno 
  • Más complejidad propia (PID 1¿falla generalizada?)

Lennart Poettering

ADMINISTRACIÓN LINUX

ADMINISTRACIÓN LINUX

systemd

ADMINISTRACIÓN LINUX

Systemd

ADMINISTRACIÓN LINUX

Systemd

Ventajas:

  • Boot paralelizado
  • Utiliza socks para comunicar servicios
  • Los daemons no tienen por que estar todos encendidos
  • Maneja puntos de montaje (como dependencia)
  • Gestiona CGroups
  • Puede reaccionar ante eventos (a demanda)

ADMINISTRACIÓN LINUX

units

ADMINISTRACIÓN LINUX

Son los recursos aque systemd conoce y gestiona

units

systemctl list-units --all
unit descripción
automount punto de montado automático
device dispositivo de udev o sysfs
mount punto de montado (~fstab)
path activación por path de un servicio
scope se crea con información del bus
service como se gestiona un servicio
slice se vincula a CGroups
socket activación por socket de un servicio
target puntos de sincronización y estado del sistema
timer gestion de tareas (~cron)
systemctl list-units --all --state=inactive
systemctl list-units --type=service

ADMINISTRACIÓN LINUX

units

estado descripción
enabled actiada
disabled desactivada
static no se puede cambiar
masked evita que se inicie
generated creada por systemd 
transient gestionado por systemd (por otra unidad)
systemctl cat sshd.service
systemctl list-unit-files
systemctl list-dependencies sshd.service
systemctl show sshd.service

ADMINISTRACIÓN LINUX

sistemctl

ADMINISTRACIÓN LINUX

# systemctl list-units --type service --all

 

# systemctl reboot
# systemctl halt

Se usa para consultar y controlar el estado de "sistemd" y para administrar los servicios.

systemctl

ADMINISTRACIÓN LINUX

# systemctl is-enabled [name.service]

# systemctl enable [name.service]

Servicios que inician en el booteo:

systemctl enable

* Instalación por defecto en RedHat vs Ubuntu

  • enabled
  • disabled
  • masked

ADMINISTRACIÓN LINUX

Activar (start) los servicios

systemctl start

# systemctl start [name.service]
# systemctl stop [name.service]
# systemctl restart [name.service]
# systemctl reload [name.service]

# systemctl status [name.service]

# systemctl is-active [name.service]

ADMINISTRACIÓN LINUX

target

ADMINISTRACIÓN LINUX

Los systemd targets son equivalentes al sistema de runlevels que se disponía en SysV init

 

La unidad graphical.target inicia una sesión gráfica de gdm.service y el servicio de usuario accounts-daemon.service y también activa el multi-user.target

target (runlevel)

# systemctl get-default
# systemctl set-default name.target
# systemctl list-units --type target
# systemctl list-dependencies multi-user.target

ADMINISTRACIÓN LINUX

Otros comandos

ADMINISTRACIÓN LINUX

Un log interno de systemd es manejado por journald

journalctl

# journalctl -b  (boot)
# journalctl -u nginx.service 
# journalctl -k  (kernel)

ADMINISTRACIÓN LINUX

Controla la fecha y hora del sistema

timedatectl

# timedatectl status
# timedatectl list-timezones
# timedatectl set-timezone zone

ADMINISTRACIÓN LINUX

Controla el hostname del sistema

hostnamectl

# hostnamectl status

ADMINISTRACIÓN LINUX

... y más

# systemd-analize 

# localectl status

# loginctl 

# networkctl status

Sobre esta presentación

Atribución 4.0 Internacional (CC BY 4.0)

https://creativecommons.org/licenses/by/4.0/deed.es

ADMINISTRACIÓN LINUX

Arranque de Linux

By Rodolfo Pilas

Arranque de Linux

Cómo arranca un sistema Linux

  • 396