Skip to content

Instantly share code, notes, and snippets.

@codehz
Created May 8, 2020 01:40
Show Gist options
  • Save codehz/980c417f26e28cce027d77dbd14edadb to your computer and use it in GitHub Desktop.
Save codehz/980c417f26e28cce027d77dbd14edadb to your computer and use it in GitHub Desktop.
Run qemu with 9p rootfs
#!/bin/bash
set -euxo pipefail
kernel="${kernel:-kernel}"
initrd="${initrd:-initramfs.cpio.gz}"
target="$1"
shift
nsroot -xpf -- qemu-system-x86_64 \
-enable-kvm \
-m 1G \
-smp 2 \
-cpu host \
-kernel $kernel \
-initrd $initrd \
-fsdev local,id=fsdev0,path=$target,security_model=passthrough \
-device virtio-9p-pci,fsdev=fsdev0,mount_tag=root \
-device virtio-rng-pci \
-net nic,model=virtio-net-pci -net user \
-append "quiet" \
"$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment