How to remove old kernels and headers on linux mint 13

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Brahim Salem

How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

I have Installed Linux Mint 13 Mate 64bit alongside Linux Mint 14 Cinnamon 64bit to replace Linux Mint 14 Mate 64bit. Now I get entries related to the old OS. I have installed Grub-customizer and removed them. But there are other entries that don't show up in Grub Customizer and still appear on tthe grub menu. Is there any command lines that can help me get rid of this mess???

The output of "uname -r" is:

Code: Select all

mohamed@mohamed-Inspiron-N5040 ~ $ uname -r
3.2.0-23-generic
mohamed@mohamed-Inspiron-N5040
The output of "dpkg -l | grep linux-image" is:

Code: Select all

mohamed@mohamed-Inspiron-N5040 ~ $ dpkg -l | grep linux-image
ii  linux-image-3.2.0-23-generic           3.2.0-23.36                             Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-generic                    3.2.0.23.25                             Generic Linux kernel image
mohamed@mohamed-Inspiron-N5040 ~ $ 
My /boot//grub/grub-cfg file looks like this:

Code: Select all

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function recordfail {
  set recordfail=1
  if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}

function load_video {
  insmod vbe
  insmod vga
  insmod video_bochs
  insmod video_cirrus
}

insmod part_msdos
insmod ext2
set root='(hd0,msdos7)'
search --no-floppy --fs-uuid --set=root 99b2e85d-5b00-4f5e-8df0-22b737dd1c37
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  insmod part_msdos
  insmod ext2
  set root='(hd0,msdos7)'
  search --no-floppy --fs-uuid --set=root 99b2e85d-5b00-4f5e-8df0-22b737dd1c37
  set locale_dir=($root)/boot/grub/locale
  set lang=en_US
  insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ]; then
  set timeout=-1
else
  set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/06_mint_theme ###
set menu_color_normal=white/black
set menu_color_highlight=white/light-gray
### END /etc/grub.d/06_mint_theme ###

### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
	set gfxpayload="$1"
	if [ "$1" = "keep" ]; then
		set vt_handoff=vt.handoff=7
	else
		set vt_handoff=
	fi
}
if [ ${recordfail} != 1 ]; then
  if [ -e ${prefix}/gfxblacklist.txt ]; then
    if hwmatch ${prefix}/gfxblacklist.txt 3; then
      if [ ${match} = 0 ]; then
        set linux_gfx_mode=keep
      else
        set linux_gfx_mode=text
      fi
    else
      set linux_gfx_mode=text
    fi
  else
    set linux_gfx_mode=keep
  fi
else
  set linux_gfx_mode=text
fi
export linux_gfx_mode
if [ "$linux_gfx_mode" != "text" ]; then load_video; fi
menuentry 'Linux Mint 13 MATE 64-bit, 3.2.0-23-generic (/dev/sda7)' --class linuxmint --class gnu-linux --class gnu --class os {
	recordfail
	gfxmode $linux_gfx_mode
	insmod gzio
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos7)'
	search --no-floppy --fs-uuid --set=root 99b2e85d-5b00-4f5e-8df0-22b737dd1c37
	linux	/boot/vmlinuz-3.2.0-23-generic root=UUID=99b2e85d-5b00-4f5e-8df0-22b737dd1c37 ro   quiet splash $vt_handoff
	initrd	/boot/initrd.img-3.2.0-23-generic
}
menuentry 'Linux Mint 13 MATE 64-bit, 3.2.0-23-generic (/dev/sda7) -- recovery mode' --class linuxmint --class gnu-linux --class gnu --class os {
	recordfail
	insmod gzio
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos7)'
	search --no-floppy --fs-uuid --set=root 99b2e85d-5b00-4f5e-8df0-22b737dd1c37
	echo	'Loading Linux 3.2.0-23-generic ...'
	linux	/boot/vmlinuz-3.2.0-23-generic root=UUID=99b2e85d-5b00-4f5e-8df0-22b737dd1c37 ro recovery nomodeset 
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initrd.img-3.2.0-23-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/10_lupin ###
### END /etc/grub.d/10_lupin ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos7)'
	search --no-floppy --fs-uuid --set=root 99b2e85d-5b00-4f5e-8df0-22b737dd1c37
	linux16	/boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos7)'
	search --no-floppy --fs-uuid --set=root 99b2e85d-5b00-4f5e-8df0-22b737dd1c37
	linux16	/boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober_proxy ###
menuentry "Linux Mint 14 MATE 64-bit, 3.5.0-17-generic (/dev/sda7) (on /dev/sda7)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.5.0-17-generic--b90a38ab-e5f8-4787-95ca-41d8673db81d (on /dev/sda5)" --class gnu-linux --class gnu --class os {
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos5)'
	search --no-floppy --fs-uuid --set=root af137352-32e8-4d14-ac26-b75086feead6
	linux /boot/vmlinuz-3.5.0-17-generic root=UUID=b90a38ab-e5f8-4787-95ca-41d8673db81d ro quiet splash $vt_handoff
	initrd /boot/initrd.img-3.5.0-17-generic
}
menuentry "Linux Mint 14 Nadia (14) (on /dev/sda7)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.5.0-17-generic--b90a38ab-e5f8-4787-95ca-41d8673db81d (on /dev/sda5)" --class gnu-linux --class gnu --class os {
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos5)'
	search --no-floppy --fs-uuid --set=root af137352-32e8-4d14-ac26-b75086feead6
	linux /boot/vmlinuz-3.5.0-17-generic root=UUID=af137352-32e8-4d14-ac26-b75086feead6 ro quiet splash $vt_handoff
	initrd /boot/initrd.img-3.5.0-17-generic
}
menuentry "Linux Mint 14 Cinnamon 64-bit, 3.5.0-17-generic (/dev/sda5) (on /dev/sda5)" --class gnu-linux --class gnu --class os {
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos5)'
	search --no-floppy --fs-uuid --set=root af137352-32e8-4d14-ac26-b75086feead6
	linux /boot/vmlinuz-3.5.0-17-generic root=UUID=af137352-32e8-4d14-ac26-b75086feead6 ro quiet splash $vt_handoff
	initrd /boot/initrd.img-3.5.0-17-generic
}
menuentry "Linux Mint 14 Cinnamon 64-bit, 3.5.0-17-generic (/dev/sda5) -- recovery mode (on /dev/sda5)" --class gnu-linux --class gnu --class os {
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos5)'
	search --no-floppy --fs-uuid --set=root af137352-32e8-4d14-ac26-b75086feead6
	linux /boot/vmlinuz-3.5.0-17-generic root=UUID=af137352-32e8-4d14-ac26-b75086feead6 ro recovery nomodeset
	initrd /boot/initrd.img-3.5.0-17-generic
}
### END /etc/grub.d/30_os-prober_proxy ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
jazz.h
Level 4
Level 4
Posts: 363
Joined: Sat Jun 18, 2011 7:13 am

Re: How to remove old kernels and headers on linux mint 13

Post by jazz.h »

I also have Linux Mint 13 Mate 64bit and 13 KDE.
From Mate I have deleted old kernels and headers by using Ubuntu Tweak > Janitor > Old kernel.
No problems so far...
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

Tried that but didn't work :(
passerby

Re: How to remove old kernels and headers on linux mint 13

Post by passerby »

Run

Code: Select all

sudo update-grub2
It will tell you where the files pertaining to those unwanted entries are.
eg. Mine comes up with

Code: Select all

Found linux image: /boot/vmlinuz-3.8.5-030805-generic
Found initrd image: /boot/initrd.img-3.8.5-030805-generic
so if I wanted to remove the 3.8.5 entry, I'd delete those two files, then run update-grub2 again.
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

Code: Select all

sudo update-grub2
gave me:

Code: Select all

mohamed@mohamed-Inspiron-N5040 ~ $ sudo update-grub2
[sudo] password for mohamed: 
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-23-generic
Found initrd image: /boot/initrd.img-3.2.0-23-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Linux Mint 14 Nadia (14) on /dev/sda5
done
which ones should I remove?
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

I want to remove these ntwo lines:

Code: Select all

menuentry "Linux Mint 14 MATE 64-bit, 3.5.0-17-generic (/dev/sda7) (on /dev/sda7)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.5.0-17-generic--b90a38ab-e5f8-4787-95ca-41d8673db81d (on /dev/sda5)" --class 
passerby

Re: How to remove old kernels and headers on linux mint 13

Post by passerby »

Do you have a separate /boot partition shared between both installs? Or perhaps two disks?
If not, it appears as though your other install is handling grub. Reboot into that installation and make the changes there.
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

I am runnig Linux Mint 13 Mate now.t is the one handling grub. The two OS'S have their separate ex4 and swap partitions :(
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

:roll: Where is everyone??? :roll: :roll:
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

I found this line on a Ubuntu forum:

Code: Select all

sudo apt-get purge $( dpkg --list | grep -P -o "linux-image-\d\S+" | grep -v $(uname -r | grep -P -o ".+\d") )
Is it safe to use it???
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

Heeeeeeeeeeeelp

Image
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

I kept getting this issue with Mint 13 :shock: Does anyone have a solution. I like Mint and now I'm starting to think of ditching it :roll: :roll: ? :roll:
passerby

Re: How to remove old kernels and headers on linux mint 13

Post by passerby »

That command listed above will remove the kernels it finds other than the one currently in use.
I don't know about using it on a system with multiple installs.
You can just run the first part to see which kernels it finds:

Code: Select all

dpkg --list | grep -P -o "linux-image-\d\S+"
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

Code: Select all

dpkg --list | grep -P -o "linux-image-\d\S+"
gave me::

Code: Select all

mohamed@mohamed-Inspiron-N5040 ~ $ dpkg --list | grep -P -o "linux-image-\d\S+"
linux-image-3.2.0-23-generic
mohamed@mohamed-Inspiron-N5040 ~ $
Shoud I edit grub.cfg instead?? :roll:

Does upgrading grub solve the issue? Because this issue is common only on LM 13 and the latest version of grub is more clean :roll: I made a tutorial on how to do it here http://forums.linuxmint.com/viewtopic.php?f=42&t=132488.
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

What are these two ugly lines on my GRUB Menu :oops: :oops: :roll:

Code: Select all

menuentry "Linux Mint 14 MATE 64-bit, 3.5.0-17-generic (/dev/sda7) (on /dev/sda7)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.5.0-17-generic--b90a38ab-e5f8-4787-95ca-41d8673db81d (on /dev/sda5)" --class 
BTW

Code: Select all

    grep menuentry /boot/grub/grub.cfg
gives:

Code: Select all

mohamed@mohamed-Inspiron-N5040 ~ $ grep menuentry /boot/grub/grub.cfg
menuentry 'Linux Mint 13 MATE 64-bit, 3.2.0-23-generic (/dev/sda7)' --class linuxmint --class gnu-linux --class gnu --class os {
menuentry 'Linux Mint 13 MATE 64-bit, 3.2.0-23-generic (/dev/sda7) -- recovery mode' --class linuxmint --class gnu-linux --class gnu --class os {
menuentry "Linux Mint 14 MATE 64-bit, 3.5.0-17-generic (/dev/sda7) (on /dev/sda7)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.5.0-17-generic--b90a38ab-e5f8-4787-95ca-41d8673db81d (on /dev/sda5)" --class gnu-linux --class gnu --class os {
menuentry "Linux Mint 14 Nadia (14) (on /dev/sda7)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.5.0-17-generic--b90a38ab-e5f8-4787-95ca-41d8673db81d (on /dev/sda5)" --class gnu-linux --class gnu --class os {
menuentry "Linux Mint 14 Cinnamon 64-bit, 3.5.0-17-generic (/dev/sda5) (on /dev/sda5)" --class gnu-linux --class gnu --class os {
menuentry "Linux Mint 14 Cinnamon 64-bit, 3.5.0-17-generic (/dev/sda5) -- recovery mode (on /dev/sda5)" --class gnu-linux --class gnu --class os {
mohamed@mohamed-Inspiron-N5040 ~ $
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

Image

Image
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

HELP
Brahim Salem

Re: How to remove old kernels and headers on linux mint 13

Post by Brahim Salem »

HEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEELP
WarBishop

Re: How to remove old kernels and headers on linux mint 13

Post by WarBishop »

Synaptic > Quick search box > type in linux-image

Mark for Removal > linux-image-generic 3.2.0.23.25
Locked

Return to “Installation & Boot”