feat: added helper scripts

This commit is contained in:
mustard 2025-08-12 01:50:42 +02:00
parent a030082f11
commit e9ab7fc9d9
5 changed files with 49 additions and 0 deletions

7
create.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
rm ./rootfs.qcow2
rm -rf ./rootfs
mkdir ./rootfs
tar -xf ./jammy-server-cloudimg-amd64-root.tar.xz -C ./rootfs
virt-make-fs --format=qcow2 --size=2000M only rootfs.qcow2

15
extract-kernel-initrd.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
qemu-nbd /dev/nbd0 --disconnect
sleep 0.5
umount ./files/mnt
sleep 0.5
rm -rf ./files/mnt && mkdir ./files/mnt
sleep 0.5
rmmod nbd
modprobe nbd max_part=8
qemu-nbd --connect=/dev/nbd0 ./files/jammy-server-cloudimg-amd64-disk-kvm.img && sleep 1 && mount /dev/nbd0p1 ./files/mnt/
cp ./files/mnt/boot/initrd.img-*-kvm ./initrd.img
cp ./files/mnt/boot/vmlinuz-*-kvm ./vmlinuz-kvm

3
init.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
qemu-system-x86_64 -m 4096M -M microvm -enable-kvm -cpu host -kernel vmlinuz-kvm -initrd initrd.img -append 'console=ttyS0 root=/dev/vda rw fsck.mode=skip nomodeset reboot=t init=/usr/sbin/init' -no-reboot -nodefaults -no-user-config -display none -serial mon:stdio -drive file=rootfs.qcow2,index=0,format=qcow2,media=disk,if=none,id=virtio1 -device virtio-blk-device,drive=virtio1 -netdev tap,id=tap0,script=no,downscript=no -device virtio-net-device,netdev=tap0

9
notes.txt Normal file
View file

@ -0,0 +1,9 @@
# Stuff to change:
/etc/shadow for root password
extract kernel, initrd and pass as arguments
edit /etc/fstab to mount /dev/vda
disable snap, multipath services

15
prepare-rootfs.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
tar -xf ./files/jammy-server-cloudimg-amd64-root.tar.xz -C ./files/rootfs
sed -i "1 s,^.*$,root:\$y\$j9T\$4Sr0RCDCWboukd7UCeeWvIyH\$5bE15871.Uyzk77tFoYZqmPqOUosbB0MFWkKGq2/KI2::0:99999:7:::," ./files/rootfs/etc/shadow # password is amogus
echo "/dev/vda / ext4 discard,errors=remount-ro 0 1" > ./files/rootfs/etc/fstab
echo "TimeoutStartSec=1" >> ./files/rootfs/lib/systemd/system/snapd.seeded.service
rm ./files/rootfs/etc/systemd/system/multipath-tools.service
rm ./files/rootfs/lib/systemd/system/multipathd.service
# rm -f ./files/rootfs/etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service
ln -sf ./files/rootfs/dev/null ./files/rootfs/etc/systemd/system/systemd-networkd-wait-online.service
virt-make-fs --format=qcow2 --size=2000M ./files/rootfs rootfs.qcow2