QEMU Cookbook

Share memory

  1. Prepare the Host System:

    You need to ensure the 9p kernel module is loaded:

    sudo modprobe 9pnet_virtio
  1. Start the Arch Linux Live ISO with QEMU:

    Use this command to start the Arch Linux live ISO while sharing a directory:

    qemu-system-x86_64 \
    -enable-kvm \
    -m 2G \
    -cdrom /path/to/archlinux.iso \
    -fsdev local,id=fsdev0,path=/path/to/host/directory,security_model=none \
    -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare
    
    

    Here:

    • Replace /path/to/archlinux.iso with the path to the Arch Linux ISO on your host system.
    • Replace /path/to/host/directory with the path to the directory on your host system that you want to share with the guest.
  1. Mount the Shared Directory in the Arch Live Environment:

    Once the Arch Linux live environment boots up:

    1. Ensure the 9p kernel module is loaded inside the live environment:
      sudo modprobe 9pnet_virtio
    1. Create a mount point:
      sudo mkdir /mnt/hostshare
    1. Mount the shared directory:
      sudo mount -t 9p -o trans=virtio,version=9p2000.L hostshare /mnt/hostshare