This is a tiny init for MicroVMs. It can set hostname, dns, and run a entrypoint command like docker.
This project is built with Taskfile. But you can also build it manually.
task initramfs
mkdir build
cd firefly
export CGO_ENABLED=0
go build -o ../build/init .
then create initramfs:
mkdir build/initramfs
cp build/init build/initramfs/init
chmod +x build/initramfs/init
find . | cpio -o -H newc > ../initramfs.cpio
FireFly read commandline arguments from /proc/cmdline
:
for example:
root=/dev/vda ip=192.168.10.2/24:192.168.10.1 endpoint=/bin/bash
root
is the root deviceip
is the static ip 192.168.10.2/24 with gateway 192.168.10.1endpoint
is the entrypoint command
- Set hostname
- Set dns
- Set static ip
- Run entrypoint
- Auto mount necessary filesystems such as /dev, /proc, /sys, etc
- Shutdown VM if entrypoint exits
hostname
is the hostnamedns
is the dns serverroot
is the root devicerootfstype
is the root filesystem type, default isext4
ip
is the static ipendpoint
is the entrypoint
Firefly can run a rescue shell if something goes wrong. Such as cannot found root device, entrypoint not found...
You can add shell binary to /bin/sh
, or run task build-busybox
to add busybox to rootfs.
MIT