Created
September 24, 2021 15:54
-
-
Save teknoraver/80082ad7bac1a5e878808dc743e5e272 to your computer and use it in GitHub Desktop.
Install Debian via a serial console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
[ $# -eq 2 ] || exec echo "Usage: $0 <install.iso> <disk.img>" | |
for k in qemu kvm qemu-kvm; do | |
which $k 2>/dev/null >/dev/null && kvm=$k && break | |
done | |
[ -n "$kvm" ] || exec echo "error: KVM not found!" | |
cores=$(nproc) | |
[ $cores -gt 4 ] && cpus="-smp cpus=$((cores / 2))" | |
root=/tmp/${0##*/}.$$ | |
mkdir $root | |
sudo mount -r -oloop "$1" $root | |
$kvm -machine q35,accel=kvm -m 512 -no-reboot -nographic $cpus \ | |
-boot d -cdrom "$1" \ | |
-drive "file=$2,media=disk,format=raw,if=virtio" \ | |
-netdev user,id=hostnet0 \ | |
-device virtio-net-pci,netdev=hostnet0 \ | |
-kernel $root/install.*/vmlinuz -initrd $root/install.*/initrd.gz -append console=ttyS0 | |
sudo umount $root | |
rmdir $root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment