Project ID: 82217


Firecracker for Fedora 37 x86_64

Installation Instructions

Users only need to install the firecracker package. The other packages in the repository are build dependencies.

To run an example VM, start the API server:

# Install the package. sudo dnf -y copr enable dm0/Firecracker sudo dnf -y install firecracker # Download an example kernel and disk image to /tmp. wget -P /tmp # Run the API server in the foreground. This will be the serial prompt when the VM starts. firecracker --api-sock /tmp/firecracker.socket

Then use the REST API in another terminal to start the VM. The API requests should return HTTP 204 codes.

curl --unix-socket /tmp/firecracker.socket -iX PUT 'http://localhost/boot-source' --json '{"kernel_image_path":"/tmp/vmlinux.bin","boot_args":"console=ttyS0 reboot=k panic=1 pci=off"}' curl --unix-socket /tmp/firecracker.socket -iX PUT 'http://localhost/drives/rootfs' --json '{"drive_id":"rootfs","path_on_host":"/tmp/bionic.rootfs.ext4","is_root_device":true,"is_read_only":false}' curl --unix-socket /tmp/firecracker.socket -iX PUT 'http://localhost/machine-config' --json '{"vcpu_count":2,"mem_size_mib":1024}' # optional curl --unix-socket /tmp/firecracker.socket -iX PUT 'http://localhost/actions' --json '{"action_type":"InstanceStart"}'

Alternatively, a VM can be started directly with a JSON configuration file instead of the API server.

firecracker --no-api --config-file /dev/stdin { "boot-source": { "kernel_image_path": "/tmp/vmlinux.bin", "boot_args": "console=ttyS0 reboot=k panic=1 pci=off" }, "drives": [ { "drive_id": "rootfs", "path_on_host": "/tmp/bionic.rootfs.ext4", "is_root_device": true, "is_read_only": false } ], "machine-config": { "vcpu_count": 2, "mem_size_mib": 1024 } }

Currently the Fedora kernel must be rebuilt with CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y to be usable in Firecracker, and assuming no other configuration changes are made, some additional preparation is necessary. The overall idea is to strip off the kernel's compression layer and load its modules to support VirtIO hardware. After running the following steps, the VM can be started with the previous methods by changing the boot-source JSON keys to have "kernel_image_path": "/tmp/vmlinux.fedora" and "initrd_path": "/tmp/initrd.cpio" (and the rootfs drive should preferably set "is_root_device": false with an initrd).

# Install kernel scripts and BusyBox to build an initrd. sudo dnf -y install busybox kernel-devel # Select the installed Fedora kernel version to use. kerneldir=/lib/modules/$(uname -r) # Extract the bare vmlinux kernel image for Firecracker to start. "$kerneldir/build/scripts/extract-vmlinux" "$kerneldir/vmlinuz" > /tmp/vmlinux.fedora # Write a simple BusyBox initrd that just loads Fedora's VirtIO drivers and switches to the disk image. mkdir -p /tmp/initrd/{bin,dev,lib,proc,sys,sysroot} cp -t /tmp/initrd/bin /usr/sbin/busybox for cmd in ash insmod mount mountpoint reboot sed sleep switch_root ; do ln -fns busybox "/tmp/initrd/bin/$cmd" ; done for mod in failover net_failover virtio_blk virtio_mmio virtio_net ; do xz -cd "$kerneldir"/kernel/*/*/"$mod.ko.xz" > "/tmp/initrd/lib/$mod.ko" ; done cat << 'EOF' > /tmp/initrd/init ; chmod 0755 /tmp/initrd/init #!/bin/ash -ex trap -- 'reboot -f ; exec sleep 10' EXIT mountpoint -q /dev || mount -t devtmpfs devtmpfs /dev mountpoint -q /proc || mount -t proc proc /proc mountpoint -q /sys || mount -t sysfs sysfs /sys for mod in /lib/*.ko ; do insmod "$mod" $(sed -n "s/.* ${mod:5:-3}\.\([^ ]*\).*/\1/p" /proc/cmdline) ; done #exec ash -l # Use this for interactive initrd debugging. mount /dev/vda /sysroot exec switch_root /sysroot /bin/bash -l EOF find /tmp/initrd -mindepth 1 -printf '%P\n' | cpio -D /tmp/initrd -H newc -R 0:0 -o > /tmp/initrd.cpio

Active Releases

The following unofficial repositories are provided as-is by owner of this project. Contact the owner directly for bugs or issues (IE: not bugzilla).

Release Architectures Repo Download
Fedora 37 i386 (12)*, x86_64 (358)* Fedora 37 multilib x86_64+i386 (13 downloads)

* Total number of packages downloaded in the last seven days.

External Repository List

The following repositories are accessible during builds