Skip to content

Instantly share code, notes, and snippets.

@mcastelino
Created September 20, 2018 18:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mcastelino/299dd9ca2bd9349abdcb33c8da894224 to your computer and use it in GitHub Desktop.
Save mcastelino/299dd9ca2bd9349abdcb33c8da894224 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