disk.sh (1989B)
1 #!/usr/bin/env bash 2 # Installs the image onto a fresh disk file, out/disk.raw, the way it would go 3 # onto a real disk: the image runs its own `bootc install to-disk` through a loop 4 # device, onto Btrfs (ADR-0009). The image is the local one vm/build.sh made (with 5 # the test login); the installed system follows the published image, so `make upgrade` in the 6 # VM fetches what `make publish` pushed. Also makes the SSH key, which root's 7 # authorized_keys gets. 8 source "$(dirname "$0")/common.sh" 9 10 vm_running && die "the VM is running; vm/vm.sh stop first" 11 docker image inspect "$IMAGE" >/dev/null 2>&1 || die "no $IMAGE; vm/build.sh first" 12 13 [[ -f "$KEY" ]] || ssh-keygen -q -t ed25519 -N '' -C patina-os-vm -f "$KEY" 14 15 say "installing $IMAGE onto $DISK" 16 rm -f "$DISK" "$OVMF_VARS" 17 truncate -s "$DISK_SIZE" "$DISK" 18 # Privileged with the host's /dev, for the loop device. bootc installs from 19 # podman's storage, normally the host's; there's no podman on the host here, so 20 # the image's own podman loads it, from a file saved here, into a storage folder of its 21 # own first. Nothing comes from the registry. 22 mkdir -p "$OUT/containers" 23 docker save "$IMAGE" -o "$OUT/image.tar" 24 docker run --rm --privileged --network host \ 25 -v /dev:/dev -v "$OUT:/data" -v "$OUT/containers:/var/lib/containers" \ 26 "$IMAGE" bash -euc ' 27 # The console order: tty0 last, since Plymouth shows its splash on the last console and treats 28 # a serial one as no screen. 29 mkdir -p /var/tmp # /var in the image is empty until it boots 30 podman load -q -i /data/image.tar >/dev/null 31 bootc install to-disk \ 32 --via-loopback /data/disk.raw \ 33 --wipe \ 34 --filesystem btrfs \ 35 --root-ssh-authorized-keys /data/id_ed25519.pub \ 36 --source-imgref "containers-storage:$1" \ 37 --target-imgref "$2" \ 38 --karg console=ttyS0,115200 \ 39 --karg console=tty0 40 ' install "$IMAGE" "$VM_IMAGE" 41 rm -f "$OUT/image.tar" 42 43 [[ -f "$DATA" ]] || qemu-img create -q -f qcow2 "$DATA" "$DATA_SIZE" 44 say "done: vm/vm.sh start"