화요일, 5월 20, 2014

QEMU Shared Directory on GNU/Linux (공유 디렉토리 만들기)

QEMU Shared Directory on GNU/Linux

How to make a shared directory for QEMU on GNU/Linux ?
It's pretty easy...

* I suppose you using QEMU on GNU/Linux already.
* You can also find shared directory option '3.6.7 Virtual FAT disk images' at QEMU WiKi.
 - http://wiki.qemu.org/download/qemu-doc.html#disk_005fimages_005ffat_005fimages
 - http://en.wikibooks.org/wiki/QEMU/Devices/Storage



[SETP #1]
// Host
//
// Option: -hdb fat:rw:/mnt/qemu_shared_dir/
//
// Device: 'hdb'
// File System: 'fat'
// Permission: 'rw'
// Path: '/mnt/qemu_shared_dir'
user@host:/$ qemu-xxx <...YOUR OPTIONS...> -hdb fat:rw:/mnt/qemu_shared_dir/


[SETP #2]
// QEMU Guest
root@qemuxxx:/# mount
...
/dev/sdb1 on /media/sdb1 type vfat (rw,relatime,gid=6,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
...
root@qemuxxx:/# cd /media/sdb1
root@qemuxxx:/media/sdb1# echo 'test' > test

//! IMPORTANT
root@qemuxxx:/media/sdb1# sync


[SETP #3]
// Host
user@host:/mnt/qemu_shared_dir$ ls -al


[===NOTE===]
 - If you create/modify a file or directory, you MUST do 'sync'.
 -
 - WARNING: keep in mind that QEMU makes the virtual FAT table once, when adding the device, and then doesn't update it in response to changes to the specified directory made by the host system. If you modify the directory while the VM is running, QEMU might get confused.
 -
What you should never do:
 - use non-ASCII filenames ;
 - use "-snapshot" together with ":rw:" ;
 - expect it to work when loadvm’ing ;
 - write to the FAT directory on the host system while accessing it with the guest system.


that's it!


-----
Cheers,
June