| 1 | .. _disk images: |
| 2 | |
| 3 | Disk Images |
| 4 | ----------- |
| 5 | |
| 6 | QEMU supports many disk image formats, including growable disk images |
| 7 | (their size increase as non empty sectors are written), compressed and |
| 8 | encrypted disk images. |
| 9 | |
| 10 | .. _disk_005fimages_005fquickstart: |
| 11 | |
| 12 | Quick start for disk image creation |
| 13 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 14 | |
| 15 | You can create a disk image with the command:: |
| 16 | |
| 17 | qemu-img create myimage.img mysize |
| 18 | |
| 19 | where myimage.img is the disk image filename and mysize is its size in |
| 20 | kilobytes. You can add an ``M`` suffix to give the size in megabytes and |
| 21 | a ``G`` suffix for gigabytes. |
| 22 | |
| 23 | See the ``qemu-img`` invocation documentation for more information. |
| 24 | |
| 25 | .. _disk_005fimages_005fsnapshot_005fmode: |
| 26 | |
| 27 | Snapshot mode |
| 28 | ~~~~~~~~~~~~~ |
| 29 | |
| 30 | If you use the option ``-snapshot``, all disk images are considered as |
| 31 | read only. When sectors in written, they are written in a temporary file |
| 32 | created in ``/tmp``. You can however force the write back to the raw |
| 33 | disk images by using the ``commit`` monitor command (or :kbd:`Ctrl+a s` in the |
| 34 | serial console). |
| 35 | |
| 36 | .. _vm_005fsnapshots: |
| 37 | |
| 38 | VM snapshots |
| 39 | ~~~~~~~~~~~~ |
| 40 | |
| 41 | VM snapshots are snapshots of the complete virtual machine including CPU |
| 42 | state, RAM, device state and the content of all the writable disks. In |
| 43 | order to use VM snapshots, you must have at least one non removable and |
| 44 | writable block device using the ``qcow2`` disk image format. Normally |
| 45 | this device is the first virtual hard drive. |
| 46 | |
| 47 | Use the monitor command ``savevm`` to create a new VM snapshot or |
| 48 | replace an existing one. A human readable name can be assigned to each |
| 49 | snapshot in addition to its numerical ID. |
| 50 | |
| 51 | Use ``loadvm`` to restore a VM snapshot and ``delvm`` to remove a VM |
| 52 | snapshot. ``info snapshots`` lists the available snapshots with their |
| 53 | associated 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 | |
| 63 | A 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 |
| 65 | state info is stored in the first ``qcow2`` non removable and writable |
| 66 | block device. The disk image snapshots are stored in every disk image. |
| 67 | The size of a snapshot in a disk image is difficult to evaluate and is |
| 68 | not shown by ``info snapshots`` because the associated disk sectors are |
| 69 | shared among all the snapshots to save disk space (otherwise each |
| 70 | snapshot would need a full copy of all the disk images). |
| 71 | |
| 72 | When using the (unrelated) ``-snapshot`` option |
| 73 | (:ref:`disk_005fimages_005fsnapshot_005fmode`), |
| 74 | you can always make VM snapshots, but they are deleted as soon as you |
| 75 | exit QEMU. |
| 76 | |
| 77 | VM 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 | .. _block-drivers: |
| 86 | |
| 87 | .. include:: qemu-block-drivers.rst.inc |