Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save parrotmac/6eb0e01099e1b6bfb8598054cd456180 to your computer and use it in GitHub Desktop.
Save parrotmac/6eb0e01099e1b6bfb8598054cd456180 to your computer and use it in GitHub Desktop.
Build Linux Kernel (v5.10) for use in a Firecracker VM
#!/usr/bin/env bash
# Note that this doesn't work on Ubuntu 22.04, but works on 20.04. This seem to be due to the newer kernel used by default on newer Ubuntu versions (YMMV)
set -euo pipefail
# Install system deps
apt-get update && apt-get upgrade -y && sudo apt-get install \
bison \
build-essential \
flex \
git \
libelf-dev \
libncurses5-dev \
libssl-dev -y
# Shallow clone of specific branch we're targeting
git clone --branch v5.10 --depth=1 https://github.com/torvalds/linux.git
# Download hosted config for v5.10
curl -fsSL -o 5-10-config https://raw.githubusercontent.com/firecracker-microvm/firecracker/main/resources/guest_configs/microvm-kernel-x86_64-5.10.config
cp 5-10-config linux/.config
(cd linux && make olddefconfig) # Accept defaults for any new options
(cd linux && make vmlinux -j32) # Build using 32 threads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment