How to clean kernel in Kubuntu 11.10

Asked by Francisco Trinidad

I have too many kernels listed in Grub and I wish to remove old ones. I'm not sure how to do it safely.
I ugrade to Kubuntu 11.10 and tweak does not works.

Thanks for any help

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu grub2 Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Nathan Heafner (nathan1465-5) said :
#1
Revision history for this message
Francisco Trinidad (jftr47) said :
#2

On Mon, Dec 19, 2011 at 4:35 AM, marcobra (Marco Braida) <
<email address hidden>> wrote:

> Your question #182320 on grub2 in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/grub2/+question/182320
>
> Project: Ubuntu => grub2 in Ubuntu
>
> --
> You received this question notification because you asked the question.
>

When I run dpkg -- list, give me a list of 3.0.0.x kernels. When I stat my
computer,
appear only one 3.0.0.14 kernel, windows 7 and a list of 2.6.32.32 to
2.6.32.36 kernels.
when I run the purge command, did not find it, and when I run update
command and reboot,
nothing was change.

Revision history for this message
Mark Rijckenberg (markrijckenberg) said :
#3

I suggest using the following Korn shell script:

#!/bin/ksh

if [[ $1 == "" ]]; then
echo "List of installed kernel versions:"
dpkg --list | grep linux-image | cut -d" " -f3
echo "No argument added after removekernel command"
echo "Please enter kernelversion to remove from your pc (for example: 2.6.24-16) "
read KERNELVERSION

echo "Removing kernelversion $KERNELVERSION"
apt-cache search $KERNELVERSION|cut -d" " -f1|xargs sudo apt-get remove -y

else
echo "Removing kernelversion $1"
apt-cache search $1|cut -d" " -f1|xargs sudo apt-get remove -y
fi

You will need to save it in /usr/bin and give it executable privileges.

You will also need to install the ksh korn shell package to be able to execute the script.

Revision history for this message
Francisco Trinidad (jftr47) said :
#4

Mark, thank you for your help, but how can I do this?

Thanks Again

On Mon, Dec 19, 2011 at 1:45 PM, Mark Rijckenberg <
<email address hidden>> wrote:

> Your question #182320 on grub2 in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/grub2/+question/182320
>
> Status: Open => Answered
>
> Mark Rijckenberg proposed the following answer:
> I suggest using the following Korn shell script:
>
> #!/bin/ksh
>
> if [[ $1 == "" ]]; then
> echo "List of installed kernel versions:"
> dpkg --list | grep linux-image | cut -d" " -f3
> echo "No argument added after removekernel command"
> echo "Please enter kernelversion to remove from your pc (for example:
> 2.6.24-16) "
> read KERNELVERSION
>
> echo "Removing kernelversion $KERNELVERSION"
> apt-cache search $KERNELVERSION|cut -d" " -f1|xargs sudo apt-get remove -y
>
> else
> echo "Removing kernelversion $1"
> apt-cache search $1|cut -d" " -f1|xargs sudo apt-get remove -y
> fi
>
> You will need to save it in /usr/bin and give it executable privileges.
>
> You will also need to install the ksh korn shell package to be able to
> execute the script.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
>
> https://answers.launchpad.net/ubuntu/+source/grub2/+question/182320/+confirm?answer_id=2
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+source/grub2/+question/182320
>
> You received this question notification because you asked the question.
>

Revision history for this message
Mark Rijckenberg (markrijckenberg) said :
#5

Run the following command:

kdesudo kate /usr/bin/removekernel

Enter your password when requested.

Copy my script into the new text file.

Save the change to the /usr/bin/removekernel file.

Run these commands:

sudo apt-get update && sudo apt-get install ksh

sudo chmod +x /usr/bin/removekernel

Then run the command itself.

removekernel

Then select the kernel version you want to delete.

Revision history for this message
Francisco Trinidad (jftr47) said :
#6

Thanks Mark the file "kate" was created in /usr/bin, there is not kate /usr/bin/removekernel
I open kate, and paste your script, but does not want to saved, ask me for permission.

Thanks

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#7

Need to type "kdesudo" so be sure to type or copy and paste from here the entire command to open the ksh script file

kdesudo kate /usr/bin/removekernel

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#8

Or to remove all unused kernel keeping this working kernel by typing only one row please copy and paste from here the row below:

sudo apt-get -y purge $(dpkg --get-selections | awk '((/^linux-/) && (/[0-9]\./) && (!/'"`uname -r | sed "s/-generic//g"`"'/)) {print $1}')

Revision history for this message
Mark Rijckenberg (markrijckenberg) said :
#9

@Francisco: Please read this:

https://help.ubuntu.com/community/RootSudo

and read this as well:

http://www.kubuntu.org/docs/kquickguide/C/ch03s06.html

kate is NOT a text file. It is a text editor for KDE.

kdesudo is used to ESCALATE privileges to that of the root (=administrator user) while running kate.

This allows kate to edit files with administrator privileges.

Revision history for this message
Francisco Trinidad (jftr47) said :
#10

pancho@pancho-ET1331G:~$ sudo apt-get -y purge $(dpkg --get-selections |
awk '((/^linux-/) &&
> (/[0-9]\./) && (!/'"`uname -r | sed "s/-generic//g"`"'/)) {print $1}')
[sudo] password for pancho:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 linux-headers-generic : Depends: linux-headers-3.0.0-14-generic but it is
not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused
by held packages.
pancho@pancho-ET1331G:~$

and nothing happen kernels still the same

On Mon, Dec 19, 2011 at 5:15 PM, marcobra (Marco Braida) <
<email address hidden>> wrote:

> Your question #182320 on grub2 in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/grub2/+question/182320
>
> marcobra (Marco Braida) posted a new comment:
> Or to remove all unused kernel keeping this working kernel by typing
> only one row please copy and paste from here the row below:
>
> sudo apt-get -y purge $(dpkg --get-selections | awk '((/^linux-/) &&
> (/[0-9]\./) && (!/'"`uname -r | sed "s/-generic//g"`"'/)) {print $1}')
>
> --
> You received this question notification because you asked the question.
>

Revision history for this message
delance (olivier-delance) said :
#11

Have a look at https://answers.launchpad.net/grub/+faqs How to remove entries from Grub2 menu.
It's another way of doing.

Revision history for this message
delance (olivier-delance) said :
#12

what's about your issue ?

Can you help with this problem?

Provide an answer of your own, or ask Francisco Trinidad for more information if necessary.

To post a message you must log in.