Announcement

Collapse
No announcement yet.

HOWTO: Removing unnecessary entries from the grub menu list

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    HOWTO: Removing unnecessary entries from the grub menu list

    a.k.a removing old kernel packages and rewriting new menu.lst

    I have in the grub's menu list (/boot/grub/menu.lst) entries:
    ...
    title Ubuntu, kernel 2.6.15-28-k7
    title Ubuntu, kernel 2.6.15-28-k7 (recovery mode)
    ...
    title Ubuntu, kernel 2.6.15-27-k7
    title Ubuntu, kernel 2.6.15-27-k7 (recovery mode)
    ...
    title Ubuntu, kernel 2.6.15-26-k7
    title Ubuntu, kernel 2.6.15-26-k7 (recovery mode)
    ...
    title Ubuntu, kernel 2.6.15-25-386
    title Ubuntu, kernel 2.6.15-25-386 (recovery mode)
    ...
    title Ubuntu, memtest86+
    ...
    And in the /boot/

    01 2005-10-25 13:32 memtest86+.bin
    02 2006-06-14 14:24 config-2.6.15-25-386
    03 2006-06-14 15:15 vmlinuz-2.6.15-25-386
    04 2006-06-14 15:15 abi-2.6.15-25-386
    05 2006-06-14 15:15 System.map-2.6.15-25-386
    06 2006-06-29 23:13 initrd.img-2.6.15-25-386
    07 2006-09-08 23:35 config-2.6.15-26-k7
    08 2006-09-09 00:54 vmlinuz-2.6.15-26-k7
    09 2006-09-09 00:54 abi-2.6.15-26-k7
    10 2006-09-09 00:54 System.map-2.6.15-26-k7
    11 2006-09-14 19:10 initrd.img-2.6.15-26-k7
    12 2006-12-08 20:19 config-2.6.15-27-k7
    13 2006-12-08 21:36 vmlinuz-2.6.15-27-k7
    14 2006-12-08 21:36 abi-2.6.15-27-k7
    15 2006-12-08 21:36 System.map-2.6.15-27-k7
    16 2006-12-14 10:29 initrd.img-2.6.15-27-k7
    17 2007-03-13 23:01 config-2.6.15-28-k7
    18 2007-03-13 23:32 vmlinuz-2.6.15-28-k7
    19 2007-03-13 23:32 abi-2.6.15-28-k7
    20 2007-03-13 23:32 System.map-2.6.15-28-k7
    21 2007-04-15 01:42 initrd.img-2.6.15-28-k7
    I wan't to remove the oldest (kernel 2.6.15-25-386)


    Using Synaptic/Adept package manager:

    Search 2.6.15-25-386:
    --> Find:
    linux-image-2.6.15-25-386
    Linux kernel image for version 2.6.15 on 386.

    Click Remove:
    Synaptic tells (update-grub /1/ ):
    Removing linux-image-2.6.15-25-386 ...
    Searching for GRUB installation directory ... found: /boot/grub
    Testing for an existing GRUB menu.list file ... found: /boot/grub/menu.lst
    Searching for splash image ... none found, skipping ...
    Found kernel: /boot/vmlinuz-2.6.15-28-k7
    Found kernel: /boot/vmlinuz-2.6.15-27-k7
    Found kernel: /boot/vmlinuz-2.6.15-26-k7
    Found kernel: /boot/memtest86+.bin
    Updating /boot/grub/menu.lst ... done

    Purging configuration files for linux-image-2.6.15-25-386 ...
    Searching for GRUB installation directory ... found: /boot/grub
    Testing for an existing GRUB menu.list file ... found: /boot/grub/menu.lst
    Searching for splash image ... none found, skipping ...
    Found kernel: /boot/vmlinuz-2.6.15-28-k7
    Found kernel: /boot/vmlinuz-2.6.15-27-k7
    Found kernel: /boot/vmlinuz-2.6.15-26-k7
    Found kernel: /boot/memtest86+.bin
    Updating /boot/grub/menu.lst ... done

    Cannot delete /boot/initrd.img-2.6.15-25-386, doesn't exist.

    After that (menu.lst):
    ...
    title Ubuntu, kernel 2.6.15-28-k7
    title Ubuntu, kernel 2.6.15-28-k7 (recovery mode)
    ...
    title Ubuntu, kernel 2.6.15-27-k7
    title Ubuntu, kernel 2.6.15-27-k7 (recovery mode)
    ...
    title Ubuntu, kernel 2.6.15-26-k7
    title Ubuntu, kernel 2.6.15-26-k7 (recovery mode)
    ...
    title Ubuntu, memtest86+
    ...
    and /boot/:

    01 2005-10-25 13:32 memtest86+.bin
    02 2006-09-08 23:35 config-2.6.15-26-k7
    03 2006-09-09 00:54 vmlinuz-2.6.15-26-k7
    04 2006-09-09 00:54 abi-2.6.15-26-k7
    05 2006-09-09 00:54 System.map-2.6.15-26-k7
    06 2006-09-14 19:10 initrd.img-2.6.15-26-k7
    07 2006-12-08 20:19 config-2.6.15-27-k7
    08 2006-12-08 21:36 vmlinuz-2.6.15-27-k7
    09 2006-12-08 21:36 abi-2.6.15-27-k7
    10 2006-12-08 21:36 System.map-2.6.15-27-k7
    11 2006-12-14 10:29 initrd.img-2.6.15-27-k7
    12 2007-03-13 23:01 config-2.6.15-28-k7
    13 2007-03-13 23:32 vmlinuz-2.6.15-28-k7
    14 2007-03-13 23:32 abi-2.6.15-28-k7
    15 2007-03-13 23:32 System.map-2.6.15-28-k7
    16 2007-04-15 01:42 initrd.img-2.6.15-28-k7

    Note #1
    If you just remove entries from the menu.lst they will be back when you update kernel next time.

    Note #2
    This makes new menu.lst.

    /1/ man update-grub tells:
    update-grub - program to generate GRUB’s menu.lst file

    DESCRIPTION
    update-grub is a program used to generate the menu.lst file used by the
    grub bootloader. It works by looking in /boot for all files which
    start with "vmlinuz-". They will be treated as kernels, and grub menu
    entries will be created for each. It will also create the initial
    menu.lst if none exists, after prompting the user. It will also add
    initrd lines for ramdisk images found with the same version as kernels
    found.
    Before you edit, BACKUP !

    Why there are dead links ?
    1. Thread: Please explain how to access old kubuntu forum posts
    2. Thread: Lost Information

    #2
    Re: HOWTO: Removing unnecessary entries from the grub menu list

    (Kubuntu 10.10 Grub 2)

    Example with the Muon package manager


    With the Kubuntu 10.10 there are Kernels installed:
    Code:
    ls -l /boot/config*
    -rw-r--r-- 1 root root 128592 2010-10-17 05:02 /boot/config-2.6.35-22-generic
    -rw-r--r-- 1 root root 128592 2010-11-24 13:21 /boot/config-2.6.35-23-generic
    -rw-r--r-- 1 root root 128614 2010-12-02 09:07 /boot/config-2.6.35-24-generic
    -rw-r--r-- 1 root root 128615 2011-01-22 00:04 /boot/config-2.6.35-25-generic
    -rw-r--r-- 1 root root 128615 2011-02-23 02:50 /boot/config-2.6.35-27-generic

    1-2-3 with the Muon:




    1) Entering the version: 2.6.35-22
    2) Status is installed
    3) Removing/Purging the selected files (linux-image-2.6.35-22-generic)

    and "Apply Changes"...

    after this there are:

    Code:
    ls -l /boot/config*
    -rw-r--r-- 1 root root 128592 2010-11-24 13:21 /boot/config-2.6.35-23-generic
    -rw-r--r-- 1 root root 128614 2010-12-02 09:07 /boot/config-2.6.35-24-generic
    -rw-r--r-- 1 root root 128615 2011-01-22 00:04 /boot/config-2.6.35-25-generic
    -rw-r--r-- 1 root root 128615 2011-02-23 02:50 /boot/config-2.6.35-27-generic

    Example with the command line:

    Code:
    sudo apt-get purge linux-image-2.6.35-23-generic
    [sudo] password for rog131:
    Reading package lists...
    Building dependency tree...
    Reading state information...
    The following packages will be REMOVED:
    linux-image-2.6.35-23-generic*
    0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
    After this operation, 107MB disk space will be freed.
    Do you want to continue [Y/n]? y
    (Reading database ... 124345 files and directories currently installed.)
    Removing linux-image-2.6.35-23-generic ...
    Examining /etc/kernel/postrm.d .
    run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.35-23-generic /boot/vmlinuz-2.6.35-23-generic
    run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.35-23-generic /boot/vmlinuz-2.6.35-23-generic
    Generating grub.cfg ...
    Found background image: my_wallpaper.png
    Found linux image: /boot/vmlinuz-2.6.35-27-generic
    Found initrd image: /boot/initrd.img-2.6.35-27-generic
    Found linux image: /boot/vmlinuz-2.6.35-25-generic
    Found initrd image: /boot/initrd.img-2.6.35-25-generic
    Found linux image: /boot/vmlinuz-2.6.35-24-generic
    Found initrd image: /boot/initrd.img-2.6.35-24-generic
    Found memtest86+ image: /boot/memtest86+.bin
    Found Microsoft Windows XP Professional on /dev/sda1
    Found Ubuntu Natty (development branch) (11.04) on /dev/sdc1
    done
    Purging configuration files for linux-image-2.6.35-23-generic ...
    Now there are:
    Code:
    ls -l /boot/config*
    -rw-r--r-- 1 root root 128614 2010-12-02 09:07 /boot/config-2.6.35-24-generic
    -rw-r--r-- 1 root root 128615 2011-01-22 00:04 /boot/config-2.6.35-25-generic
    -rw-r--r-- 1 root root 128615 2011-02-23 02:50 /boot/config-2.6.35-27-generic

    Links:
    > FAQ: Kernel
    > FAQ: Package Managers
    Last edited by Rog131; Apr 02, 2012, 10:08 AM.
    Before you edit, BACKUP !

    Why there are dead links ?
    1. Thread: Please explain how to access old kubuntu forum posts
    2. Thread: Lost Information

    Comment


      #3
      Bump-12.04

      Testing with the Kubuntu 12.04 Beta 2


      There are Kernels:
      :~$ ls -l /boot/config*
      -rw-r--r-- 1 root root 140007 Mar 10 03:22 /boot/config-3.2.0-18-generic
      -rw-r--r-- 1 root root 140153 Mar 21 04:51 /boot/config-3.2.0-19-generic
      -rw-r--r-- 1 root root 140211 Mar 27 20:22 /boot/config-3.2.0-20-generic
      -rw-r--r-- 1 root root 140243 Mar 30 08:05 /boot/config-3.2.0-21-generic
      The Grub update ( https://help.ubuntu.com/community/Grub2 ) is finding them:
      :~$ sudo update-grub
      Generating grub.cfg ...
      Found linux image: /boot/vmlinuz-3.2.0-21-generic
      Found initrd image: /boot/initrd.img-3.2.0-21-generic
      Found linux image: /boot/vmlinuz-3.2.0-20-generic
      Found initrd image: /boot/initrd.img-3.2.0-20-generic
      Found linux image: /boot/vmlinuz-3.2.0-19-generic
      Found initrd image: /boot/initrd.img-3.2.0-19-generic
      Found linux image: /boot/vmlinuz-3.2.0-18-generic
      Found initrd image: /boot/initrd.img-3.2.0-18-generic

      Pick-Purge-Removed with the Muon



      Now there are:
      :~$ ls -l /boot/config*
      -rw-r--r-- 1 root root 140153 Mar 21 04:51 /boot/config-3.2.0-19-generic
      -rw-r--r-- 1 root root 140211 Mar 27 20:22 /boot/config-3.2.0-20-generic
      -rw-r--r-- 1 root root 140243 Mar 30 08:05 /boot/config-3.2.0-21-generic
      The Grub is finding:
      :~$ sudo update-grub
      Generating grub.cfg ...
      Found linux image: /boot/vmlinuz-3.2.0-21-generic
      Found initrd image: /boot/initrd.img-3.2.0-21-generic
      Found linux image: /boot/vmlinuz-3.2.0-20-generic
      Found initrd image: /boot/initrd.img-3.2.0-20-generic
      Found linux image: /boot/vmlinuz-3.2.0-19-generic
      Found initrd image: /boot/initrd.img-3.2.0-19-generic
      Pick-Purge-Removed with the apt

      Looking kernel 3.2.0-19 with the apt-show-versions
      :~$ apt-show-versions | grep 3.2.0-19
      linux-headers-3.2.0-19 3.2.0-19.31 installed: No available version in archive
      linux-headers-3.2.0-19-generic 3.2.0-19.31 installed: No available version in archive
      linux-image-3.2.0-19-generic 3.2.0-19.31 installed: No available version in archive
      Purging (copy&paste from the apt-show-versions...):
      Code:
      sudo apt-get purge linux-headers-3.2.0-19 linux-headers-3.2.0-19-generic linux-image-3.2.0-19-generic
      Reading package lists...
      Building dependency tree...
      Reading state information...

      The following packages will be REMOVED:
      linux-headers-3.2.0-19* linux-headers-3.2.0-19-generic*
      linux-image-3.2.0-19-generic*
      0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
      After this operation, 216 MB disk space will be freed.
      Do you want to continue [Y/n]?
      There are Kernels:
      :~$ ls -l /boot/config*
      -rw-r--r-- 1 root root 140211 Mar 27 20:22 /boot/config-3.2.0-20-generic
      -rw-r--r-- 1 root root 140243 Mar 30 08:05 /boot/config-3.2.0-21-generic
      The Grub is finding:
      :~$ sudo update-grub
      Generating grub.cfg ...
      Found linux image: /boot/vmlinuz-3.2.0-21-generic
      Found initrd image: /boot/initrd.img-3.2.0-21-generic
      Found linux image: /boot/vmlinuz-3.2.0-20-generic
      Found initrd image: /boot/initrd.img-3.2.0-20-generic
      Last edited by OneLine; Apr 02, 2012, 10:55 AM.
      Have you tried ?

      - How to Ask a Question on the Internet and Get It Answered
      - How To Ask Questions The Smart Way

      Comment


        #4
        Manual mode

        http://www.kubuntuforums.net/showthr...linux-versions

        The best option is to remove the packages from the package management but if it not possible:


        Picking the unwanted kernel entries and manually moving/removing them:



        Updating the grub:
        Code:
        sudo update-grub
        [sudo] password for oneline:
        Generating grub.cfg ...
        Found linux image: /boot/vmlinuz-3.2.0-22-generic
        Found initrd image: /boot/initrd.img-3.2.0-22-generic
        Found linux image: /boot/vmlinuz-3.2.0-21-generic
        Found initrd image: /boot/initrd.img-3.2.0-21-generic
        Found memtest86+ image: /boot/memtest86+.bin
        Found Ubuntu 11.10 (11.10) on /dev/sda5
        Found Microsoft Windows XP Professional on /dev/sdc1
        done
        Have you tried ?

        - How to Ask a Question on the Internet and Get It Answered
        - How To Ask Questions The Smart Way

        Comment


          #5
          Bump 12.10

          Testing with the 12.10 beta



          There are Kernels:
          $ ls -l /boot/config*
          -rw-r--r-- 1 root root 147792 Aug 13 18:46 /boot/config-3.5.0-10-generic
          -rw-r--r-- 1 root root 147808 Aug 17 00:26 /boot/config-3.5.0-11-generic
          -rw-r--r-- 1 root root 147819 Aug 29 20:11 /boot/config-3.5.0-13-generic
          -rw-r--r-- 1 root root 147819 Sep 14 23:44 /boot/config-3.5.0-14-generic
          -rw-r--r-- 1 root root 147878 Sep 19 23:24 /boot/config-3.5.0-15-generic
          -rw-r--r-- 1 root root 147800 Aug 9 17:16 /boot/config-3.5.0-9-generic
          Picking the "3.5.0-9" and marking them to be removed (purge)



          Clik: "Apply Changes"

          The dpkg log is telling:
          $ grep "remove" /var/log/dpkg.log

          2012-09-23 19:24:11 remove linux-headers-3.5.0-9-generic:amd64 3.5.0-9.9 <none>
          2012-09-23 19:24:14 remove linux-headers-3.5.0-9:all 3.5.0-9.9 <none>
          2012-09-23 19:24:17 remove linux-image-extra-3.5.0-9-generic:amd64 3.5.0-9.9 <none>
          2012-09-23 19:24:31 remove linux-image-3.5.0-9-generic:amd64 3.5.0-9.9 <none>
          ...and the /boot/config is having:
          $ ls -l /boot/config*
          -rw-r--r-- 1 root root 147792 Aug 13 18:46 /boot/config-3.5.0-10-generic
          -rw-r--r-- 1 root root 147808 Aug 17 00:26 /boot/config-3.5.0-11-generic
          -rw-r--r-- 1 root root 147819 Aug 29 20:11 /boot/config-3.5.0-13-generic
          -rw-r--r-- 1 root root 147819 Sep 14 23:44 /boot/config-3.5.0-14-generic
          -rw-r--r-- 1 root root 147878 Sep 19 23:24 /boot/config-3.5.0-15-generic
          Have you tried ?

          - How to Ask a Question on the Internet and Get It Answered
          - How To Ask Questions The Smart Way

          Comment

          Working...
          X