On 29/03/2010, at 8:58 PM, wbenn...@turing.une.edu.au wrote:

> The hard drive of the PC is partitioned.
> 
> When I boot up, eventually I receive:---
> 
> Ubuntu, kernel 2.6.20 - 17 generic
> Ubuntu, kernel 2.6.20 - 17 generic (recovery mode)
> Ubuntu, kernel 2.6.20 - 16 generic
> Ubuntu, kernel 2.6.20 - 16 generic (recovery mode)
> Ubuntu, kernel 2.6.20 - 15 generic
> Ubuntu, kernel 2.6.20 - 15 generic (recovery mode)
> 
> Ubuntu, memtest86+
> 
> Other operating systems:
> Microsoft Windows XP Professional.
> 
> The Ubuntu section is what's the matter.
> 
> I assume the 16 and 15's are superceded kernels, ie., they can be removed.
> 
> How is this done? I'd rather not wipe the operative kernel by mistake.

Hi William,

Here's a sample run on one of my Ubuntu servers (some screen output trimmed):

Get a list of what's installed:

r...@node:~# dpkg -l 'linux-image*'
...
ii  linux-image-2.6.24-24-server
ii  linux-image-2.6.24-25-server
ii  linux-image-2.6.24-26-server
ii  linux-image-2.6.24-27-server
...

Check the running kernel version:

r...@node:~# uname -r
2.6.24-27-server

Ok - so let's keep the running kernel (obviously) and the previous one, just in 
case.  So that means we want to get rid of the -24 and -25 kernels.

r...@node:~# apt-get remove linux-image-2.6.24-24-server 
linux-image-2.6.24-25-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-2.6.24-24-server linux-image-2.6.24-25-server 
linux-ubuntu-modules-2.6.24-24-server linux-ubuntu-modules-2.6.24-25-server
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 219MB disk space will be freed.
Do you want to continue [Y/n]? Y
(Reading database ... 98398 files and directories currently installed.)
Removing linux-ubuntu-modules-2.6.24-24-server ...

-->8-- snipped the actual removal and initrd regeneration steps (see below)

Removing linux-ubuntu-modules-2.6.24-25-server ...
update-initramfs: Generating /boot/initrd.img-2.6.24-25-server
Removing linux-image-2.6.24-25-server ...
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: /vmlinuz-2.6.24-27-server
Found kernel: /vmlinuz-2.6.24-26-server
Found kernel: /memtest86+.bin
Replacing config file /var/run/grub/menu.lst with new version
Updating /boot/grub/menu.lst ... done

Now lets look at the grub view of the world:

r...@node:~# cat /boot/grub/menu.lst | egrep '^title|^default'
default         0
title           Ubuntu 8.04.4 LTS, kernel 2.6.24-27-server
title           Ubuntu 8.04.4 LTS, kernel 2.6.24-27-server (recovery mode)
title           Ubuntu 8.04.4 LTS, kernel 2.6.24-26-server
title           Ubuntu 8.04.4 LTS, kernel 2.6.24-26-server (recovery mode)
title           Ubuntu 8.04.4 LTS, memtest86+

Voila. Only the -27 (running) and -26 kernels are left with the -27 set as 
default (the 0th line)
-- 
James

Attachment: smime.p7s
Description: S/MIME cryptographic signature

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to