5

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
  • 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 '17 at 15:20
  • I tried removing old kernels but got same output. – Sourav Das Jun 27 '17 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 '17 at 16:03
  • Please let me know what additional details you require. – Sourav Das Jun 27 '17 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 '17 at 16:22
9

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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