feature/build-my-own-kernel-rootfs #1

Merged
antoine merged 34 commits from feature/build-my-own-kernel-rootfs into main 2024-01-06 13:25:49 +00:00
2 changed files with 14 additions and 13 deletions
Showing only changes of commit 0ce44f6e7b - Show all commits

View File

@ -89,17 +89,18 @@ func setupEnv() int {
cpuCount := int64(4)
memorySize := int64(1024)
isSmt := true
socketPath := "/tmp/firecracker.socket"
cfg := firecracker.Config{
SocketPath: "/tmp/firecracker.socket",
KernelImagePath: "./vmlinux-5.10.204",
LogPath: "./firecracker.log",
SocketPath: socketPath,
KernelImagePath: "./out/vmlinux-5.10.204",
LogPath: "./out/firecracker.log",
LogLevel: "Debug",
KernelArgs: "console=ttyS0 reboot=k panic=1 pci=off",
Drives: []models.Drive{
{
DriveID: firecracker.String("rootfs"),
PathOnHost: firecracker.String("./ubuntu-22.04.ext4"),
PathOnHost: firecracker.String("./out/ubuntu-22.04.ext4"),
IsReadOnly: firecracker.Bool(false),
IsRootDevice: firecracker.Bool(true),
},
@ -130,7 +131,7 @@ func setupEnv() int {
firecracker.WithProcessRunner(
firecracker.VMCommandBuilder{}.
WithBin("firecracker").
WithSocketPath("/tmp/firecracker.socket").
WithSocketPath(socketPath).
//WithStdin(os.Stdin).
//WithStdout(os.Stdout).
//WithStderr(os.Stderr).

View File

@ -2,14 +2,14 @@
# inspired by https://github.com/oraoto/archlinux-firecracker/blob/master/scripts/build-arch-rootfs.sh
DISK_SIZE=4G
DISK_FILE=../output/arch-rootfs.ext4
DISK_ROOT=../output/mount
DISK_SIZE=10G
DISK_FILE=../out/arch-rootfs.ext4
DISK_ROOT=../out/mount
cd $(dirname "${BASH_SOURCE[0]}")
# Allocate rootfs disk
fallocate -l 4G $DISK_FILE
dd if=/dev/zero of="$DISK_FILE" bs=1M count="$DISK_SIZE"
mkfs.ext4 $DISK_FILE
# Mount rootfs to mount
@ -17,13 +17,13 @@ mkdir -p $DISK_ROOT
sudo mount $DISK_FILE $DISK_ROOT
yes y | sudo pacstrap -i -c $DISK_ROOT bash filesystem systemd-sysvcompat pacman iproute2
yes y | sudo pacstrap -i -c $DISK_ROOT bash filesystem systemd-sysvcompat pacman iproute2 git
echo "nameserver 1.1.1.1" | sudo tee $DISK_ROOT/etc/resolv.conf
sudo tee $DISK_ROOT/etc/systemd/system/firecracker-network.service <<-'EOF'
sudo tee $DISK_ROOT/etc/systemd/system/internal-network.service <<-'EOF'
[Unit]
Description=Firecracker Network
Description=Internal Network
[Service]
Type=oneshot
@ -36,7 +36,7 @@ RemainAfterExit=yes
WantedBy=multi-user.target
EOF
sudo ln -s /etc/systemd/system/firecracker-network.service $DISK_ROOT/etc/systemd/system/multi-user.target.wants/
sudo ln -s /etc/systemd/system/internal-network.service $DISK_ROOT/etc/systemd/system/multi-user.target.wants/
# Remove default (locked) root password
# See https://github.com/archlinux/svntogit-packages/commit/0320c909f3867d47576083e853543bab1705185b