Streamline VM overlays and rootfs packages
Move the default guest package list into a repo manifest and record a hash beside built rootfs images so run/make-rootfs can warn when the docker-ready image is stale. Switch the Firecracker launch path to a single sparse root overlay per VM instead of separate /home and /var disks, so many VMs can share the same base image while still installing packages under /var and working from /root. Keep older images bootable by masking stale home.mount and var.mount units at boot, and scrub those obsolete fstab entries when customize.sh rebuilds an image. Verified with bash -n on the updated scripts; no live VM boot was run in this environment.
This commit is contained in:
parent
9191b7e370
commit
3cf33d1e0a
8 changed files with 206 additions and 204 deletions
28
restore.sh
28
restore.sh
|
|
@ -76,8 +76,6 @@ VM_NAME="$(jq -r '.meta.name // empty' "$VM_JSON")"
|
|||
PID="$(jq -r '.meta.pid // empty' "$VM_JSON")"
|
||||
ROOTFS="$(jq -r '.meta.rootfs // empty' "$VM_JSON")"
|
||||
KERNEL="$(jq -r '.meta.kernel // empty' "$VM_JSON")"
|
||||
HOME_PATH="$(jq -r '.meta.home_path // empty' "$VM_JSON")"
|
||||
VAR_PATH="$(jq -r '.meta.var_path // empty' "$VM_JSON")"
|
||||
TAP_DEV="$(jq -r '.meta.tap // empty' "$VM_JSON")"
|
||||
API_SOCK="$(jq -r '.meta.api_sock // empty' "$VM_JSON")"
|
||||
LOG_FILE="$(jq -r '.meta.log // empty' "$VM_JSON")"
|
||||
|
|
@ -90,11 +88,11 @@ COW_LOOP_OLD="$(jq -r '.meta.cow_loop // empty' "$VM_JSON")"
|
|||
INITRD_PATH="$(jq -r '.config["boot-source"].initrd_path // empty' "$VM_JSON")"
|
||||
DNS_NAME="$(banger_dns_name "$VM_NAME")"
|
||||
|
||||
if [[ -z "$ROOTFS" || -z "$KERNEL" || -z "$HOME_PATH" || -z "$VAR_PATH" || -z "$API_SOCK" || -z "$TAP_DEV" || -z "$GUEST_IP" || -z "$DM_NAME" || -z "$COW_FILE" ]]; then
|
||||
if [[ -z "$ROOTFS" || -z "$KERNEL" || -z "$API_SOCK" || -z "$TAP_DEV" || -z "$GUEST_IP" || -z "$DM_NAME" || -z "$COW_FILE" ]]; then
|
||||
log "vm.json missing required fields"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "$ROOTFS" || ! -f "$KERNEL" || ! -f "$HOME_PATH" || ! -f "$VAR_PATH" || ! -f "$COW_FILE" || ! -f "$FC_BIN" ]]; then
|
||||
if [[ ! -f "$ROOTFS" || ! -f "$KERNEL" || ! -f "$COW_FILE" || ! -f "$FC_BIN" ]]; then
|
||||
log "missing disk/kernel file(s)"
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -203,9 +201,9 @@ log "configuring machine"
|
|||
-d "$(jq -c '.config["machine-config"]' "$VM_JSON")" >/dev/null
|
||||
|
||||
boot_args="$(jq -r '.config["boot-source"].boot_args // empty' "$VM_JSON")"
|
||||
boot_args="$(printf '%s' "$boot_args" | sed -E 's/(^| )hostname=[^ ]+//g; s/(^| )ip=[^ ]+//g' | awk '{$1=$1; print}')"
|
||||
boot_args="$(printf '%s' "$boot_args" | sed -E 's/(^| )hostname=[^ ]+//g; s/(^| )ip=[^ ]+//g; s/(^| )systemd\.mask=home\.mount//g; s/(^| )systemd\.mask=var\.mount//g' | awk '{$1=$1; print}')"
|
||||
boot_args="$boot_args ip=${GUEST_IP}::${BR_IP}:255.255.255.0::eth0:off:${DNS_SERVER}"
|
||||
boot_args="$boot_args hostname=$VM_NAME"
|
||||
boot_args="$boot_args hostname=$VM_NAME systemd.mask=home.mount systemd.mask=var.mount"
|
||||
INITRD_JSON=""
|
||||
if [[ -n "$INITRD_PATH" ]]; then
|
||||
INITRD_JSON=", \"initrd_path\": \"$INITRD_PATH\""
|
||||
|
|
@ -229,24 +227,6 @@ log "attaching drives"
|
|||
\"is_read_only\": false
|
||||
}" >/dev/null
|
||||
|
||||
/usr/bin/sudo /usr/bin/curl --unix-socket "$API_SOCK" -X PUT http://localhost/drives/home \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"drive_id\": \"home\",
|
||||
\"path_on_host\": \"$HOME_PATH\",
|
||||
\"is_root_device\": false,
|
||||
\"is_read_only\": false
|
||||
}" >/dev/null
|
||||
|
||||
/usr/bin/sudo /usr/bin/curl --unix-socket "$API_SOCK" -X PUT http://localhost/drives/var \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"drive_id\": \"var\",
|
||||
\"path_on_host\": \"$VAR_PATH\",
|
||||
\"is_root_device\": false,
|
||||
\"is_read_only\": false
|
||||
}" >/dev/null
|
||||
|
||||
log "configuring network interface"
|
||||
/usr/bin/sudo /usr/bin/curl --unix-socket "$API_SOCK" -X PUT http://localhost/network-interfaces/eth0 \
|
||||
-H "Content-Type: application/json" \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue