Ubuntu: Cannot Remove old Kernels from Full Boot Disk



Question:

I am unable to install or update any software on my machine.

Using my incredible powers of inference I deduced that /boot was full and was causing all my heartache.

notlinus@NS0:/boot$ df -h

Filesystem                Size  Used Avail Use% Mounted on  udev                      2.0G  4.0K  2.0G   1% /dev  tmpfs                     396M  656K  395M   1% /run  /dev/mapper/NS0--vg-root   36G  3.6G   30G  11% /  none                      4.0K     0  4.0K   0% /sys/fs/cgroup  none                      5.0M     0  5.0M   0% /run/lock  none                      2.0G     0  2.0G   0% /run/shm  none                      100M     0  100M   0% /run/user  /dev/sda1                 236M  234M     0 100% /boot  

notlinus@NS0:/boot$ ls -l

total 229780  -rw-r--r-- 1 root root  1270654 Aug 12  2015 abi-3.19.0-26-generic  -rw-r--r-- 1 root root  1271100 Sep  1  2015 abi-3.19.0-28-generic  -rw-r--r-- 1 root root  1271518 Oct  3 00:54 abi-3.19.0-30-generic  -rw-r--r-- 1 root root  1271689 Oct  8 13:01 abi-3.19.0-31-generic  -rw-r--r-- 1 root root  1271689 Oct 22 13:14 abi-3.19.0-32-generic  -rw-r--r-- 1 root root  1271689 Nov  6 20:39 abi-3.19.0-33-generic  -rw-r--r-- 1 root root  1271691 Nov 23 16:57 abi-3.19.0-37-generic  -rw-r--r-- 1 root root   177632 Aug 12  2015 config-3.19.0-26-generic  -rw-r--r-- 1 root root   177651 Sep  1  2015 config-3.19.0-28-generic  -rw-r--r-- 1 root root   177730 Oct  3 00:54 config-3.19.0-30-generic  -rw-r--r-- 1 root root   177790 Oct  8 13:01 config-3.19.0-31-generic  -rw-r--r-- 1 root root   177790 Oct 22 13:14 config-3.19.0-32-generic  -rw-r--r-- 1 root root   177790 Nov  6 20:39 config-3.19.0-33-generic  -rw-r--r-- 1 root root   177790 Nov 23 16:57 config-3.19.0-37-generic  drwxr-xr-x 5 root root     1024 Feb 17 13:47 grub  -rw-r--r-- 1 root root 20754747 Aug 27  2015 initrd.img-3.19.0-26-generic  -rw-r--r-- 1 root root 20753554 Sep  9 06:29 initrd.img-3.19.0-28-generic  -rw-r--r-- 1 root root 20756217 Oct  6 07:03 initrd.img-3.19.0-30-generic  -rw-r--r-- 1 root root 20758684 Oct 22 13:04 initrd.img-3.19.0-31-generic  -rw-r--r-- 1 root root 20757000 Nov  5 06:55 initrd.img-3.19.0-32-generic  -rw-r--r-- 1 root root 20758873 Nov 10 07:17 initrd.img-3.19.0-33-generic  -rw-r--r-- 1 root root 20757964 Dec  2 06:54 initrd.img-3.19.0-37-generic  -rw-r--r-- 1 root root  3463561 Feb 17 13:46 initrd.img-3.19.0-39-generic  -rw-r--r-- 1 root root  3463563 Feb 17 13:47 initrd.img-3.19.0-42-generic  drwx------ 2 root root    12288 Aug 27  2015 lost+found  -rw-r--r-- 1 root root   176500 Mar 12  2014 memtest86+.bin  -rw-r--r-- 1 root root   178176 Mar 12  2014 memtest86+.elf  -rw-r--r-- 1 root root   178680 Mar 12  2014 memtest86+_multiboot.bin  -rw------- 1 root root  3626965 Aug 12  2015 System.map-3.19.0-26-generic  -rw------- 1 root root  3626779 Sep  1  2015 System.map-3.19.0-28-generic  -rw------- 1 root root  3627906 Oct  3 00:54 System.map-3.19.0-30-generic  -rw------- 1 root root  3628177 Oct  8 13:01 System.map-3.19.0-31-generic  -rw------- 1 root root  3628149 Oct 22 13:14 System.map-3.19.0-32-generic  -rw------- 1 root root  3628149 Nov  6 20:39 System.map-3.19.0-33-generic  -rw------- 1 root root  3628776 Nov 23 16:57 System.map-3.19.0-37-generic  -rw------- 1 root root  6570192 Aug 12  2015 vmlinuz-3.19.0-26-generic  -rw------- 1 root root  6568848 Sep  1  2015 vmlinuz-3.19.0-28-generic  -rw------- 1 root root  6572496 Oct  3 00:54 vmlinuz-3.19.0-30-generic  -rw------- 1 root root  6572336 Oct  8 13:01 vmlinuz-3.19.0-31-generic  -rw------- 1 root root  6572944 Oct 22 13:14 vmlinuz-3.19.0-32-generic  -rw------- 1 root root  6572432 Nov  6 20:39 vmlinuz-3.19.0-33-generic  -rw------- 1 root root  6571920 Nov 23 16:57 vmlinuz-3.19.0-37-generic  

notlinus@NS0:/boot$ uname -r

3.19.0-37-generic  

notlinus@NS0:~$ sudo apt-get clean

notlinus@NS0:/boot$ sudo apt-get autoremove

Reading package lists... Done  Building dependency tree  Reading state information... Done  You might want to run ‘apt-get -f install’ to correct these.  The following packages have unmet dependencies.   linux-image-extra-3.19.0-49-generic : Depends: linux-image-3.19.0-49-generic but it is not installed   linux-image-generic-lts-vivid : Depends: linux-image-3.19.0-49-generic but it is not installed                                   Recommends: thermald but it is not installed  E: Unmet dependencies. Try using -f.  

notlinus@NS0:/boot$ sudo dpkg --list 'linux-image*'

Desired=Unknown/Install/Remove/Purge/Hold  | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend  |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)  ||/ Name                                Version                Architecture           Description  +++-===================================-======================-======================-===========================================================================  un  linux-image                         <none>                 <none>                 (no description available)  un  linux-image-3.0                     <none>                 <none>                 (no description available)  rc  linux-image-3.19.0-25-generic       3.19.0-25.26~14.04.1   amd64                  Linux kernel image for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-3.19.0-26-generic       3.19.0-26.28~14.04.1   amd64                  Linux kernel image for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-3.19.0-28-generic       3.19.0-28.30~14.04.1   amd64                  Linux kernel image for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-3.19.0-30-generic       3.19.0-30.34~14.04.1   amd64                  Linux kernel image for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-3.19.0-31-generic       3.19.0-31.36~14.04.1   amd64                  Linux kernel image for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-3.19.0-32-generic       3.19.0-32.37~14.04.1   amd64                  Linux kernel image for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-3.19.0-33-generic       3.19.0-33.38~14.04.1   amd64                  Linux kernel image for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-3.19.0-37-generic       3.19.0-37.42~14.04.1   amd64                  Linux kernel image for version 3.19.0 on 64 bit x86 SMP  in  linux-image-3.19.0-39-generic       <none>                 amd64                  (no description available)  in  linux-image-3.19.0-42-generic       <none>                 amd64                  (no description available)  in  linux-image-3.19.0-49-generic       <none>                 amd64                  (no description available)  rc  linux-image-extra-3.19.0-25-generic 3.19.0-25.26~14.04.1   amd64                  Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-extra-3.19.0-26-generic 3.19.0-26.28~14.04.1   amd64                  Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-extra-3.19.0-28-generic 3.19.0-28.30~14.04.1   amd64                  Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-extra-3.19.0-30-generic 3.19.0-30.34~14.04.1   amd64                  Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-extra-3.19.0-31-generic 3.19.0-31.36~14.04.1   amd64                  Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-extra-3.19.0-32-generic 3.19.0-32.37~14.04.1   amd64                  Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP  ii  linux-image-extra-3.19.0-33-generic 3.19.0-33.38~14.04.1   amd64                  Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP  iF  linux-image-extra-3.19.0-37-generic 3.19.0-37.42~14.04.1   amd64                  Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP  iU  linux-image-extra-3.19.0-49-generic 3.19.0-49.55~14.04.1   amd64                  Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP  iU  linux-image-generic-lts-vivid       3.19.0.49.34           amd64                  Generic Linux kernel image  

notlinus@NS0:/boot$ sudo apt-get remove linux-image-3.19.0-26-generic

Reading package lists... Done  Building dependency tree  Reading state information... Done  You might want to run 'apt-get -f install' to correct these:  The following packages have unmet dependencies.   linux-image-extra-3.19.0-26-generic : Depends: linux-image-3.19.0-26-generic but it is not going to be installed   linux-image-extra-3.19.0-49-generic : Depends: linux-image-3.19.0-49-generic but it is not going to be installed   linux-image-generic-lts-vivid : Depends: linux-image-3.19.0-49-generic but it is not going to be installed                                   Recommends: thermald but it is not going to be installed  E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).  

Im sure this must be a duplicate question but after searching around the solutions to similar questions did not aleviate my predicament.

Lastly, I am a RHEL admin so please excuse my apt ignorance - our BIND servers have to be on Ubuntu as a condition of some free colo space by our sister company. What am I doing wrong that caused this issue and how can I avoid it happening in future?

When I try similar solutions on this site such as How do I free up more space in /boot? I get:

notlinus@NS0:/boot$ sudo dpkg -fl linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge  You might want to run ‘apt-get -f install’ to correct these.  The following packages have unmet dependencies.   linux-image-extra-3.19.0-26-generic : Depends: linux-image-3.19.0-26-generic but it is not installed   linux-image-extra-3.19.0-28-generic : Depends: linux-image-3.19.0-28-generic but it is not installed   linux-image-extra-3.19.0-30-generic : Depends: linux-image-3.19.0-30-generic but it is not installed   linux-image-extra-3.19.0-31-generic : Depends: linux-image-3.19.0-31-generic but it is not installed   linux-image-extra-3.19.0-32-generic : Depends: linux-image-3.19.0-32-generic but it is not installed   linux-image-extra-3.19.0-33-generic : Depends: linux-image-3.19.0-33-generic but it is not installed   linux-image-extra-3.19.0-49-generic : Depends: linux-image-3.19.0-49-generic but it is not installed   linux-image-generic-lts-vivid : Depends: linux-image-3.19.0-49-generic but it is not installed                                   Recommends: thermald but it is not installed  E: Unmet dependencies. Try using -f.  


Solution:1

Thanks @mikewhatever,

sudo dpkg --force-all -P pkgname was the answer

So: sudo dpkg --force-all -P linux-image-extra-3.19.0-26-generic did it for me


Solution:2

Since Ubuntu 14.04 Trusty , this command supports older kernels except the last two . It is very easy and safe to remove old kernels other than the last 2 by typing in a terminal the command:

sudo apt-get autoremove --purge  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »