Build a rootfs ext4 image from distroless image for firecracker

676 Views Asked by At

I need to use a debian based distro with firecracker, and I attempt to do something similar to what firecracker docs gave: here.

I attempted to run this distroless image gcr.io/distroless/base-debian10 and install systemd and copy over the files to the mounted rootfs like so:

for d in bin etc lib root sbin usr; do tar c "/$d" | tar x -C /my-rootfs; done
for dir in dev proc run sys var; do mkdir /my-rootfs/${dir}; done

Then changed the API call to add the boot arg init=/bin/systemd

curl --unix-socket /tmp/firecracker.socket -i \
      -X PUT 'http://localhost/boot-source'   \
      -H 'Accept: application/json'           \
      -H 'Content-Type: application/json'     \
      -d "{
            \"kernel_image_path\": \"hello-vmlinux.bin\",
            \"boot_args\": \"init=/bin/systemd reboot=k panic=1 pci=off\"
       }"

But I get no output when I start the vm and it just closes immediately.

How do I create bootable ext4 images using the minimal debian distroless images?

1

There are 1 best solutions below

0
On

I believe the image you are using does not have systemd daemon. If that was the case, Firecracker will try to start systemd daemon at the startup (respecting init=/bin/systemd kernel option) and fail as there is no such file in the filesystem. You can simply check whether /bin/systemd is available in your filesystem.