19

Getting the following error when trying to upgrade to 22.04

The upgrade has aborted. The upgrade needs a total of 616 M free space on disk '/boot'. Please free at least an additional 144 M of disk space on '/boot'. You can remove old kernels using 'sudo apt autoremove' and you could also set COMPRESS=xz in /etc/initramfs-tools/initramfs.conf to reduce the size of your initramfs.

I have done all the usual suspects removing old kernels, etc., but that amount of space takes up nearly all of the Ubuntu default boot drive space so no amount of freeing space is going to let that go through.

The giant increase in size requirements leads me to believe this is some form of error. Short of decrypting and re-sizing partitions is there anything I can try here?

1

5 Answers 5

35

This is a known issue caused by using a different compression method for the initramfs. The new default, lz4 compression, is faster to decompress/read at boot time, but takes a lot of space in /boot to create. This means people with smaller /boot partitions won't have enough space to generate the initramfs.

The workaround is to change the compression algorithm to xz as recommended (or some other algorithm that takes less space).

To do this, edit /etc/initramfs-tools/initramfs.conf and set COMPRESS=xz, as stated in the error message. Afterward, you should be able to upgrade.

8
  • Thanks for the response, the bug report helped me get to the right answer. The COMPRESS=xz setting did not reduce the size enough to allow the update but in the bug report someone mentioned using COMPRESS=lzma and that did it. I had initially tried the xz and lzma setting and saw it do nothing but that was because I was also missing the piece of needing to use update-initramfs afterwards.
    – Seth Brown
    Sep 14, 2022 at 14:00
  • 4
    Another possible workaround, but partially dangerous, is to change MODULES=most to MODULES=dep. This will shrink the initramfs significantly, because it only contains the modules needed to mount the root partition, but the downside is that the system will no longer boot if the system configuration changes too much -- basically, in the same circumstances Windows won't boot, since they too build an archive containing the drivers needed to mount the system disk that is loaded by the bootloader before the kernel takes over from the BIOS. Sep 15, 2022 at 15:09
  • 1
    How much are we putting in initramfs these days? My initramfs is 15MB; OP seems to need an additional 144MB?
    – Joshua
    Sep 15, 2022 at 15:12
  • @Joshua are you running 22.04?
    – Esther
    Sep 15, 2022 at 15:15
  • 1
    I am not; however I don't believe that any system needs 144MB of initrd unless it's loading the entire system image via initrd because it's boot external media and remove the media after.
    – Joshua
    Sep 15, 2022 at 15:18
22

I was ultimately able to resolve this with a compression tip from the bug report that Esther linked here.

The error states that the initramfs.conf must be changed to COMPRESS=xz. However, simply changing the config has no effect. The images need to be rebuilt after with the following command:

sudo update-initramfs -u -k all

Changing to COMPRESS=xz has a minimal effect however and not enough to allow install on a default-sized boot partition. Setting COMPRESS=lzma and rebuilding the images did allow the install to continue.

Also worth noting that the error message says to run the command "sudo apt autoremove" but this will likewise not free up boot space on its own. Excess kernels must generally be removed like so.

2
  • 2
    Thanks for pointing out the typo, I have edited the answer. When I made a change from the default lz4 to xz it did reduce the amount of space required to 580mb or so, but not nearly enough to get the update through. Once I switched to lzma this was effective.
    – Seth Brown
    Sep 14, 2022 at 13:59
  • 4
    xz uses the LZMA algorithm; presumably the lzma compression program just had a different default compression level. I assume you could have gotten the same result with COMPRESS=xz and a compression-level setting, however that's done in Ubuntu's scripts. (Perhaps COMPRESS='xz -9' for very slow max compression, if the script lets you include args as part of the command.) Not that that would be better; just that xz is a more widely used file format (metadata) for the same compression stream. If lzma works on your system, use it. Sep 15, 2022 at 0:43
1

Another option, if putting /boot on the root partition is no option: You can (temporarily or permanently) put it on a usb stick.

  • Copy all files onto the stick (make sure to keep permission, e.g., by using rsync -a)
  • umount the stick, mount it at /boot
  • reinstall grub (update-grub and grub-install)
  • Boot from the usb stick

Best if you still have the old /boot around for a first test before doing it for real.

0

To avoid this you can put /boot on the same partition. export a user to another /home directory after the fact.

4
  • 1
    Please explain how you put /boot on the root partition, it looks like it's not easy to do.
    – A.L
    Sep 15, 2022 at 13:46
  • 3
    He can't put /boot on /; he has an encrypted /.
    – Joshua
    Sep 15, 2022 at 15:15
  • That is correct, root is encrypted which is why it has the separate boot partition. Next time I upgrade the main drive I'll likely allocate a 4-5 gig boot partition to spare similar situations.
    – Seth Brown
    Sep 15, 2022 at 16:27
  • /boot is not [boot]
    – TardisGuy
    Nov 19, 2022 at 1:12
0

For anyone looking for an idea of what the Ubuntu 22.04 /boot partition size should be, I've set mine to 1G and on a fresh install currently 127M used.

The 22.04 installer seems to want to use a percentage of the whole disk for /boot. On 12G it was trying to use 1.75G which seems excessive.

Hopefully 1G will be enough, though it hasn't done a kernel update yet, though an apt update did do this okay:

Processing triggers for initramfs-tools (0.140ubuntu13) ...
update-initramfs: Generating /boot/initrd.img-5.15.0-53-generic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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