docker rootfs defaults

This commit is contained in:
Thales Maciel 2026-02-05 02:13:14 -03:00
parent 5f3d60ef0f
commit 93c3d1a67b
6498 changed files with 64929 additions and 14 deletions

28
run.sh
View file

@ -15,6 +15,7 @@ Options:
--ram <mib> RAM in MiB (default: 1024)
--rootfs <path> Root filesystem image (default: ./rootfs.ext4)
--kernel <path> Kernel image (default: ./vmlinux)
--initrd <path> Initrd image (optional)
--home-size <size> Home disk size (e.g. 4G, 10240M)
--var-size <size> Var disk size (e.g. 4G, 10240M)
-h, --help Show this help
@ -29,8 +30,9 @@ VM_ROOT="$STATE/vms"
mkdir -p "$VM_ROOT"
FC_BIN="$DIR/firecracker"
DEFAULT_KERNEL="$DIR/vmlinux"
DEFAULT_ROOTFS="$DIR/rootfs.ext4"
DEFAULT_KERNEL="$DIR/wtf/root/boot/vmlinux-6.8.0-94-generic"
DEFAULT_ROOTFS="$DIR/rootfs-docker.ext4"
DEFAULT_INITRD="$DIR/wtf/root/boot/initrd.img-6.8.0-94-generic"
SSH_KEY="$DIR/id_ed25519"
NAMEGEN="$DIR/namegen"
@ -56,6 +58,7 @@ HOME_SIZE="$DEFAULT_HOME_SIZE"
VAR_SIZE="$DEFAULT_VAR_SIZE"
KERNEL="$DEFAULT_KERNEL"
ROOTFS="$DEFAULT_ROOTFS"
INITRD="$DEFAULT_INITRD"
VM_NAME=""
shopt -s nullglob
@ -109,6 +112,10 @@ while [[ $# -gt 0 ]]; do
KERNEL="${2:-}"
shift 2
;;
--initrd)
INITRD="${2:-}"
shift 2
;;
--home-size)
HOME_SIZE="${2:-}"
shift 2
@ -189,6 +196,12 @@ if ! [[ "$VM_NAME" =~ ^[a-z0-9][a-z0-9-]{0,63}$ ]]; then
log "invalid --name value: $VM_NAME"
exit 1
fi
if [[ ! -f "$ROOTFS" ]]; then
if [[ "$ROOTFS" == "$DEFAULT_ROOTFS" && -x "$DIR/make-rootfs.sh" ]]; then
log "rootfs missing; building via make-rootfs.sh"
"$DIR/make-rootfs.sh"
fi
fi
if [[ ! -f "$ROOTFS" ]]; then
log "rootfs not found: $ROOTFS"
exit 1
@ -197,6 +210,10 @@ if [[ ! -f "$KERNEL" ]]; then
log "kernel not found: $KERNEL"
exit 1
fi
if [[ -n "$INITRD" && ! -f "$INITRD" ]]; then
log "initrd not found: $INITRD"
exit 1
fi
if name_taken "$VM_NAME"; then
log "name already in use: $VM_NAME"
exit 1
@ -418,11 +435,16 @@ log "configuring machine"
log "configuring boot source"
KCMD="console=ttyS0 reboot=k panic=1 pci=off root=/dev/vda rw ip=${GUEST_IP}::${BR_IP}:255.255.255.0::eth0:off:${DNS_SERVER} hostname=${VM_NAME}"
INITRD_JSON=""
if [[ -n "$INITRD" ]]; then
INITRD_JSON=", \"initrd_path\": \"$INITRD\""
fi
"${CURL_CMD[@]}" --unix-socket "$API_SOCK" -X PUT http://localhost/boot-source \
-H "Content-Type: application/json" \
-d "{
\"kernel_image_path\": \"$KERNEL\",
\"boot_args\": \"$KCMD\"
\"boot_args\": \"$KCMD\"${INITRD_JSON}
}" >/dev/null
# Root filesystem