8

Whenever I try to install/uninstall any software I get similar error saying that 'No space left on device'. I tried removing old kernels but got similar errors.

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.19.0-56-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-3.19.0-56-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have triedsudo apt-get autoremove --purge as suggested online but with no help. I have read the previous post for similar questions too but they did not help either.

Because of this I am unable to install/uninstall anything at all.

sourav@Valkyrie:~$ ls /boot
abi-3.19.0-56-generic                  initrd.img-4.4.0-34-generic
abi-3.19.0-61-generic                  initrd.img-4.4.0-34-generic.old-dkms
abi-3.19.0-64-generic                  lost+found
abi-3.19.0-65-generic                  memtest86+.bin
abi-4.4.0-34-generic                   memtest86+.elf
config-3.19.0-56-generic               memtest86+_multiboot.bin
config-3.19.0-61-generic               System.map-3.19.0-56-generic
config-3.19.0-64-generic               System.map-3.19.0-61-generic
config-3.19.0-65-generic               System.map-3.19.0-64-generic
config-4.4.0-34-generic                System.map-3.19.0-65-generic
grub                                   System.map-4.4.0-34-generic
initrd.img-3.19.0-56-generic           vmlinuz-3.19.0-56-generic
initrd.img-3.19.0-56-generic.old-dkms  vmlinuz-3.19.0-61-generic
initrd.img-3.19.0-61-generic           vmlinuz-3.19.0-64-generic
initrd.img-3.19.0-64-generic           vmlinuz-3.19.0-65-generic
initrd.img-3.19.0-65-generic           vmlinuz-4.4.0-34-generic
sourav@Valkyrie:~$ df -h
Filesystem                   Size  Used Avail Use% Mounted on
udev                         2.0G     0  2.0G   0% /dev
tmpfs                        396M  6.4M  390M   2% /run
/dev/mapper/ubuntu--vg-root  913G  215G  652G  25% /
tmpfs                        2.0G  248K  2.0G   1% /dev/shm
tmpfs                        5.0M  4.0K  5.0M   1% /run/lock
tmpfs                        2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/sda1                    236M  228M     0 100% /boot
cgmfs                        100K     0  100K   0% /run/cgmanager/fs
tmpfs                        396M   64K  396M   1% /run/user/1000
8
  • You may have to remove some old kernels by hand... post the output of ls /boot and df -h please? (copy and paste and format as code with the {} button)
    – Zanna
    Jun 26, 2017 at 15:20
  • I tried removing old kernels but got same output.
    – Sourav Das
    Jun 27, 2017 at 15:58
  • I am new to askunbuntu so I could not find the code format in comments. Sorry for that.
    – Sourav Das
    Jun 27, 2017 at 16:03
  • Please let me know what additional details you require.
    – Sourav Das
    Jun 27, 2017 at 16:05
  • I have edited the question. As you can see the boot partition is fully used. So I tried removing old kernels but I could not. Obviously I am missing something.
    – Sourav Das
    Jun 27, 2017 at 16:22

2 Answers 2

20

I see you have some old kernels there, seemingly from a previous version of Ubuntu. I think that autoremove fails to act on kernels with a different major version number - at least I have seen cases before like that.

You also have a very small /boot partition. In the long term, or even now if it's an option, I would recommend you reinstall and not create a separate boot partition, or if you do make sure it is bigger. My experience is that the installer does not create one by default; on an UEFI system a small EFI system partition is created mounted on /boot/efi which doesn't interfere with the space in /boot where kernels are stored.

In the short term, you can make space by deleting the kernels yourself. You can remove all traces of the kernel by hand using the version string if APT cannot.

First check which kernel is running with the command

uname -r

it will output the version string, for example 4.4.0-34-generic

Do not delete that kernel

Choose one of the other versions you see in ls /boot; start with the oldest one 3.19.0-56-generic and find all the files that belong to it:

locate -b -e 3.19.0-56-generic

Now you can delete them using xargs

locate -b -e 3.19.0-56-generic | xargs -p sudo rm -r

You will see a list of files that will be deleted and you will be asked to confirm. If the list looks OK, type y and the files will be deleted.

Check that the files were removed:

sudo updatedb && locate -b -e 3.19.0-56-generic

Repeat this with the next oldest kernel. It is very much advisable to always keep a spare kernel, but I don't think those old kernels will be much use to you anyway, and your current kernel is presumably stable, so you can either continue until you only have only the currently running kernel version (indicated by uname -r) or only two kernel versions in /boot, then run

sudo update-grub
sudo apt update
sudo apt upgrade

And, fingers crossed, update-initramfs should be able to run OK. To maintain the situation, every time you get a new kernel, run

sudo apt autoremove
0

The clean way to uninstall old kernels when the space on your /boot partition has filled up is by uninstalling old linux-image packages.

[I] ~ ❯❯❯ dpkg -l | grep linux-image
rc  linux-image-4.19.0-6-amd64                       4.19.67-2+deb10u1                             amd64        Linux 4.19 for 64-bit PCs (signed)
rc  linux-image-5.10.0-2-amd64                       5.10.9-1                                      amd64        Linux 5.10 for 64-bit PCs (signed)
rc  linux-image-5.10.0-5-amd64                       5.10.24-1                                     amd64        Linux 5.10 for 64-bit PCs (signed)
rc  linux-image-5.10.0-6-amd64                       5.10.28-1                                     amd64        Linux 5.10 for 64-bit PCs (signed)
rc  linux-image-5.14.0-1-amd64                       5.14.6-3                                      amd64        Linux 5.14 for 64-bit PCs (signed)
rc  linux-image-5.14.0-2-amd64                       5.14.9-2                                      amd64        Linux 5.14 for 64-bit PCs (signed)
rc  linux-image-5.14.0-3-amd64                       5.14.12-1                                     amd64        Linux 5.14 for 64-bit PCs (signed)
rc  linux-image-5.14.0-4-amd64                       5.14.16-1                                     amd64        Linux 5.14 for 64-bit PCs (signed)
ic  linux-image-5.15.0-2-amd64                       5.15.5-2                                      amd64        Linux 5.15 for 64-bit PCs (signed)
rc  linux-image-5.15.0-3-amd64                       5.15.15-2                                     amd64        Linux 5.15 for 64-bit PCs (signed)
rc  linux-image-5.16.0-3-amd64                       5.16.11-1                                     amd64        Linux 5.16 for 64-bit PCs (signed)
rc  linux-image-5.17.0-1-amd64                       5.17.3-1                                      amd64        Linux 5.17 for 64-bit PCs (signed)
ii  linux-image-5.18.0-4-amd64                       5.18.16-1                                     amd64        Linux 5.18 for 64-bit PCs (signed)
ii  linux-image-5.19.0-2-amd64                       5.19.11-1                                     amd64        Linux 5.19 for 64-bit PCs (signed)
rc  linux-image-5.2.0-3-amd64                        5.2.17-1                                      amd64        Linux 5.2 for 64-bit PCs (signed)
rc  linux-image-5.3.0-2-amd64                        5.3.9-3                                       amd64        Linux 5.3 for 64-bit PCs (signed)
rc  linux-image-5.3.0-3-amd64                        5.3.15-1                                      amd64        Linux 5.3 for 64-bit PCs (signed)
rc  linux-image-5.4.0-1-amd64                        5.4.6-1                                       amd64        Linux 5.4 for 64-bit PCs (signed)
rc  linux-image-5.4.0-2-amd64                        5.4.8-1                                       amd64        Linux 5.4 for 64-bit PCs (signed)
rc  linux-image-5.4.0-3-amd64                        5.4.13-1                                      amd64        Linux 5.4 for 64-bit PCs (signed)
rc  linux-image-5.4.0-4-amd64                        5.4.19-1                                      amd64        Linux 5.4 for 64-bit PCs (signed)
rc  linux-image-5.5.0-2-amd64                        5.5.17-1                                      amd64        Linux 5.5 for 64-bit PCs (signed)
rc  linux-image-5.6.0-1-amd64                        5.6.7-1                                       amd64        Linux 5.6 for 64-bit PCs (signed)
rc  linux-image-5.6.0-2-amd64                        5.6.14-2                                      amd64        Linux 5.6 for 64-bit PCs (signed)
rc  linux-image-5.8.0-1-amd64                        5.8.7-1                                       amd64        Linux 5.8 for 64-bit PCs (signed)
rc  linux-image-5.8.0-2-amd64                        5.8.10-1                                      amd64        Linux 5.8 for 64-bit PCs (signed)
rc  linux-image-5.8.0-3-amd64                        5.8.14-1                                      amd64        Linux 5.8 for 64-bit PCs (signed)
rc  linux-image-5.9.0-1-amd64                        5.9.1-1                                       amd64        Linux 5.9 for 64-bit PCs (signed)
rc  linux-image-5.9.0-2-amd64                        5.9.6-1                                       amd64        Linux 5.9 for 64-bit PCs (signed)
rc  linux-image-5.9.0-4-amd64                        5.9.11-1                                      amd64        Linux 5.9 for 64-bit PCs (signed)
ii  linux-image-amd64                                5.19.11-1                                     amd64        Linux for 64-bit PCs (meta-package)

then get the version of the current kernel version with

[I] ~ ❯❯❯ uname -r
5.19.0-2-amd64 

Now you need to install the old kernels by simply purging there package names with sudo apt purge <package-name> . If there are a lot of packages to uninstall you can use some bash magic with.

sudo apt purge linux-image-5.{2,3,4,5,6,8,9,18}*

be careful that the pattern should not match the current version of the kernel you are running.

After removing old kernels you would be able to free up plenty of space on /boot.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .