Desinstalar kernels antiguos en Ubuntu

Tras cada actualización del kernel de Linux, los anteriores quedan como recuerdo en el disco duro. El inconveniente principal de esto es que cada vez que arranques tu máquina, el menú del Grub (o Lilo quizá, aunque si usas Ubuntu, es poco probable que lo tengas) será cada vez más largo y con opciones (kernels antiguos) que muy probablemente no vuelvas a utilizar.

La solución a esto es desinstalar cada cierto tiempo los kernels obsoletos. En Ubuntu, podemos hacerlo de la siguiente manera:

Ver primero que versión del kernel estamos usando con el comando:

uname -r

Esto arrojará algo como:

2.6.28-13-generic

Ver que otras versiones tienen instaladas (a la izquierda de cada linea, hay una letra, todas las que tengan la letra i serán las que están en el sistema):

sudo aptitude search linux-image-2

Luego, desde consola ejecutamos el comando:

sudo apt-get remove --purge 2.6.28-11-*

Teniendo en cuenta que 2.6.28-11 es la versión que queremos quitar (OJO, deben reemplazar este valor por la versión que quieran quitar, que no sea la versión actual y preferiblemente dejen las dos últimas versiones por si la más nueva tiene algún problema).

El resultado de este comando será algo similar a esto (seguramente con variaciones dependiendo que tengan instalado):

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package 2.6.28-11
yorch@blackbird:~$ sudo apt-get remove --purge 2.6.28-11-*
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting linux-image-2.6.28-11-generic for regex '2.6.28-11-*'
Note, selecting linux-headers-lbm-2.6.28-11-server for regex '2.6.28-11-*'
Note, selecting linux-image-2.6.28-11-server for regex '2.6.28-11-*'
Note, selecting linux-headers-2.6.28-11-generic for regex '2.6.28-11-*'
Note, selecting linux-headers-2.6.28-11-server for regex '2.6.28-11-*'
Note, selecting linux-headers-2.6.28-11 for regex '2.6.28-11-*'
Note, selecting linux-backports-modules-2.6.28-11-server for regex '2.6.28-11-*'
Note, selecting linux-backports-modules-2.6.28-11-generic for regex '2.6.28-11-*'
Note, selecting linux-restricted-modules-2.6.28-11-server for regex '2.6.28-11-*'
Note, selecting linux-restricted-modules-2.6.28-11-generic for regex '2.6.28-11-*'
Note, selecting linux-headers-lbm-2.6.28-11-generic for regex '2.6.28-11-*'
Note, selecting linux-image-2.6.28-11-virtual for regex '2.6.28-11-*'
The following packages will be REMOVED:
  linux-headers-2.6.28-11* linux-headers-2.6.28-11-generic* linux-image-2.6.28-11-generic*
  linux-restricted-modules-2.6.28-11-generic*
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 190MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 369744 files and directories currently installed.)
Removing linux-headers-2.6.28-11-generic ...
Removing linux-headers-2.6.28-11 ...
Removing linux-restricted-modules-2.6.28-11-generic ...
update-initramfs: Generating /boot/initrd.img-2.6.28-11-generic
Purging configuration files for linux-restricted-modules-2.6.28-11-generic ...
Removing linux-image-2.6.28-11-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms
Uninstalling: vboxnetflt 2.1.4 (2.6.28-11-generic) (x86_64)

-------- Uninstall Beginning --------
Module:  vboxnetflt
Version: 2.1.4
Kernel:  2.6.28-11-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

vboxnetflt.ko:
 - Uninstallation
   - Deleting from: /lib/modules/2.6.28-11-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.
depmod....

DKMS: uninstall Completed.
Uninstalling: vboxdrv 2.1.4 (2.6.28-11-generic) (x86_64)

-------- Uninstall Beginning --------
Module:  vboxdrv
Version: 2.1.4
Kernel:  2.6.28-11-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

vboxdrv.ko:
 - Uninstallation
   - Deleting from: /lib/modules/2.6.28-11-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.
depmod....

DKMS: uninstall Completed.
Uninstalling: virtualbox-ose-guest 2.1.4 (2.6.28-11-generic) (x86_64)

-------- Uninstall Beginning --------
Module:  virtualbox-ose-guest
Version: 2.1.4
Kernel:  2.6.28-11-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

vboxadd.ko:
 - Uninstallation
   - Deleting from: /lib/modules/2.6.28-11-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

vboxvfs.ko:
 - Uninstallation
   - Deleting from: /lib/modules/2.6.28-11-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.
depmod....

DKMS: uninstall Completed.
run-parts: executing /etc/kernel/prerm.d/last-good-boot
Running postrm hook script /sbin/update-grub.
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-2.6.28-13-generic
Found kernel: /boot/memtest86+.bin
Replacing config file /var/run/grub/menu.lst with new version
Updating /boot/grub/menu.lst ... done

Purging configuration files for linux-image-2.6.28-11-generic ...
Running postrm hook script /sbin/update-grub.
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-2.6.28-13-generic
Found kernel: /boot/memtest86+.bin
Updating /boot/grub/menu.lst ... done

dpkg - warning: while removing linux-image-2.6.28-11-generic, directory `/lib/modules/2.6.28-11-generic' not empty so not removed.

Luego pueden repetir el proceso para el resto de versiones que deseen.

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? *