build: init qemu-based staging setup
I emphasize that it's a quote-on-quote staging setup, not really a proper one yet but hopefully it'll be. TODO: Maybe look into AWS MicroVM as an alternative to QEMU?
This commit is contained in:
parent
4efd9c7c5b
commit
188153fb34
2 changed files with 66 additions and 0 deletions
14
qemu.sh
Executable file
14
qemu.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eux
|
||||
|
||||
img=../qcow2/debian-12-backports-nocloud-amd64-20250210-2019.qcow2
|
||||
qemu-system-x86_64 \
|
||||
-machine type=pc,accel=kvm \
|
||||
-drive if=none,file="$img",id=hd0 \
|
||||
-device virtio-blk,drive=hd0 \
|
||||
-m 2G \
|
||||
-enable-kvm \
|
||||
-cpu max \
|
||||
-device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp:127.0.0.1:5555-:22 \
|
||||
-nographic
|
52
setup_qemu.sh
Executable file
52
setup_qemu.sh
Executable file
|
@ -0,0 +1,52 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Adapted from https://wiki.debian.org/Arm64Qemu
|
||||
# * https://cdimage.debian.org/images/cloud/bookworm-backports/20250210-2019/
|
||||
|
||||
set -eux
|
||||
|
||||
skip="${1:-}"
|
||||
|
||||
url=https://cdimage.debian.org/images/cloud/bookworm-backports/20250210-2019/debian-12-backports-nocloud-amd64-20250210-2019.qcow2
|
||||
img=../qcow2/debian-12-backports-nocloud-amd64-20250210-2019.qcow2
|
||||
|
||||
mkdir -p ./.local
|
||||
|
||||
if [ ! -f "$img" ]; then
|
||||
cd -- ./.local
|
||||
curl -LO -- "$url"
|
||||
cd -- ..
|
||||
fi
|
||||
|
||||
sudo apt install \
|
||||
qemu-utils \
|
||||
qemu-efi \
|
||||
qemu-system-x86
|
||||
|
||||
sudo modprobe nbd
|
||||
sudo qemu-nbd -c /dev/nbd0 "$img"
|
||||
if ! sudo mount /dev/nbd0p1 /mnt; then
|
||||
<<-EOF cat -
|
||||
|
||||
I am unfortunately too lazy to actually understand why this fails
|
||||
sometimes.
|
||||
|
||||
What's even more interesting is that it works if you execute again this
|
||||
exact command outside of the script.
|
||||
|
||||
sudo mount /dev/nbd0p1 /mnt
|
||||
"$0" skip # to resume this script
|
||||
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ssh-add -L >/mnt/home/debian/.ssh/authorized_keys
|
||||
sudo umount /mnt
|
||||
sudo qemu-nbd -d /dev/nbd0
|
||||
|
||||
# qemu-system-aarch64 -m 2G -M virt -cpu max \
|
||||
# -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd \
|
||||
# -drive if=none,file=debian-9.9.0-openstack-arm64.qcow2,id=hd0 -device virtio-blk-device,drive=hd0 \
|
||||
# -device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp:127.0.0.1:5555-:22 \
|
||||
# -nographic
|
Loading…
Reference in a new issue