A single block device cannot be mounted, read or written by 2 or more systems simultaneously, so using a USB drive as shared storage is not appropriate for your purpose. You might want to set up a diskless system based on NFS which allows to share the file system on a per-file basis among multiple hosts.
Here's mini howto using prebuilt image of full (but a bit old) Debian desktop found in this site. I'm assuming working on a Debian host, but I believe you can easily adapt it with other distro.
Download the QCOW2 image
debian_wheezy_amd64_desktop.qcow2 from the site above. To extract the image you'll need
apt-get install qemu-img):
# modprobe nbd
# qemu-nbd -c /dev/nbd0 /path/to/debian_wheezy_amd64_desktop.qcow2
# mount /dev/nbd0p1 /mnt -o ro
# mkdir -p /srv/nfsroot/wheezy
# rsync -avP /mnt/ /srv/nfsroot/wheezy/
# umount /mnt
# qemu-nbd -d /dev/nbd0
You need to fix some files in
/etc for the diskless system. First, comment out lines starting with
/srv/nfsroot/wheezy/etc/fstab, which refer harddisk partitions:
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
#UUID=613f176b-eca4-47e6-93a6-32653ca1982e / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
#UUID=24674a13-481b-4ff8-913f-9099661397bd none swap sw 0 0
Second, add the following in
/srv/nfsroot/wheezy/etc/network/interfaces to keep NetworkManager away from
iface eth0 inet dhcp
Set up NFS server on your host:
# apt-get install nfs-kernel-server
# vi /etc/exports
# exportfs -ra
Put the following line in
Now launch QEMU using kernel and initrd images with nfsroot cmdline:
# qemu-system-x86_64 -enable-kvm -m 512 -kernel /srv/nfsroot/wheezy/boot/vmlinuz-3.2.0-4-amd64 -initrd /srv/nfsroot/wheezy/boot/initrd.img-3.2.0-4-amd64 -append "root=/dev/nfs nfsroot=192.168.1.2:/srv/nfsroot/wheezy ip=dhcp rw"
where you need to specify your host's IPv4 address in
nfsroot=. It's accessed from QEMU's internal network via built-in NAT.
Now you got a GUI login screen in the QEMU window, while you can see/modify any files of the system in
/srv/nfsroot/wheezy at the same time. Default system settings like users/passwords are described in README.txt.