< QEMU < Devices

Storage devices can be added using -drive parameter, or with the drive_add command in the QEMU monitor.

Media type

Several 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)

Qemu 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

QEMU can cache access to the disk image files, and it provides several methods to do so. This can be specified using the cache modifier.

PolicyDescription
unsafeLike writeback, but without performing an fsync.
writethroughData is written to disk and cache simultaneously. (default)
writebackData is written to disk when discarded from the cache.
noneDisable caching.

Example:

qemu -drive file=disk.img,cache=writeback ...

Attaching drives to controller interfaces

If the drive is not attached to a controller interface (i.e. if=none), then it can be manually attached with:

BusArgument
SCSI-device scsi-hd,drive={id}
USB-device usb-storage,drive={id}
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.