Qemu

From vegard.wiki
Revision as of 06:32, 15 December 2019 by Vegard (talk | contribs) (→‎Boot using host filesystem over 9p: security_model=none)
Jump to navigation Jump to search

Boot using host filesystem over 9p

kvm \
  -cpu host \
  -m 1G \
  -kernel arch/x86/boot/bzImage \
  -append "rootfstype=9p root=/dev/root rootflags=trans=virtio,version=9p2000.L rw console=ttyS0 init=/bin/bash" \
  -serial stdio \
  -fsdev local,id=fsdev0,path=/,security_model=passthrough \
  -device virtio-9p-pci,fsdev=fsdev0,mount_tag=/dev/root \
  -no-reboot \
  -display none

Remember to set the following variables in your kernel config (in order):

  • CONFIG_VIRTIO_PCI=y
  • CONFIG_NET_9P=y
  • CONFIG_NET_9P_VIRTIO=y
  • CONFIG_9P_FS=y

Sometimes it will be useful to use security_model=none rather than passthrough. From the man page: In "passthrough" security model, files are stored using the same credentials as they are created on the guest. This requires QEMU to run as root. [...] "none" security model is same as passthrough except the sever won't report failures if it fails to set file attributes like ownership.