Skip to content

Commit 5451532

Browse files
committed
Add FreeBSD kernel+rootfs build instructions
While I'm here, clarify that the existing instructions are for building a Linux kernel and rootfs. Signed-off-by: Colin Percival <cperciva@freebsd.org>
1 parent a31e862 commit 5451532

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

docs/rootfs-and-kernel-setup.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Creating Custom rootfs and kernel Images
22

3-
## Creating a kernel Image
3+
## Creating a Linux kernel Image
44

55
### Manual compilation
66

@@ -72,7 +72,7 @@ config="resources/guest_configs/microvm-kernel-arm64-4.14.config"
7272

7373
on an aarch64 machine.
7474

75-
## Creating a rootfs Image
75+
## Creating a Linux rootfs Image
7676

7777
A rootfs image is just a file system image, that hosts at least an init system.
7878
For instance, our getting started guide uses an ext4 filesystem image. Note
@@ -178,3 +178,45 @@ adjust the script(s) to suit your use case.
178178

179179
You should now have a kernel image (`vmlinux`) and a rootfs image
180180
(`rootfs.ext4`), that you can boot with Firecracker.
181+
182+
## Creating FreeBSD rootfs and kernel Images
183+
184+
Here's a quick step-by-step guide to building a FreeBSD rootfs and kernel that
185+
Firecracker can boot:
186+
187+
1. Boot a FreeBSD system. In EC2, the
188+
[FreeBSD 13 Marketplace image](https://aws.amazon.com/marketplace/pp/prodview-ukzmy5dzc6nbq)
189+
is a good option; you can also use weekly snapshot AMIs published by the
190+
FreeBSD project. (Firecracker support is in FreeBSD 14 and later, so you'll
191+
need FreeBSD 13 or later to build it.)
192+
193+
The build will require about 50 GB of disk space, so size the disk
194+
appropriately.
195+
196+
1. Log in to the FreeBSD system and become root. If using EC2, you'll want to
197+
ssh in as `ec2-user` with your chosen SSH key and then `su` to become root.
198+
199+
1. Install git and check out the FreeBSD src tree:
200+
201+
```sh
202+
pkg install -y git
203+
git clone https://git.freebsd.org/src.git /usr/src
204+
```
205+
206+
At present (July 2023) Firecracker support is only present in the `main`
207+
branch.
208+
209+
1. Build FreeBSD:
210+
211+
```sh
212+
make -C /usr/src buildworld buildkernel KERNCONF=FIRECRACKER
213+
make -C /usr/src/release firecracker DESTDIR=`pwd`
214+
```
215+
216+
You should now have a rootfs `freebsd-rootfs.bin` and a kernel `freebsd-kern.bin`
217+
in the current directory (or elsewhere if you change the `DESTDIR` value) that
218+
you can boot with Firecracker. Note that the FreeBSD rootfs generated in this
219+
manner is somewhat minimized compared to "stock" FreeBSD; it omits utilities
220+
which are only relevant on physical systems (e.g., utilities related to floppy
221+
disks, USB devices, and some network interfaces) and also debug files and the
222+
system compiler.

0 commit comments

Comments
 (0)