[Solved] Safe way to remove old kernels from Terminal

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

[Solved] Safe way to remove old kernels from Terminal

Postby su35 » May 10th, '14, 07:18

Hi,
This is my second day in Mageia and I already have 4 kernels on my system which not really a problem other the fact that I have to manually select the newest kernel in grub on every boot. So I want to remove the old kernels. I got a kernel update just a few mins ago and booted with it and its working fine so I want to remove all the older ones.

I have never done this before. I wen to Install and Remove Software and searched for "kernel" but didn't find anything.

I want to do this the command line way.

uname -a shows the current kernel. Is there a command which prints the list of all installed kernels ? and finally what the command to remove them ?
Last edited by su35 on May 10th, '14, 15:44, edited 1 time in total.
User avatar
su35
 
Posts: 21
Joined: May 9th, '14, 15:34

Re: Safe way to remove old kernels from Terminal

Postby nigelc » May 10th, '14, 09:49

Hi,
You can search for them by doing:
Code: Select all
"rpm -qa |grep kernel"

Then you could go su then
urpme kernel" you want to remove.
Or in the mcc > add remove programs and do it via the gui.
Be careful which one you remove.
nigelc
 
Posts: 266
Joined: Aug 28th, '11, 09:35

Re: Safe way to remove old kernels from Terminal

Postby su35 » May 10th, '14, 10:28

For the first time I don't wanna try this without a little guidance. This is what I am getting

Code: Select all
$ rpm -qa |grep kernel
nvidia304-kernel-3.12.13-desktop-2.mga4-304.119-5.mga4.nonfree
kernel-firmware-20131013-2.mga4
kernel-desktop-devel-latest-3.12.18-1.mga4
nvidia304-kernel-3.12.8-desktop-2.mga4-304.119-2.mga4.nonfree
kernel-desktop-3.12.8-2.mga4-1-1.mga4
kernel-userspace-headers-3.12.18-1.mga4
kernel-desktop-devel-3.12.13-2.mga4-1-1.mga4
kernel-desktop-latest-3.12.18-1.mga4
kernel-desktop-devel-3.12.8-2.mga4-1-1.mga4
kernel-desktop-3.12.18-1.mga4-1-1.mga4
kernel-desktop-devel-3.12.18-1.mga4-1-1.mga4
nvidia304-kernel-3.12.18-desktop-1.mga4-304.119-6.mga4.nonfree
kernel-firmware-nonfree-20140119-1.mga4.nonfree
kernel-desktop-3.12.13-2.mga4-1-1.mga4
nvidia304-kernel-desktop-latest-304.119-6.mga4.nonfree


Code: Select all
$ uname -a
Linux localhost 3.12.18-desktop-1.mga4 #1 SMP Thu Apr 24 13:10:59 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux


So is this what I should do ?

Code: Select all
urpme kernel-desktop-3.12.8-2.mga4-1-1.mga4
urpme kernel-desktop-3.12.13-2.mga4-1-1.mga4
User avatar
su35
 
Posts: 21
Joined: May 9th, '14, 15:34

Re: Safe way to remove old kernels from Terminal

Postby doktor5000 » May 10th, '14, 11:20

You can also remove them from MCC, you just need to switch the filter from "packages with GUI" to "all".

For the commands, better sort the list so it's more obvious:
Code: Select all
rpm -qa | grep kernel | sort


I'll show you a complete example.

Code: Select all
[root@Mageia4 ~]# uname -r                                                                                                                                             
3.12.18-desktop-1.mga4


The packages marked in bold are those we want to remove.
[root@Mageia4 ~]# rpm -qa | grep kernel | sort
kernel-desktop-3.12.13-2.mga4-1-1.mga4
kernel-desktop-3.12.18-1.mga4-1-1.mga4
kernel-desktop-3.12.8-2.mga4-1-1.mga4
kernel-desktop-3.12.9-1.mga4-1-1.mga4
kernel-desktop-devel-3.12.13-2.mga4-1-1.mga4
kernel-desktop-devel-3.12.18-1.mga4-1-1.mga4
kernel-desktop-devel-3.12.8-2.mga4-1-1.mga4
kernel-desktop-devel-3.12.9-1.mga4-1-1.mga4
kernel-desktop-devel-latest-3.12.18-1.mga4
kernel-desktop-latest-3.12.18-1.mga4
kernel-firmware-20131013-2.mga4
kernel-firmware-nonfree-20140119-1.mga4.nonfree
kernel-userspace-headers-3.12.18-1.mga4
virtualbox-kernel-3.12.13-desktop-2.mga4-4.3.10-1.mga4
virtualbox-kernel-3.12.18-desktop-1.mga4-4.3.10-2.mga4
virtualbox-kernel-3.12.8-desktop-2.mga4-4.3.6-8.mga4
virtualbox-kernel-3.12.9-desktop-1.mga4-4.3.6-9.mga4
virtualbox-kernel-desktop-latest-4.3.10-2.mga4


Remove them all in one go:
Code: Select all
[root@Mageia4 ~]# urpme kernel-desktop-3.12.13-2.mga4-1-1.mga4 kernel-desktop-3.12.8-2.mga4-1-1.mga4 kernel-desktop-3.12.9-1.mga4-1-1.mga4 kernel-desktop-devel-3.12.13-2.mga4-1-1.mga4 kernel-desktop-devel-3.12.8-2.mga4-1-1.mga4 kernel-desktop-devel-3.12.9-1.mga4-1-1.mga4 virtualbox-kernel-3.12.13-desktop-2.mga4-4.3.10-1.mga4 virtualbox-kernel-3.12.8-desktop-2.mga4-4.3.6-8.mga4 virtualbox-kernel-desktop-latest-4.3.10-2.mga4
To satisfy dependencies, the following 10 packages will be removed (227MB):
  kernel-desktop-3.12.13-2.mga4-1-1.mga4.x86_64
  kernel-desktop-3.12.8-2.mga4-1-1.mga4.x86_64
  kernel-desktop-3.12.9-1.mga4-1-1.mga4.x86_64
  kernel-desktop-devel-3.12.13-2.mga4-1-1.mga4.x86_64
  kernel-desktop-devel-3.12.8-2.mga4-1-1.mga4.x86_64
  kernel-desktop-devel-3.12.9-1.mga4-1-1.mga4.x86_64
  virtualbox-kernel-3.12.13-desktop-2.mga4-4.3.10-1.mga4.x86_64
   (due to missing kernel-desktop-3.12.13-2.mga4[*],
    due to missing kernel-desktop-3.12.13-2.mga4)
  virtualbox-kernel-3.12.8-desktop-2.mga4-4.3.6-8.mga4.x86_64
   (due to missing kernel-desktop-3.12.8-2.mga4[*],
    due to missing kernel-desktop-3.12.8-2.mga4)
  virtualbox-kernel-3.12.9-desktop-1.mga4-4.3.6-9.mga4.x86_64
   (due to missing kernel-desktop-3.12.9-1.mga4[*],
    due to missing kernel-desktop-3.12.9-1.mga4)
  virtualbox-kernel-desktop-latest-4.3.10-2.mga4.x86_64
Remove 10 packages? (y/N) y
removing kernel-desktop-3.12.13-2.mga4-1-1.mga4.x86_64 kernel-desktop-3.12.8-2.mga4-1-1.mga4.x86_64 kernel-desktop-3.12.9-1.mga4-1-1.mga4.x86_64 kernel-desktop-devel-3.12.13-2.mga4-1-1.mga4.x86_64 kernel-desktop-devel-3.12.8-2.mga4-1-1.mga4.x86_64 kernel-desktop-devel-3.12.9-1.mga4-1-1.mga4.x86_64 virtualbox-kernel-3.12.13-desktop-2.mga4-4.3.10-1.mga4.x86_64 virtualbox-kernel-3.12.8-desktop-2.mga4-4.3.6-8.mga4.x86_64 virtualbox-kernel-3.12.9-desktop-1.mga4-4.3.6-9.mga4.x86_64 virtualbox-kernel-desktop-latest-4.3.10-2.mga4.x86_64

-------- Uninstall Beginning --------
Module:  virtualbox
Version: 4.3.10-1.1.mga4
Kernel:  3.12.13-desktop-2.mga4 (x86_64)
-------------------------------------

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

vboxdrv.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/3.12.13-desktop-2.mga4/dkms-binary/3rdparty/vbox/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

vboxnetflt.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/3.12.13-desktop-2.mga4/dkms-binary/3rdparty/vbox/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

vboxnetadp.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/3.12.13-desktop-2.mga4/dkms-binary/3rdparty/vbox/
 - 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.
removing package virtualbox-kernel-3.12.13-desktop-2.mga4-4.3.10-1.mga4.x86_64
     1/10: removing virtualbox-kernel-3.12.13-desktop-2.mga4-4.3.10-1.mga4.x86_64
                                 #####################################################################################################################################

-------- Uninstall Beginning --------
Module:  virtualbox
Version: 4.3.6-1.mga4
Kernel:  3.12.8-desktop-2.mga4 (x86_64)
-------------------------------------

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

vboxdrv.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/3.12.8-desktop-2.mga4/dkms-binary/3rdparty/vbox/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

vboxnetflt.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/3.12.8-desktop-2.mga4/dkms-binary/3rdparty/vbox/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

vboxnetadp.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/3.12.8-desktop-2.mga4/dkms-binary/3rdparty/vbox/
 - 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.
removing package virtualbox-kernel-3.12.8-desktop-2.mga4-4.3.6-8.mga4.x86_64
     2/10: removing virtualbox-kernel-3.12.8-desktop-2.mga4-4.3.6-8.mga4.x86_64
                                 #####################################################################################################################################

-------- Uninstall Beginning --------
Module:  virtualbox
Version: 4.3.6-1.mga4
Kernel:  3.12.9-desktop-1.mga4 (x86_64)
-------------------------------------

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

vboxdrv.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/3.12.9-desktop-1.mga4/dkms-binary/3rdparty/vbox/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vboxnetflt.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/3.12.9-desktop-1.mga4/dkms-binary/3rdparty/vbox/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vboxnetadp.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/3.12.9-desktop-1.mga4/dkms-binary/3rdparty/vbox/
 - 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.
removing package virtualbox-kernel-3.12.9-desktop-1.mga4-4.3.6-9.mga4.x86_64
     3/10: removing virtualbox-kernel-3.12.9-desktop-1.mga4-4.3.6-9.mga4.x86_64
                                 #####################################################################################################################################
removing package kernel-desktop-3.12.9-1.mga4-1-1.mga4.x86_64
     4/10: removing kernel-desktop-3.12.9-1.mga4-1-1.mga4.x86_64
                                 #####################################################################################################################################
removing package kernel-desktop-3.12.8-2.mga4-1-1.mga4.x86_64
     5/10: removing kernel-desktop-3.12.8-2.mga4-1-1.mga4.x86_64
                                 #####################################################################################################################################
removing package kernel-desktop-3.12.13-2.mga4-1-1.mga4.x86_64
     6/10: removing kernel-desktop-3.12.13-2.mga4-1-1.mga4.x86_64
                                 #####################################################################################################################################
removing package kernel-desktop-devel-3.12.9-1.mga4-1-1.mga4.x86_64
     7/10: removing kernel-desktop-devel-3.12.9-1.mga4-1-1.mga4.x86_64
                                 #####################################################################################################################################
removing package virtualbox-kernel-desktop-latest-4.3.10-2.mga4.x86_64
     8/10: removing virtualbox-kernel-desktop-latest-4.3.10-2.mga4.x86_64
                                 #####################################################################################################################################
removing package kernel-desktop-devel-3.12.8-2.mga4-1-1.mga4.x86_64
     9/10: removing kernel-desktop-devel-3.12.8-2.mga4-1-1.mga4.x86_64
                                 #####################################################################################################################################
removing package kernel-desktop-devel-3.12.13-2.mga4-1-1.mga4.x86_64
    10/10: removing kernel-desktop-devel-3.12.13-2.mga4-1-1.mga4.x86_64
                                 #####################################################################################################################################
[root@Mageia4 ~]#
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18058
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Safe way to remove old kernels from Terminal

Postby wobo » May 10th, '14, 13:36

To be added to the list are drivers like graphics (nvidia) or wifi (broadcom) which are installed for a certain kernel which is in the "remove"-list.
(I just checked my /boot and was greeted by more than 20 old kernels, time to do some house-cleaning)
wobo
---
And a new day will dawn for those who stand long
And the forests will echo with laughter
(Stairway to Heaven, Led Zeppelin)
User avatar
wobo
 
Posts: 1649
Joined: Mar 22nd, '11, 17:13

Re: Safe way to remove old kernels from Terminal

Postby su35 » May 10th, '14, 15:43

Done. Thanks
User avatar
su35
 
Posts: 21
Joined: May 9th, '14, 15:34


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest