No space left on device when upgrading kernel

I’m trying to upgrade the kernel snap on a UC 18 image running on an RPI4, but it’s failing due to lack of disk space in the /boot partition:

$ sudo snap list | grep pi-kernel
pi-kernel                 5.3.0-1021.23~18.04.1  117   18-pi/stable   canonical*    kernel
$ sudo snap refresh pi-kernel
error: cannot perform the following tasks:
- Mount snap "pi-kernel" (119) (cannot install kernel: cannot extract "kernel.img" to "/boot/uboot/pi-kernel_119.snap": failed: "Write on output file failed because No space left on device", "writer: failed to write data block 166", and "Failed to write /boot/uboot/pi-kernel_119.snap/kernel.img, skipping")

Disk usage is as follows:

$ sudo df -h | grep -E "/boot|/writable"
/dev/mmcblk0p2   30G  1.2G   27G   5% /writable
/dev/mmcblk0p1  127M  106M   21M  84% /boot/uboot

The image was built with: ubuntu-image snap --image-size 1536M ...

My questions are:

  1. Is there any way to recover from this?
  2. Should I consider increasing the size of the /boot partition as part of the image, and if so, how?

Thanks,
Jesse

Hi, sorry you are encountering this bug with UC18. I assume you are using arm64 for your image, and if you are, then the fix for this is to rebuild your image with an updated gadget snap that increases the size of the system-boot partition, as was done here: https://github.com/snapcore/pi-gadget/commit/32c285ba57ba4a80a78d3ade57543ab183ac72df. Unfortunately you cannot update the partition size of an already flashed image, so you will need to reflash, but if you need to immediately fix the device you can delete old revisions of the kernel snap with snap remove pi-kernel --revision=$OLD where $OLD is an old revision of the snap that is not currently installed.

Awesome, thanks for the details.