Deleting files on /boot

Asked by Korrigan Nagirrok

Presently in my Xubuntu 13.10 installation i have the following kernels:

~$ dpkg-query -l | grep linux-image
ii linux-image-3.11.5-031105-generic 3.11.5-031105.201310132235 i386 Linux kernel image for version 3.11.5 on 32 bit x86 SMP
ii linux-image-3.12.0-031200-generic 3.12.0-031200.201311031935 i386 Linux kernel image for version 3.12.0 on 32 bit x86 SMP

and the contents of my /boot folder is the following:

~$ ls -lh /boot
total 233M
-rw-r--r-- 1 root root 978K Oct 14 03:50 abi-3.11.5-031105-generic
-rw-r--r-- 1 root root 985K Nov 4 00:53 abi-3.12.0-031200-generic
-rw-r--r-- 1 root root 834K Oct 9 2012 abi-3.5.0-17-generic
-rw-r--r-- 1 root root 837K Jan 8 2013 abi-3.5.0-22-generic
-rw-r--r-- 1 root root 837K Jan 24 2013 abi-3.5.0-23-generic
-rw-r--r-- 1 root root 839K Feb 7 2013 abi-3.5.0-24-generic
-rw-r--r-- 1 root root 839K Feb 25 2013 abi-3.5.0-25-generic
-rw-r--r-- 1 root root 839K Mar 8 2013 abi-3.5.0-26-generic
-rw-r--r-- 1 root root 841K Mar 25 2013 abi-3.5.0-27-generic
-rw-r--r-- 1 root root 904K Apr 17 2013 abi-3.8.0-19-generic
-rw-r--r-- 1 root root 164K Oct 14 03:50 config-3.11.5-031105-generic
-rw-r--r-- 1 root root 163K Nov 4 00:53 config-3.12.0-031200-generic
-rw-r--r-- 1 root root 151K Oct 9 2012 config-3.5.0-17-generic
-rw-r--r-- 1 root root 151K Jan 8 2013 config-3.5.0-22-generic
-rw-r--r-- 1 root root 151K Jan 24 2013 config-3.5.0-23-generic
-rw-r--r-- 1 root root 151K Feb 7 2013 config-3.5.0-24-generic
-rw-r--r-- 1 root root 151K Feb 25 2013 config-3.5.0-25-generic
-rw-r--r-- 1 root root 151K Mar 8 2013 config-3.5.0-26-generic
-rw-r--r-- 1 root root 152K Mar 25 2013 config-3.5.0-27-generic
-rw-r--r-- 1 root root 158K Apr 17 2013 config-3.8.0-19-generic
drwxr-xr-x 5 root root 4.0K Dec 5 00:36 grub
-rw-r--r-- 1 root root 16M Nov 13 21:42 initrd.img-3.11.5-031105-generic
-rw-r--r-- 1 root root 17M Dec 4 23:28 initrd.img-3.12.0-031200-generic
-rw-r--r-- 1 root root 15M Jan 25 2013 initrd.img-3.5.0-17-generic
-rw-r--r-- 1 root root 15M Jan 25 2013 initrd.img-3.5.0-22-generic
-rw-r--r-- 1 root root 15M Jan 31 2013 initrd.img-3.5.0-23-generic
-rw-r--r-- 1 root root 15M Feb 19 2013 initrd.img-3.5.0-24-generic
-rw-r--r-- 1 root root 15M Feb 26 2013 initrd.img-3.5.0-25-generic
-rw-r--r-- 1 root root 15M Mar 28 2013 initrd.img-3.5.0-26-generic
-rw-r--r-- 1 root root 15M Apr 30 2013 initrd.img-3.5.0-27-generic
-rw-r--r-- 1 root root 16M Apr 30 2013 initrd.img-3.8.0-19-generic
-rw-r--r-- 1 root root 173K Jun 17 10:52 memtest86+.bin
-rw-r--r-- 1 root root 175K Jun 17 10:52 memtest86+_multiboot.bin
-rw------- 1 root root 2.6M Oct 14 03:50 System.map-3.11.5-031105-generic
-rw------- 1 root root 2.7M Nov 4 00:53 System.map-3.12.0-031200-generic
-rw------- 1 root root 2.3M Oct 9 2012 System.map-3.5.0-17-generic
-rw------- 1 root root 2.3M Jan 8 2013 System.map-3.5.0-22-generic
-rw------- 1 root root 2.3M Jan 24 2013 System.map-3.5.0-23-generic
-rw------- 1 root root 2.3M Feb 7 2013 System.map-3.5.0-24-generic
-rw------- 1 root root 2.3M Feb 25 2013 System.map-3.5.0-25-generic
-rw------- 1 root root 2.3M Mar 8 2013 System.map-3.5.0-26-generic
-rw------- 1 root root 2.3M Mar 25 2013 System.map-3.5.0-27-generic
-rw------- 1 root root 2.4M Apr 17 2013 System.map-3.8.0-19-generic
-rw------- 1 root root 5.5M Oct 14 03:50 vmlinuz-3.11.5-031105-generic
-rw------- 1 root root 5.6M Nov 4 00:53 vmlinuz-3.12.0-031200-generic
-rw-r--r-- 1 root root 5.0M Oct 17 2012 vmlinuz-3.5.0-17-generic
-rw------- 1 root root 5.0M Jan 8 2013 vmlinuz-3.5.0-22-generic
-rw------- 1 root root 5.0M Jan 24 2013 vmlinuz-3.5.0-23-generic
-rw------- 1 root root 5.0M Feb 7 2013 vmlinuz-3.5.0-24-generic
-rw------- 1 root root 5.0M Feb 25 2013 vmlinuz-3.5.0-25-generic
-rw------- 1 root root 5.0M Mar 8 2013 vmlinuz-3.5.0-26-generic
-rw------- 1 root root 5.0M Mar 25 2013 vmlinuz-3.5.0-27-generic
-rw------- 1 root root 5.2M Apr 17 2013 vmlinuz-3.8.0-19-generic

So my question is: can I safely remove all those files that relate to previous versions of kernels from /boot​, leaving just the ones that relate to the existent kernels in my computer?

What I mean is it safe to remove all these:
1. from abi-3.5.0-17-generic to abi-3.8.0-19-generic,
2. from config-3.5.0-17-generic to config-3.8.0-19-generic,
3. from initrd.img-3.5.0-17-generic to initrd.img-3.8.0-19-generic,
4. from System.map-3.5.0-17-generic to System.map-3.8.0-19-generic;
5. from vmlinuz-3.5.0-17-generic to vmlinuz-3.8.0-19-generic,

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
David Pires
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

What is the output of:

lsb_release -a; uname -a; dpkg -l | grep linux-image

Thanks

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#2

You don't delete the files in /boot they get removed when you uninstall old kernels.

Revision history for this message
Korrigan Nagirrok (korrigan) said :
#3

The output of dpkg -l | grep linux-image I already had post it and is:

~$ dpkg-query -l | grep linux-image
ii linux-image-3.11.5-031105-generic 3.11.5-031105.201310132235 i386 Linux kernel image for version 3.11.5 on 32 bit x86 SMP
ii linux-image-3.12.0-031200-generic 3.12.0-031200.201311031935 i386 Linux kernel image for version 3.12.0 on 32 bit x86 SMP

~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 13.10
Release: 13.10
Codename: saucy

~$ uname -a
Linux VirtualBox 3.12.0-031200-generic #201311031935 SMP Fri Nov 22 20:46:38 UTC 2013 i686 i686 i686 GNU/Linux

I'm aware that the files in /boot should get remove when old kernels are uninstalled but apparently something did not work as expected as you can see by the contents of my /boot folder hence why I'm asking if I can delete the files I mentioned on my question.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#4

sudo apt-get --purge remove linux-image-3.11.5-031105-generic
sudo apt-get --purge autoremove

Should do it

Revision history for this message
Best David Pires (slickymaster) said :
#5

Since you've already removed the kernel images to which all of those files were related, no harm can came of deleting those files. Even if you remove everything except the kernel that it's currently configured to boot, no harm happens.

Revision history for this message
Korrigan Nagirrok (korrigan) said :
#6

Thanks David Pires, that solved my question.

Revision history for this message
daniel CURTIS (anoda) said :
#7

Hello everyone. Since there is a pleany of a good answers, I would like to wirte a "method", which I'm using to remove too many installed kernels, which - in fact - are old. So I'm using 12.04 LTS series. After some time and kernel updates , there is more and more config files etc., in a /boot directory and that's fine, but...

I've decided to leave only two, three kernels, that I know it's working okay. Firstly, I'm checking how many kernels are installed. I'm doing by a simple 'dpkg -l |grep linux-*' command. And now: if there is - let say - five kernels installed: from version '*.53' to '*.58', I'll remove two:

,-----[ removing 'old' kernels ] [1]
| $ sudo apt-get --purge remove linux-image-3.2.0-53-generic \
| linux-image-3.2.0-54-generic linux-image-3.2.0-55-generic \
| linux-image-3.2.0-56-generic
`-----

Now two kernels were left, right? I did the same thing with linux-headers packages, because they aren't removed automatically (an example of a command: sudo apt-get --purge remove linux-headers...) and they're occupying some disk capacity. So summing up:

* check for linux packages (installed).
* decide how many pkg's left (in my opinion: at least two)
* remove linux-i,age kernel pkg's, which I don't want/or are not needed
* remove linux-headers pkg's ...
! check if everything is okay
* do some cleaning with e.g.: sudo apt-get clean command etc.

So if we talk about a "terminal language" it could look this way:

1. dpkg -l |grep linux-image
2. sudo apt-get --purge remove linux-image-EXACT-PKG-NAME
3. dpkg -l |grep linux-headers
4. sudo apt-get --purge remove linux-headers -EXACT-PKG-NAME
!! checking !!
5. sudo apt-get clean, sudo apt-get autoclean commands etc.

I'm always doing it this way. I've had never problems. Somewhere I'm having a nice script to remove "old" kernels, but I can not find it right now. Oh, and most important thing; @Korrigan you've asked about '.abi' and '.config' files, right? After mentioned steps, they are also auto removed, so everything is really okay :- )

Best regards!
_____________
[1] I've added a '\' sign, because of launchpad site text formatting.Generally, everything should be in a one line.

Revision history for this message
daniel CURTIS (anoda) said :
#8

Uhm, I was late with a reply :- )

Revision history for this message
Korrigan Nagirrok (korrigan) said :
#9

Even though your answer came late I want to thank you daniel CURTIS (krikras) for your thorough explanation and I hope that it will serve others if they come across the same doubt I had.

Revision history for this message
daniel CURTIS (anoda) said :
#10

Hi Korrigan. Thank you for your understanding. It really means a lot for me. I'm really happy, because it seems to me, that you have no doubts, regarding to the files in a '/etc/' directory, right? ;- )

Best regards.

Revision history for this message
daniel CURTIS (anoda) said :
#11

Sorry, I mean '/boot' directory...