Sin espacio en boot, reduciendo initramfs sin morir en el intento.

Deje una partición boot más pequeña al instalar y siempre me da problemas, esta vez sabia que tenia que dejar 1 GB o más pero de ultima hora ya tenia las particiones y se me olvido el UEFI y bot quedo de 512 MB para dar espacio a UEFI

ls -lha /boot/
total 444M
drwxr-xr-x 5 root root 4,0K feb  4 15:55 .
drwxr-xr-x 1 root root  246 feb  4 15:47 ..
-rw-r--r-- 1 root root 285K dic 20 10:15 config-6.17.13+deb14-amd64
-rw-r--r-- 1 root root 288K ene 16 06:09 config-6.18.5+deb14-amd64
drwx------ 4 root root 4,0K ene  1  1970 efi
drwxr-xr-x 5 root root 4,0K feb  4 15:51 grub
-rw-r--r-- 1 root root 209M feb  4 15:14 initrd.img-6.17.13+deb14-amd64<<<<<<<<<<<<<<<<<<<<<<<<
-rw-r--r-- 1 root root 209M feb  4 15:48 initrd.img-6.18.5+deb14-amd64<<<<<<<<<<<<<<<<<<<<<<<<
drwx------ 2 root root  16K ene 17 16:47 lost+found
-rw-r--r-- 1 root root   93 dic 20 10:15 System.map-6.17.13+deb14-amd64
-rw-r--r-- 1 root root   92 ene 16 06:09 System.map-6.18.5+deb14-amd64
-rw-r--r-- 1 root root  14M dic 20 10:15 vmlinuz-6.17.13+deb14-amd64
-rw-r--r-- 1 root root  14M ene 16 06:09 vmlinuz-6.18.5+deb14-amd64

Intento instalar el 6.18 y no cabe, ya que tenia el 6.12 y lo quite y tampoco cabe.

Me nudo desastre y pesa más de 200 MB el kernel

Da el tipico error, lo he visto tantas veces a lo largo del tiempo ( siempre ando sin espacio en el boot ) que ya podría escribirlo de memoria

 

Utilice «apt autoremove» para eliminarlos.
0 actualizados, 0 nuevos se instalarán, 0 para eliminar y 2 no actualizados.
1 no instalados del todo o eliminados.
Se utilizarán 0 B de espacio de disco adicional después de esta operación.
Configurando initramfs-tools (0.150) ...
update-initramfs: deferring update (trigger activated)
Procesando disparadores para initramfs-tools (0.150) ...
update-initramfs: Generating /boot/initrd.img-6.18.5+deb14-amd64
zstd: error 70 : Write error : cannot write block : No space left on device <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
E: mkinitramfs failure zstd -q -9 -T0 70
update-initramfs: failed for /boot/initrd.img-6.18.5+deb14-amd64 with 1.
dpkg: error al procesar el paquete initramfs-tools (--configure):
 old initramfs-tools package postinst maintainer script subprocess failed with exit status 1
Se encontraron errores al procesar:
 initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

 

Vamos a hacer algunos ajustes

Editamos:

 vim /etc/initramfs-tools/initramfs.conf

Cambiamos MOST por DEP para que no nos meta todo

#
# MODULES: [ most | netboot | dep | list ]
#
# most - Add most filesystem and all harddrive drivers.
#
# dep - Try and guess which modules to load.
#
# netboot - Add the base modules, network modules, but skip block devices.
#
# list - Only include modules from the 'additional modules' list
#

MODULES=dep

NOTA:  no requiere mucha explicación MOST = Mete TODOS los drivers de todos los discos y sistemas de ficheros.

Ahora veamos la diferencia:

# apt-get -f install
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias... Hecho
Leyendo la información del estado... Hecho
Resolviendo dependencias... Hecho
Los paquetes indicados a continuación se instalaron de forma automática y ya no son necesarios:
  golang-any libclang-common-19-dev libclang-cpp19 libclang-rt-19-dev libllvmspirvlib19.1 libsass1 libsframe2
  linux-headers-6.17.13+deb14-common linux-kbuild-6.17.13+deb14
Utilice «apt autoremove» para eliminarlos.
0 actualizados, 0 nuevos se instalarán, 0 para eliminar y 2 no actualizados.
1 no instalados del todo o eliminados.
Se utilizarán 0 B de espacio de disco adicional después de esta operación.
Configurando initramfs-tools (0.150) ...
update-initramfs: deferring update (trigger activated)
Procesando disparadores para initramfs-tools (0.150) ...
update-initramfs: Generating /boot/initrd.img-6.18.5+deb14-amd64

Y el archivos en vez de 200 MB pesa solo 40

ls -lha /boot/
total 282M
drwxr-xr-x 5 root root 4,0K feb  4 16:01 .
drwxr-xr-x 1 root root  246 feb  4 15:47 ..
-rw-r--r-- 1 root root 285K dic 20 10:15 config-6.17.13+deb14-amd64
-rw-r--r-- 1 root root 288K ene 16 06:09 config-6.18.5+deb14-amd64
drwx------ 4 root root 4,0K ene  1  1970 efi
drwxr-xr-x 5 root root 4,0K feb  4 15:51 grub
-rw-r--r-- 1 root root 209M feb  4 15:14 initrd.img-6.17.13+deb14-amd64<<<<<<<<<<<<<<<<<<<<<<<
-rw-r--r-- 1 root root  46M feb  4 16:01 initrd.img-6.18.5+deb14-amd64<<<<<<<<<<<<<<<<<<<<<<<<
drwx------ 2 root root  16K ene 17 16:47 lost+found
-rw-r--r-- 1 root root   93 dic 20 10:15 System.map-6.17.13+deb14-amd64
-rw-r--r-- 1 root root   92 ene 16 06:09 System.map-6.18.5+deb14-amd64
-rw-r--r-- 1 root root  14M dic 20 10:15 vmlinuz-6.17.13+deb14-amd64
-rw-r--r-- 1 root root  14M ene 16 06:09 vmlinuz-6.18.5+deb14-amd64
root@debian:~# 

Como vemos el kernel nuevo pesa solo 40, el viejo 200+

Podemos reducir el tamaño de ese viejo kernel, haciendo el update a initramsfs que actualizar todos los kernels que tengamos según la configuración que hemos editado

root@debian:~# update-initramfs -u -k all
update-initramfs: Generating /boot/initrd.img-6.18.5+deb14-amd64
update-initramfs: Generating /boot/initrd.img-6.17.13+deb14-amd64

Y voila:

~# ls -lha /boot/
total 119M
drwxr-xr-x 5 root root 4,0K feb  4 16:04 .
drwxr-xr-x 1 root root  246 feb  4 15:47 ..
-rw-r--r-- 1 root root 285K dic 20 10:15 config-6.17.13+deb14-amd64
-rw-r--r-- 1 root root 288K ene 16 06:09 config-6.18.5+deb14-amd64
drwx------ 4 root root 4,0K ene  1  1970 efi
drwxr-xr-x 5 root root 4,0K feb  4 15:51 grub
-rw-r--r-- 1 root root  46M feb  4 16:04 initrd.img-6.17.13+deb14-amd64 <<<<<<<<<<<<<<<<<<<
-rw-r--r-- 1 root root  46M feb  4 16:04 initrd.img-6.18.5+deb14-amd64<<<<<<<<<<<<<<<<<<<<
drwx------ 2 root root  16K ene 17 16:47 lost+found
-rw-r--r-- 1 root root   93 dic 20 10:15 System.map-6.17.13+deb14-amd64
-rw-r--r-- 1 root root   92 ene 16 06:09 System.map-6.18.5+deb14-amd64
-rw-r--r-- 1 root root  14M dic 20 10:15 vmlinuz-6.17.13+deb14-amd64
-rw-r--r-- 1 root root  14M ene 16 06:09 vmlinuz-6.18.5+deb14-amd64

En vez de alojar solo 2 kernels en 512 MB podemos alojar 5

 

Reiniciamos y listo estamos en el nuevo kernel:

# uname -a
Linux debian 6.18.5+deb14-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.18.5-1 (2026-01-16) x86_64 GNU/Linux