1.. _disk images: 2 3Disk Images 4----------- 5 6QEMU supports many disk image formats, including growable disk images 7(their size increase as non empty sectors are written), compressed and 8encrypted disk images. 9 10.. _disk_005fimages_005fquickstart: 11 12Quick start for disk image creation 13~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 14 15You can create a disk image with the command:: 16 17 qemu-img create myimage.img mysize 18 19where myimage.img is the disk image filename and mysize is its size in 20kilobytes. You can add an ``M`` suffix to give the size in megabytes and 21a ``G`` suffix for gigabytes. 22 23See the qemu-img invocation documentation for more information. 24 25.. _disk_005fimages_005fsnapshot_005fmode: 26 27Snapshot mode 28~~~~~~~~~~~~~ 29 30If you use the option ``-snapshot``, all disk images are considered as 31read only. When sectors in written, they are written in a temporary file 32created in ``/tmp``. You can however force the write back to the raw 33disk images by using the ``commit`` monitor command (or C-a s in the 34serial console). 35 36.. _vm_005fsnapshots: 37 38VM snapshots 39~~~~~~~~~~~~ 40 41VM snapshots are snapshots of the complete virtual machine including CPU 42state, RAM, device state and the content of all the writable disks. In 43order to use VM snapshots, you must have at least one non removable and 44writable block device using the ``qcow2`` disk image format. Normally 45this device is the first virtual hard drive. 46 47Use the monitor command ``savevm`` to create a new VM snapshot or 48replace an existing one. A human readable name can be assigned to each 49snapshot in addition to its numerical ID. 50 51Use ``loadvm`` to restore a VM snapshot and ``delvm`` to remove a VM 52snapshot. ``info snapshots`` lists the available snapshots with their 53associated information:: 54 55 (qemu) info snapshots 56 Snapshot devices: hda 57 Snapshot list (from hda): 58 ID TAG VM SIZE DATE VM CLOCK 59 1 start 41M 2006-08-06 12:38:02 00:00:14.954 60 2 40M 2006-08-06 12:43:29 00:00:18.633 61 3 msys 40M 2006-08-06 12:44:04 00:00:23.514 62 63A VM snapshot is made of a VM state info (its size is shown in 64``info snapshots``) and a snapshot of every writable disk image. The VM 65state info is stored in the first ``qcow2`` non removable and writable 66block device. The disk image snapshots are stored in every disk image. 67The size of a snapshot in a disk image is difficult to evaluate and is 68not shown by ``info snapshots`` because the associated disk sectors are 69shared among all the snapshots to save disk space (otherwise each 70snapshot would need a full copy of all the disk images). 71 72When using the (unrelated) ``-snapshot`` option 73(:ref:`disk_005fimages_005fsnapshot_005fmode`), 74you can always make VM snapshots, but they are deleted as soon as you 75exit QEMU. 76 77VM snapshots currently have the following known limitations: 78 79- They cannot cope with removable devices if they are removed or 80 inserted after a snapshot is done. 81 82- A few device drivers still have incomplete snapshot support so their 83 state is not saved or restored properly (in particular USB). 84 85.. include:: qemu-block-drivers.rst.inc 86