My first issue was when I tried to apt-get update
or apt-get upgrade
. On upgrade I get the following error:
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
linux-image-server : Depends: linux-image-3.2.0-27-generic but it is not installed
E: Unmet dependencies. Try using -f.
I tried running apt-get install -f and this was the output(after saying yes on prompt)
(Reading database ... 186183 files and directories currently installed.)
Unpacking linux-image-3.2.0-27-generic (from .../linux-image-3.2.0-27-generic_3.2.0-27.43_amd64.deb) ...
Done.
dpkg: error processing /var/cache/apt/archives/linux-image-3.2.0-27-generic_3.2.0-27.43_amd64.deb (--unpack):
failed in write on buffer copy for backend dpkg-deb during `./boot/System.map-3.2.0-27-generic': No space left on device
No apport report written because the error message indicates a disk full error
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-27-generic /boot/vmlinuz-3.2.0-27-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-27-generic /boot/vmlinuz-3.2.0-27-generic
Errors were encountered while processing:
/var/cache/apt/archives/linux-image-3.2.0-27-generic_3.2.0-27.43_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I tried running apt-get autoremove
and it gives me the same error as apt-get upgrade
.
When I run df
, I get this for /boot
:
/dev/sda1 233191 230297 0 100% /boot
So, I read elsewhere that I should try to purge old kernels. I checked for what kernels I had with:
$ dpkg -l linux-image-\* | grep ^ii
ii linux-image-2.6.38-13-server 2.6.38-13.52 Linux kernel image for version 2.6.38 on x86_64
ii linux-image-3.0.0-13-server 3.0.0-13.22 Linux kernel image for version 3.0.0 on x86_64
ii linux-image-3.0.0-14-server 3.0.0-14.23 Linux kernel image for version 3.0.0 on x86_64
ii linux-image-3.0.0-15-server 3.0.0-15.26 Linux kernel image for version 3.0.0 on x86_64
ii linux-image-3.0.0-16-server 3.0.0-16.29 Linux kernel image for version 3.0.0 on x86_64
ii linux-image-3.0.0-17-server 3.0.0-17.30 Linux kernel image for version 3.0.0 on x86_64
ii linux-image-3.2.0-24-generic 3.2.0-24.39 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-25-generic 3.2.0-25.40 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-26-generic 3.2.0-26.41 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
When I try to remove the oldest with this:
$ sudo apt-get purge linux-image-2.6.38-13-server
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-server : Depends: linux-image-3.2.0-27-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
How can I free up or extend boot without messing up my installation?
Freeing Up Space on the Root File System
To free up space on the root file system you can try to execute
apt-get clean
.If that doesn't work you can go to
/var/cache/apt/archives
and manually remove a few files from the cache to get some space back, e.g.:It won't hurt to remove all of the
.deb
files here if you need to - that is whatapt-get clean
does. They will be automatically be re-downloaded byapt
if they are needed again.Freeing Up Space on the /boot File System
The Original Poster has a separate
/boot
partition, and that is what is full and preventing theapt
system from working. It will be necessary for him to free up space there.If there almost enough space, go to
/boot
and remove a config file or two:for example, but using the name of one of the kernel versions you intend to remove anyway. This will free up a little space (about 144K apiece).
If you need more space individually remove old
vmlinuz
,initrd
,abi
andSystem.map
files until you have enough space (about 22M for one of my i386 kernel versions).Whatever you do, don't remove them all. You should at least keep the latest two matching versions of each kind of file, for each kind of kernel you use.
Then proceed with your apt-get install commands. As mentioned above they may have to re-download some of the debs you deleted, but if so that will happen automatically. When you have apt working again, clean up by using apt-get to remove the packages corresponding to the files you removed - so everything matches.
The config file in
/boot
is the kernel config that was used by the kernel team to build the kernel of the same name. It should be harmless to remove unless you want it for reference or to aid you in building your own kernels.Finally you are manually removing an old kernel package or two from the
/boot
partition to make even more room for the new one.In my case, the
apt
commands anddpkg
command could not finish, and could not remove. The autoupdate had failed on installing2.6.32-56-server
.My first step, was to identify space to be used,
I had about 30 kernels and supporting files.
I did a
uname -a
to get the running kernel, I identified that I was on Linux alternate2.6.32-43-server
and did atar
of 6 of the versions that were not running, and were old.I then did a
rm -rf
of what I had backed up:I am showing these commands as examples, you will have to decide what you will work with for your situation.
Now that I had some space on
/boot
, I was able to runTo clean up the failed install of
2.6.32-56-server
.I then did a
This gave me room to put back what I had backed up.
To clean up, I then could run:
I rebooted and am now down to using 4% of
/boot
.You can use
dpkg
instead ofapt-get
to remove older kernels:I noticed there were still some files of the old versions in the boot directory:
And the package manager would list the old versions:
I therefore used this command (
autoremove
would also remove more recent images I don't want to remove)I had still some headers left:
So I did this:
Finally there was one package left I couldn't remove with apt-get purge:
Source: Remove a package marked as rc by dpkg
I found that the only thing that worked for me was using Aptitude.
Then when it opens it will usually say something about unmet dependencies on the bottom. You can hit the letter
g
to proceed with the suggested removal. It will take you to a page where it lists what is going to happen.There should be a minus
-
next to the broken kernels. Pressg
again and it will remove the broken kernels. Pressq
to quit. Then you should be able to usesudo apt-get autoremove
to get rid of the old kernels and free up space.UPDATE 2022: Another way is to manually remove some kernel files, especially if aptitude isn't installed:
First check your running kernel to make sure you don't delete it:
Then list the modules directory:
For example, here is a list from one of my servers:
Remove all but the newest 2 from this directory. For example:
Also check the /boot directory and do the same process there.
Then check to see if some space was freed up:
Finally run apt to fix the broken packages:
Check the use of
/var/tmp
withdu -sh /var/tmp/
. All files in that folder can be deleted to make space.You can then run the following to remove the old kernels:
Install linux-purge tool like this.
Then run this in terminal:
Then go on removing kernels by e.g.
Extra:
If I recall correctly there is a default setting in Ubuntu 18.04 and later for unattended-upgrades that removes unneeded kernels, but it can not cope with the case that system is already full: The setting is
Unattended-Upgrade::Remove-Unused-Kernel-Packages true
.If you want to use linux-purge for unattended kernel removal instead of using unattended-upgrades for that, you should disable removing unused kernels by editing /etc/apt/apt.conf.d/50unattended-upgrades or preferably an overriding separate file (e.g. /etc/apt/apt.conf.d/52unattended-upgrades-local); that means at least setting
Thereafter set up a systemd service executing
whenever you want.
You cannot act upon packages, but you can act upon other files. First, go through your home folder and see whether there is anything you can delete. If not, try to move a good amount of files to another partition (or a flash drive) and then try
sudo apt-get install -f
to clean up the package dependency issues (most likely you installed a .deb file throughdpkg
), and then purge any old kernels. Once you safely have at least 10 MB, try purging unneeded software or files.This is what I used:
Do that for all old kernels and only keep the most recent two.
If you want to automatically remove the old kernels and update GRUB see this: Ubuntu Documentation
Run this:
Source: I get this error after upgade. please help