Storage devices can be added using -drive
parameter,
or with the drive_add
command in the QEMU monitor.
Media type
editSeveral drive types can be emulated. This can be specified through the media
modifier.
If not specified, it defaults to disk
.
Valid types are:
disk
cdrom
Example:
qemu -drive file=install-disc-1.iso,media=cdrom ...
Virtual FAT filesystem (VVFAT)
editQemu can emulate a virtual drive with a FAT filesystem. It is an easy way to share files between the guest and host.
It works by prepending fat:
to a directory name.
By default it's read-only, if you need to make it writable append rw:
to the aforementioned prefix.
Example:
qemu -drive file=fat:rw:some/directory ...
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.
Cache policies
editQEMU can cache access to the disk image files, and it provides several methods to do so. This can be specified using the cache
modifier.
Policy | Description |
---|---|
unsafe |
Like writeback , but without performing an fsync .
|
writethrough |
Data is written to disk and cache simultaneously. (default) |
writeback |
Data is written to disk when discarded from the cache. |
none |
Disable caching. |
Example:
qemu -drive file=disk.img,cache=writeback ...
Attaching drives to controller interfaces
editIf the drive is not attached to a controller interface (i.e. if=none
), then it can be manually attached with:
Bus | Argument |
---|---|
SCSI | -device scsi-hd,drive={id}
|
USB | -device usb-storage,drive={id}
|