|
1 | 1 | # Creating Custom rootfs and kernel Images |
2 | 2 |
|
3 | | -## Creating a kernel Image |
| 3 | +## Creating a Linux kernel Image |
4 | 4 |
|
5 | 5 | ### Manual compilation |
6 | 6 |
|
@@ -79,7 +79,7 @@ but without ACPI support) and `6.1`. |
79 | 79 | After the command finishes, the kernels along with the corresponding KConfig |
80 | 80 | used will be stored under `resources/$(uname -m)`. |
81 | 81 |
|
82 | | -## Creating a rootfs Image |
| 82 | +## Creating a Linux rootfs Image |
83 | 83 |
|
84 | 84 | A rootfs image is just a file system image, that hosts at least an init system. |
85 | 85 | For instance, our getting started guide uses an ext4 filesystem image. Note |
@@ -185,3 +185,44 @@ adjust the script(s) to suit your use case. |
185 | 185 |
|
186 | 186 | You should now have a rootfs image (`ubuntu-22.04.ext4`), that you can boot with |
187 | 187 | Firecracker. |
| 188 | + |
| 189 | +## Creating FreeBSD rootfs and kernel Images |
| 190 | + |
| 191 | +Here's a quick step-by-step guide to building a FreeBSD rootfs and kernel that |
| 192 | +Firecracker can boot: |
| 193 | + |
| 194 | +1. Boot a FreeBSD system. In EC2, the |
| 195 | + [FreeBSD 13 Marketplace image](https://aws.amazon.com/marketplace/pp/prodview-ukzmy5dzc6nbq) |
| 196 | + is a good option; you can also use weekly snapshot AMIs published by the |
| 197 | + FreeBSD project. (Firecracker support is in FreeBSD 14 and later, so you'll |
| 198 | + need FreeBSD 13 or later to build it.) |
| 199 | + |
| 200 | + The build will require about 50 GB of disk space, so size the disk |
| 201 | + appropriately. |
| 202 | + |
| 203 | +1. Log in to the FreeBSD system and become root. If using EC2, you'll want to |
| 204 | + ssh in as `ec2-user` with your chosen SSH key and then `su` to become root. |
| 205 | + |
| 206 | +1. Install git and check out the FreeBSD src tree: |
| 207 | + |
| 208 | + ```sh |
| 209 | + pkg install -y git |
| 210 | + git clone https://git.freebsd.org/src.git /usr/src |
| 211 | + ``` |
| 212 | + |
| 213 | + Firecracker support is available since FreeBSD 14.0 (released November 2023). |
| 214 | + |
| 215 | +1. Build FreeBSD: |
| 216 | + |
| 217 | + ```sh |
| 218 | + make -C /usr/src buildworld buildkernel KERNCONF=FIRECRACKER |
| 219 | + make -C /usr/src/release firecracker DESTDIR=`pwd` |
| 220 | + ``` |
| 221 | + |
| 222 | +You should now have a rootfs `freebsd-rootfs.bin` and a kernel |
| 223 | +`freebsd-kern.bin` in the current directory (or elsewhere if you change the |
| 224 | +`DESTDIR` value) that you can boot with Firecracker. Note that the FreeBSD |
| 225 | +rootfs generated in this manner is somewhat minimized compared to "stock" |
| 226 | +FreeBSD; it omits utilities which are only relevant on physical systems (e.g., |
| 227 | +utilities related to floppy disks, USB devices, and some network interfaces) and |
| 228 | +also debug files and the system compiler. |
0 commit comments