Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amshinde/16fd71df3e91a545338bfca9c2c9131b to your computer and use it in GitHub Desktop.
Save amshinde/16fd71df3e91a545338bfca9c2c9131b to your computer and use it in GitHub Desktop.
QEMU Direct Kernel Boot into a disk image
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
VMN=${VMN:=1}
NEMU=~/build-x86_64/x86_64-softmmu/qemu-system-x86_64
sudo $NEMU \
-trace events=/tmp/events \
-bios /mnt/fastdata/NEMU/OVMF.fd \
-kernel ~/linux/arch/x86_64/boot/bzImage -append 'console=hvc0 iommu=false root=/dev/vda3 rw rootfstype=ext4 data=ordered rcupdate.rcu_expedited=1 tsc=reliable no_timer_check reboot=t noapictimer acpi.debug_layer=0xffffffff acpi.debug_level=0x2 loglevel=7' \
-nographic \
-nodefaults \
-L . \
-machine virt,accel=kvm,kernel_irqchip \
-smp sockets=1,cpus=4,cores=2,maxcpus=8 -cpu host \
-m 512 \
-device virtio-blk-pci,drive=image -drive if=none,id=image,file=/mnt/fastdata/NEMU/clear.img,format=raw \
-device sysbus-debugcon,iobase=0x402,chardev=debugcon -chardev file,path=/tmp/debug-log,id=debugcon \
-device virtio-serial-pci,id=virtio-serial0 -device virtconsole,chardev=charconsole0,id=console0 -chardev stdio,id=charconsole0 \
-monitor telnet:127.0.0.1:55555,server,nowait \
-netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22 -device virtio-net-pci,netdev=mynet0,romfile="" \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment