A pesar de que aún falta mucho tiempo para el fin del soporte a largo término para Debian 7 Wheezy, muchas versiones de paquetes empiezan a quedar obsoletas y surge la necesidad de migrar a Debian 8 Jessie (luego a Devuan Jessie, una vez sea liberada la primera versión estable). Claro está que muchos SysAdmins no queremos systemd en nuestros servidores de producción (ni tampoco testing o desarrollo), por lo que en este artículo voy a explicar cómo remover/eliminar completamente systemd de un servidor Debian 8 Jessie para volver al robusto SystemV.
Este artículo está basado completamente en la entrada How to remove systemd from a Debian jessie/sid installation del sitio without-systemd.org. Es básicamente una traducción libre al español, con algunas modificaciones y omisiones.
Partiendo de un sistema Debian Jessie recién instalado y funcionando, el primer paso consiste en instalar el sistema de inicio clásico SystemV:
# apt-get install sysvinit-core sysvinit-utils
root@debian8:~# apt-get install sysvinit-core sysvinit-utils Reading package lists... Done Building dependency tree Reading state information... Done sysvinit-utils is already the newest version. The following packages will be REMOVED: systemd-sysv The following NEW packages will be installed: sysvinit-core 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded. Need to get 132 kB of archives. After this operation, 119 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://httpredir.debian.org/debian/ jessie/main sysvinit-core amd64 2.88dsf-59 [132 kB] Fetched 132 kB in 2s (58.1 kB/s) Preconfiguring packages ... dpkg: systemd-sysv: dependency problems, but removing anyway as you requested: init depends on systemd-sysv | sysvinit-core | upstart; however: Package systemd-sysv is to be removed. Package sysvinit-core is not installed. Package upstart is not installed. (Reading database ... 29773 files and directories currently installed.) Removing systemd-sysv (215-17+deb8u5) ... Processing triggers for man-db (2.7.0.2-5) ... Selecting previously unselected package sysvinit-core. (Reading database ... 29756 files and directories currently installed.) Preparing to unpack .../sysvinit-core_2.88dsf-59_amd64.deb ... Unpacking sysvinit-core (2.88dsf-59) ... Processing triggers for man-db (2.7.0.2-5) ... Setting up sysvinit-core (2.88dsf-59) ... Not restarting sysvinit
Luego, instalar el archivo inittab
:
root@debian8:~# cp /usr/share/sysvinit/inittab /etc/
Una vez instalado el sistema de inicio SystemV, es necesario configurar GRUB (a partir de Debian Jessie 8.3 en adelante) para que inicie con SystemV en lugar de systemd. Editar el archivo de configuración de GRUB /etc/default/grub
:
root@debian8:~# nano /etc/default/grub
La variable GRUB_CMDLINE_LINUX_DEFAULT
debe quedar configurada de la siguiente forma:
GRUB_CMDLINE_LINUX_DEFAULT="init=/lib/sysvinit/init console=hvc0 console=ttyS0"
Guardar los cambios y actualizar GRUB ejecutando update-grub
:
root@debian8:~# update-grub Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.16.0-4-amd64 Found initrd image: /boot/initrd.img-3.16.0-4-amd64 done
En este punto se debe reiniciar el sistema para que inicie con SystemV. Antes de reiniciar, se observa el proceso init con PID 1 de systemd:
root@debian8:~# ps 1 PID TTY STAT TIME COMMAND 1 ? Ss 0:00 /sbin/init
Reiniciar el sistema para que inicie con SystemV:
root@debian8:~# reboot Broadcast message from root@debian8 (pts/0) (Tue Nov 8 10:46:08 2016): The system is going down for reboot NOW!
Luego de reiniciar el sistema, se observa el proceso init con PID 1 de SystemV:
root@debian8:~# ps 1 PID TTY STAT TIME COMMAND 1 ? Ss 0:00 init [2]
No hay rastros de systemd o alguna de sus mierdas:
root@debian8:~# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 15492 1884 ? Ss 10:46 0:00 init [2] root 2 0.0 0.0 0 0 ? S 10:46 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 10:46 0:00 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S< 10:46 0:00 [kworker/0:0H] root 6 0.0 0.0 0 0 ? S 10:46 0:00 [kworker/u2:0] root 7 0.0 0.0 0 0 ? S 10:46 0:00 [rcu_sched] root 8 0.0 0.0 0 0 ? S 10:46 0:00 [rcu_bh] root 9 0.0 0.0 0 0 ? S 10:46 0:00 [migration/0] root 10 0.0 0.0 0 0 ? S 10:46 0:00 [watchdog/0] root 11 0.0 0.0 0 0 ? S< 10:46 0:00 [khelper] root 12 0.0 0.0 0 0 ? S 10:46 0:00 [kdevtmpfs] root 13 0.0 0.0 0 0 ? S< 10:46 0:00 [netns] root 14 0.0 0.0 0 0 ? S 10:46 0:00 [khungtaskd] root 15 0.0 0.0 0 0 ? S< 10:46 0:00 [writeback] root 16 0.0 0.0 0 0 ? SN 10:46 0:00 [ksmd] root 17 0.0 0.0 0 0 ? SN 10:46 0:00 [khugepaged] root 18 0.0 0.0 0 0 ? S< 10:46 0:00 [crypto] root 19 0.0 0.0 0 0 ? S< 10:46 0:00 [kintegrityd] root 20 0.0 0.0 0 0 ? S< 10:46 0:00 [bioset] root 21 0.0 0.0 0 0 ? S< 10:46 0:00 [kblockd] root 22 0.0 0.0 0 0 ? S 10:46 0:00 [kworker/0:1] root 23 0.0 0.0 0 0 ? S 10:46 0:00 [kswapd0] root 24 0.0 0.0 0 0 ? S< 10:46 0:00 [vmstat] root 25 0.0 0.0 0 0 ? S 10:46 0:00 [fsnotify_mark] root 31 0.0 0.0 0 0 ? S< 10:46 0:00 [kthrotld] root 32 0.0 0.0 0 0 ? S< 10:46 0:00 [ipv6_addrconf] root 33 0.0 0.0 0 0 ? S< 10:46 0:00 [deferwq] root 67 0.0 0.0 0 0 ? S 10:46 0:00 [khubd] root 68 0.0 0.0 0 0 ? S< 10:46 0:00 [ata_sff] root 69 0.0 0.0 0 0 ? S< 10:46 0:00 [kpsmoused] root 72 0.0 0.0 0 0 ? S 10:46 0:00 [scsi_eh_0] root 73 0.0 0.0 0 0 ? S< 10:46 0:00 [scsi_tmf_0] root 74 0.0 0.0 0 0 ? S 10:46 0:00 [scsi_eh_1] root 75 0.0 0.0 0 0 ? S< 10:46 0:00 [scsi_tmf_1] root 77 0.0 0.0 0 0 ? S 10:46 0:00 [scsi_eh_2] root 78 0.0 0.0 0 0 ? S< 10:46 0:00 [scsi_tmf_2] root 79 0.0 0.0 0 0 ? S 10:46 0:00 [kworker/u2:3] root 85 0.0 0.0 0 0 ? S< 10:46 0:00 [kworker/0:1H] root 106 0.0 0.0 0 0 ? S 10:46 0:00 [jbd2/sda1-8] root 107 0.0 0.0 0 0 ? S< 10:46 0:00 [ext4-rsv-conver] root 290 0.0 0.1 40888 3240 ? Ss 10:46 0:00 udevd --daemon root 953 0.0 0.3 25404 7672 ? Ss 10:46 0:00 dhclient -v -pf /run/dhclient.eth0.pid -lf root 1009 0.0 0.1 37080 2752 ? Ss 10:46 0:00 /sbin/rpcbind -w statd 1037 0.0 0.1 37280 2960 ? Ss 10:46 0:00 /sbin/rpc.statd root 1042 0.0 0.0 0 0 ? S< 10:46 0:00 [rpciod] root 1044 0.0 0.0 0 0 ? S< 10:46 0:00 [nfsiod] root 1051 0.0 0.0 23356 204 ? Ss 10:46 0:00 /usr/sbin/rpc.idmapd root 1211 0.0 0.1 258672 2908 ? Ssl 10:46 0:00 /usr/sbin/rsyslogd root 1250 0.0 0.0 4256 1584 ? Ss 10:46 0:00 /usr/sbin/acpid daemon 1274 0.0 0.0 19024 168 ? Ss 10:46 0:00 /usr/sbin/atd root 1321 0.0 0.1 27476 2264 ? Ss 10:46 0:00 /usr/sbin/cron message+ 1339 0.0 0.1 42260 2844 ? Ss 10:46 0:00 /usr/bin/dbus-daemon --system Debian-+ 1610 0.0 0.1 53252 3124 ? Ss 10:46 0:00 /usr/sbin/exim4 -bd -q30m root 1640 0.0 0.1 55184 2820 ? Ss 10:46 0:00 /usr/sbin/sshd root 1664 0.0 0.1 14416 2088 tty1 Ss+ 10:46 0:00 /sbin/getty 38400 tty1 root 1665 0.0 0.1 14416 2080 tty2 Ss+ 10:46 0:00 /sbin/getty 38400 tty2 root 1666 0.0 0.1 14416 2080 tty3 Ss+ 10:46 0:00 /sbin/getty 38400 tty3 root 1667 0.0 0.0 14416 1932 tty4 Ss+ 10:46 0:00 /sbin/getty 38400 tty4 root 1668 0.0 0.0 14416 1928 tty5 Ss+ 10:46 0:00 /sbin/getty 38400 tty5 root 1669 0.0 0.1 14416 2084 tty6 Ss+ 10:46 0:00 /sbin/getty 38400 tty6 root 1676 0.0 0.2 82816 5980 ? Rs 10:49 0:00 sshd: root@pts/0 root 1678 0.0 0.0 0 0 ? S 10:49 0:00 [kauditd] root 1679 0.0 0.2 22960 5028 pts/0 Ss 10:49 0:00 -bash root 1688 0.0 0.0 0 0 ? S 10:51 0:00 [kworker/0:0] root 1733 0.0 0.0 0 0 ? S 10:56 0:00 [kworker/0:2] root 2263 0.0 0.1 19100 2508 pts/0 R+ 10:59 0:00 ps aux
El último paso consiste el desinstalar systemd, para ello ejecutar:
# apt-get remove --purge --auto-remove systemd
Tener en cuenta que este comando, además de eliminar systemd, elimina cualquier paquete que dependa del mismo.
root@debian8:~# apt-get remove --purge --auto-remove systemd Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: systemd* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 12.1 MB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 29781 files and directories currently installed.) Removing systemd (215-17+deb8u5) ... Purging configuration files for systemd (215-17+deb8u5) ... Processing triggers for man-db (2.7.0.2-5) ... Processing triggers for dbus (1.8.20-0+deb8u1) ...
Luego, configurar el gestor de paquetes APT para que jamás vuelva a intalar systemd, ninguna de sus dependencias, ni ningún paquete que contenga la palabra "systemd" en el nombre. Esto incluye systemd-shim
, el cual provee emulación de funciones de systemd para paquetes que dependen del mismo, y tal vez puede ser deseado ya que permite instalar paquetes dependientes de systemd en sistemas sin systemd.
En la configuración de APT, agregar el siguiente archivo:
root@debian8:~# nano /etc/apt/preferences.d/systemd
Con el siguiente contenido:
Package: systemd Pin: release * Pin-Priority: -1 Package: *systemd* Pin: release * Pin-Priority: -1
Esto impide que APT instale systemd ni ningún paquete que contenga la palabra systemd (*systemd*
) en su nombre.
Verificar el correcto funcionamiento de apt
:
root@debian8:~# apt-get update Hit http://security.debian.org jessie/updates InRelease Hit http://security.debian.org jessie/updates/main Sources Hit http://security.debian.org jessie/updates/main amd64 Packages Hit http://security.debian.org jessie/updates/main Translation-en Ign http://httpredir.debian.org jessie InRelease Hit http://httpredir.debian.org jessie-updates InRelease Hit http://httpredir.debian.org jessie Release.gpg Get:1 http://httpredir.debian.org jessie-updates/main Translation-en/DiffIndex [2,704 B] Hit http://httpredir.debian.org jessie-updates/main Sources Get:2 http://httpredir.debian.org jessie-updates/main amd64 Packages/DiffIndex [6,424 B] Hit http://httpredir.debian.org jessie Release Hit http://httpredir.debian.org jessie/main Sources Hit http://httpredir.debian.org jessie/main amd64 Packages Hit http://httpredir.debian.org jessie/main Translation-en Fetched 9,128 B in 6s (1,365 B/s) Reading package lists... Done root@debian8:~# apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Luego, intentar instalar systemd:
root@debian8:~# apt-get install systemd Reading package lists... Done Building dependency tree Reading state information... Done Package systemd is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: libsystemd-dev E: Package 'systemd' has no installation candidate
Hehe, fuck you systemd!
Enjoy init freedom!
Referencias
How to remove systemd from a Debian jessie/sid installation
Tal vez pueda interesarte