Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I know this question is asked many times before, however with me it is just a bit different I guess.

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       224G  5.2G  208G   3% /
udev            1.9G  4.0K  1.9G   1% /dev
tmpfs           777M  260K  777M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            1.9G     0  1.9G   0% /run/shm
/dev/sda2        90M   88M     0 100% /boot
/dev/sda6       1.9G  514M  1.3G  29% /tmp

My boot partition is full.

Current Kernel:

# uname -r
3.2.0-35-generic

All Kernels:

# dpkg --list | grep linux-image
ii  linux-image-3.2.0-32-generic    3.2.0-32.51                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-34-generic    3.2.0-34.53                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-35-generic    3.2.0-35.55                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
iF  linux-image-3.2.0-37-generic    3.2.0-37.58                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
iF  linux-image-3.2.0-38-generic    3.2.0-38.60                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
iU  linux-image-generic             3.2.0.37.45                         Generic Linux kernel image

So I thought of removing the 3.2.0.32-generic kernel with:

# sudo apt-get purge linux-image-3.2.0-32-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-generic : Depends: linux-headers-generic (= 3.2.0.37.45) but 3.2.0.38.46 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

No success.

When I try apt-get -f install it also fails:

# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.2.0-34 linux-headers-3.2.0-35 linux-headers-3.2.0-34-generic linux-headers-3.2.0-35-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  linux-generic linux-image-generic
The following packages will be upgraded:
  linux-generic linux-image-generic
2 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
5 not fully installed or removed.
Need to get 0 B/4,334 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up initramfs-tools (0.99ubuntu13.1) ...
update-initramfs: deferring update (trigger activated)
Setting up linux-image-3.2.0-37-generic (3.2.0-37.58) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
The link /initrd.img is a dangling linkto /boot/initrd.img-3.2.0-38-generic
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-37-generic /boot/vmlinuz-3.2.0-37-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-37-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.2.0-37-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.2.0-37-generic.postinst line 1010.
dpkg: error processing linux-image-3.2.0-37-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
Setting up linux-image-3.2.0-38-generic (3.2.0-38.60) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
The link /initrd.img is a dangling linkto /boot/initrd.img-3.2.0-37-generic
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-38-generic /boot/vmlinuz-3.2.0-38-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-38-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.2.0-38-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.2.0-38-generic.postinst line 1010.
dpkg: error processing linux-image-3.2.0-38-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.2.0-37-generic; however:
  Package linux-image-3.2.0-37-generic is not configured yet.
dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 3.2.0.37.45); however:
  Package linux-image-generic is not configured yet.
 linux-generic depends on linux-headers-generic (= 3.2.0.37.45); however:
  Version of linux-headers-generic on system is 3.2.0.38.46.
dpkg: error processing linux-generic (--configure):
 dependency problems - leaving unconfigured
Processing triggers for initramfs-tools ...
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because MaxReports is reached already
  update-initramfs: Generating /boot/initrd.img-3.2.0-35-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.2.0-35-generic with 1.
dpkg: error processing initramfs-tools (--configure):
 subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
 linux-image-3.2.0-37-generic
 linux-image-3.2.0-38-generic
 linux-image-generic
 linux-generic
 initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

Any help would really be appreciated.

Update: I did:

sudo rm /boot/*-3.2.0-32-generic /boot/*-3.2.0-34-generic

After that the following problem with apt-get -f install:

root@localhost:/# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  linux-generic
The following packages will be upgraded:
  linux-generic
1 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
1 not fully installed or removed.
Need to get 0 B/1,722 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 3.2.0.37.45); however:
  Version of linux-image-generic on system is 3.2.0.38.46.
 linux-generic depends on linux-headers-generic (= 3.2.0.37.45); however:
  Version of linux-headers-generic on system is 3.2.0.38.46.
dpkg: error processing linux-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error     from a previous failure.
                      Errors were encountered while processing:
 linux-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
share|improve this question

7 Answers 7

You cannot use apt-get when your kernel is outdated.

cd /boot
sudo rm *-2.6.35-6.9-generic

use ls to see what is in the folder remove the oldest one or two then

sudo apt-get -f install

Then you cen either apt-get purge as in

sudo apt-get purge linux-image-3.2.0-32-generic linux-image-3.2.0-34-generic

or just continue with rm.

you should also sudo update-grub when you are finsihed

share|improve this answer

For Ubuntu 12.04 try this sudo apt-get purge linux-image-[kernel version]

This will delete any kernel version. If your boot folder has many kernels don't forget updating grub and rebooting your system

ex. sudo apt-get purge linux-image-3.11.6*

share|improve this answer
1  
The problem is that this doesn't work anymore when one has a point where there are dependency problems, like the one ahead. –  Paŭlo Ebermann Oct 8 '13 at 11:00
    
This works for me! –  Daniel Oct 16 '13 at 13:52

In a terminal, execute the following command:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

This command lists all currently installed Linux kernels, then selects all of the ones that are currently not used and removes them.

share|improve this answer
    
Perhaps you would like to explain what this command does exactly. It looks rather complicated: in general, people should be advised away from running commands like this they don't understand - especially with something vital to their system. –  mtdevans Jan 7 at 1:22
    
@mtdevans: I have added that the above command lists all currently installed Linux kernels, then selects all of the ones that are currently not used, and then removes all the kernels that are currently not used. –  Kristian Nov 5 at 16:05

I hope this can help:

i usually delete old kernels using ubuntu-tweak janitor, nice GUI and easy :)

click on 'system' and there will be list of old kernels, just click it and clean

share|improve this answer
    
it's an ubuntu server and i am connected through putty. (But i also have the availability to Webmin on the server) –  Marcel Mar 3 '13 at 13:50

You can delete old kernel files to free some space. Try:

sudo rm /boot/*-3.2.0-32-generic /boot/*-3.2.0-34-generic
apt-get -f install
sudo apt-get purge linux-image-3.2.0-32-generic linux-image-3.2.0-34-generic

90MB is not enough for /boot, I recommend at least 300MB.

share|improve this answer
    
Run update-grub after manually removing kernel files? –  catalesia Mar 3 '13 at 10:26
    
@Marcel OK, last shot. Remove all the package lists: sudo rm /var/cache/apt/* /var/lib/apt/lists/* /var/lib/apt/lists/partial/* . Run sudo apt-get update to redownload them all. And please remove the above comments to keep this clean. –  Eric Carvalho Mar 3 '13 at 14:41

you need to fix your dependency problems first. I had the same problem with my moms 12.04 LTS box. She was doing updates and JUST before the child process (apt-get or dpkg, i guess) finished, she turned off her computer. I just went to this link on askubuntu and it fixed the problem. then I removed a few old kernels just like you are going to. I hope this helps you. :)

I love Ubuntu, (and Debian GNU/Linux of course :) but I am not a apt or dpkg hacker, but I wish there was a way to make ALL updates atomic. like ACID in PostgreSQL, MySQL, etc... (mainly Atomicity) I am learning so it is a work in progress...

Unmet Dependencies for linux-generic

share|improve this answer
2  
The problem is that solving the unmet dependencies (i.e. installing them) is not possible because of the full disk. –  Paŭlo Ebermann Oct 8 '13 at 12:13

Open up a new terminal and do the following command for removing the old kernels.

sudo apt-get autoremove
share|improve this answer
    
Sorry, that does not work: root@localhost:~# 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-generic : Depends: linux-headers-generic (= 3.2.0.37.45) but 3.2.0.38.46 is installed E: Unmet dependencies. Try using -f. root@localhost:~# –  Marcel Mar 3 '13 at 10:17
    
Maby try the command on your user account. Without sudo su. It is not recommended to use that command. –  Thomas15v Mar 3 '13 at 10:20
1  
The problem are that the unmet dependencies make all the normal apt-get operations impossible, and it is not possible to solve them because of the full disk. –  Paŭlo Ebermann Oct 8 '13 at 12:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.