I was following the instructions to download an Ubuntu 22.04 image and feed that image into Packer (via packer-plugin-arm-image) to upgrade it from 22.04.2 to 22.04.3, install a few extra packages, and configure it for our production environment.
Normally, Packer downloads the image, resizes/expands the filesystem in the image, and then attaches the filesystem to a chroot to perform setup tasks.
The default btrfs filesystem has been a huge headache.
There doesn’t seem to be any way to expand a btrfs filesystem before it’s mounted.
Mounting it on the system before doesn’t seem to be working
sudo losetup --show -f -P output-arm-image/image
sudo mount /dev/loop3p2 /btr
sudo btrfs filesystem show
Label: 'writable' uuid: b95350b5-5c3a-497c-bb88-85993f53693e
Total devices 1 FS bytes used 1.70GiB
devid 1 size 2.37GiB used 2.12GiB path /dev/loop3p2
sudo btrfs filesystem resize +2G /btr
Resize device id 1 (/dev/loop3p2) from 2.37GiB to 4.37GiB
ERROR: unable to resize '/btr': no enough free space
and attempting to manipulate the filesystem in the chroot seems to be failing.
btrfs filesystem show
zoned: ioctl BLKGETZONESZ failed: Function not implemented
btrfs filesystem resize max /
ERROR: unable to check status of exclusive operation: Function not implemented
.
I’m going to grab a stock ubuntu image and start with something like libretech-raspbian-portability to figure out how to get it to boot on a aml-s905x-cc just to get ext4 compatibility back.
Would you consider changing the default filesystem for your images back to ext4?
Would you consider preparing some kind of documentation of how we’re supposed to work with btrfs to make changes to the image before booting it for the first time?
EXT4 on SBCs is just a bad idea in general. It is significantly slower and less robust on a number of fronts.
The standard tools work fine. The issue you are having is probably with the Linux version on your machine being too old. We recommend using at least 6.1. You also need to make sure you increased the partition size in MBR before resizing. btrfs tools only does the partition, not the partition table.
We will create a demo repo for strapping an image in the future.
I updated my earlier example, and now use truncate --size=+3G ./ubuntu.img instead of sudo dd if=/dev/zero bs=1MiB of=./ubuntu.img conv=notrunc oflag=append count=4200 to grow the size of the image. Appreciate all the guidance!