xref: /openbmc/qemu/docs/system/images.rst (revision 3c87012e3887e8a904a3494283c4acfa7ef777dc)
1923e9311SThomas Huth.. _disk images:
2324b2298SPaolo Bonzini
3324b2298SPaolo BonziniDisk Images
4324b2298SPaolo Bonzini-----------
5324b2298SPaolo Bonzini
6324b2298SPaolo BonziniQEMU supports many disk image formats, including growable disk images
7324b2298SPaolo Bonzini(their size increase as non empty sectors are written), compressed and
8324b2298SPaolo Bonziniencrypted disk images.
9324b2298SPaolo Bonzini
10324b2298SPaolo Bonzini.. _disk_005fimages_005fquickstart:
11324b2298SPaolo Bonzini
12324b2298SPaolo BonziniQuick start for disk image creation
13324b2298SPaolo Bonzini~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14324b2298SPaolo Bonzini
15324b2298SPaolo BonziniYou can create a disk image with the command::
16324b2298SPaolo Bonzini
17324b2298SPaolo Bonzini   qemu-img create myimage.img mysize
18324b2298SPaolo Bonzini
19324b2298SPaolo Bonziniwhere myimage.img is the disk image filename and mysize is its size in
20324b2298SPaolo Bonzinikilobytes. You can add an ``M`` suffix to give the size in megabytes and
21324b2298SPaolo Bonzinia ``G`` suffix for gigabytes.
22324b2298SPaolo Bonzini
23*c5ba6219SPhilippe Mathieu-DaudéSee the ``qemu-img`` invocation documentation for more information.
24324b2298SPaolo Bonzini
25324b2298SPaolo Bonzini.. _disk_005fimages_005fsnapshot_005fmode:
26324b2298SPaolo Bonzini
27324b2298SPaolo BonziniSnapshot mode
28324b2298SPaolo Bonzini~~~~~~~~~~~~~
29324b2298SPaolo Bonzini
30324b2298SPaolo BonziniIf you use the option ``-snapshot``, all disk images are considered as
31324b2298SPaolo Bonziniread only. When sectors in written, they are written in a temporary file
32324b2298SPaolo Bonzinicreated in ``/tmp``. You can however force the write back to the raw
33324b2298SPaolo Bonzinidisk images by using the ``commit`` monitor command (or C-a s in the
34324b2298SPaolo Bonziniserial console).
35324b2298SPaolo Bonzini
36324b2298SPaolo Bonzini.. _vm_005fsnapshots:
37324b2298SPaolo Bonzini
38324b2298SPaolo BonziniVM snapshots
39324b2298SPaolo Bonzini~~~~~~~~~~~~
40324b2298SPaolo Bonzini
41324b2298SPaolo BonziniVM snapshots are snapshots of the complete virtual machine including CPU
42324b2298SPaolo Bonzinistate, RAM, device state and the content of all the writable disks. In
43324b2298SPaolo Bonziniorder to use VM snapshots, you must have at least one non removable and
44324b2298SPaolo Bonziniwritable block device using the ``qcow2`` disk image format. Normally
45324b2298SPaolo Bonzinithis device is the first virtual hard drive.
46324b2298SPaolo Bonzini
47324b2298SPaolo BonziniUse the monitor command ``savevm`` to create a new VM snapshot or
48324b2298SPaolo Bonzinireplace an existing one. A human readable name can be assigned to each
49324b2298SPaolo Bonzinisnapshot in addition to its numerical ID.
50324b2298SPaolo Bonzini
51324b2298SPaolo BonziniUse ``loadvm`` to restore a VM snapshot and ``delvm`` to remove a VM
52324b2298SPaolo Bonzinisnapshot. ``info snapshots`` lists the available snapshots with their
53324b2298SPaolo Bonziniassociated information::
54324b2298SPaolo Bonzini
55324b2298SPaolo Bonzini   (qemu) info snapshots
56324b2298SPaolo Bonzini   Snapshot devices: hda
57324b2298SPaolo Bonzini   Snapshot list (from hda):
58324b2298SPaolo Bonzini   ID        TAG                 VM SIZE                DATE       VM CLOCK
59324b2298SPaolo Bonzini   1         start                   41M 2006-08-06 12:38:02   00:00:14.954
60324b2298SPaolo Bonzini   2                                 40M 2006-08-06 12:43:29   00:00:18.633
61324b2298SPaolo Bonzini   3         msys                    40M 2006-08-06 12:44:04   00:00:23.514
62324b2298SPaolo Bonzini
63324b2298SPaolo BonziniA VM snapshot is made of a VM state info (its size is shown in
64324b2298SPaolo Bonzini``info snapshots``) and a snapshot of every writable disk image. The VM
65324b2298SPaolo Bonzinistate info is stored in the first ``qcow2`` non removable and writable
66324b2298SPaolo Bonziniblock device. The disk image snapshots are stored in every disk image.
67324b2298SPaolo BonziniThe size of a snapshot in a disk image is difficult to evaluate and is
68324b2298SPaolo Bonzininot shown by ``info snapshots`` because the associated disk sectors are
69324b2298SPaolo Bonzinishared among all the snapshots to save disk space (otherwise each
70324b2298SPaolo Bonzinisnapshot would need a full copy of all the disk images).
71324b2298SPaolo Bonzini
72324b2298SPaolo BonziniWhen using the (unrelated) ``-snapshot`` option
73324b2298SPaolo Bonzini(:ref:`disk_005fimages_005fsnapshot_005fmode`),
74324b2298SPaolo Bonziniyou can always make VM snapshots, but they are deleted as soon as you
75324b2298SPaolo Bonziniexit QEMU.
76324b2298SPaolo Bonzini
77324b2298SPaolo BonziniVM snapshots currently have the following known limitations:
78324b2298SPaolo Bonzini
79324b2298SPaolo Bonzini-  They cannot cope with removable devices if they are removed or
80324b2298SPaolo Bonzini   inserted after a snapshot is done.
81324b2298SPaolo Bonzini
82324b2298SPaolo Bonzini-  A few device drivers still have incomplete snapshot support so their
83324b2298SPaolo Bonzini   state is not saved or restored properly (in particular USB).
84324b2298SPaolo Bonzini
85324b2298SPaolo Bonzini.. include:: qemu-block-drivers.rst.inc
86