584 |
@node disk_images |
@node disk_images |
585 |
@section Disk Images |
@section Disk Images |
586 |
|
|
587 |
@subsection Raw disk images |
Since version 0.6.1, QEMU supports many disk image formats, including |
588 |
|
growable disk images (their size increase as non empty sectors are |
589 |
|
written), compressed and encrypted disk images. |
590 |
|
|
591 |
The disk images can simply be raw images of the hard disk. You can |
@subsection Quick start for disk image creation |
592 |
create them with the command: |
|
593 |
|
You can create a disk image with the command: |
594 |
@example |
@example |
595 |
dd of=myimage bs=1024 seek=mysize count=0 |
qemu-img create myimage.img mysize |
596 |
@end example |
@end example |
597 |
where @var{myimage} is the image filename and @var{mysize} is its size |
where @var{myimage.img} is the disk image filename and @var{mysize} is its |
598 |
in kilobytes. |
size in kilobytes. You can add an @code{M} suffix to give the size in |
599 |
|
megabytes and a @code{G} suffix for gigabytes. |
600 |
|
|
601 |
|
@xref{qemu_img_invocation} for more information. |
602 |
|
|
603 |
@subsection Snapshot mode |
@subsection Snapshot mode |
604 |
|
|
605 |
If you use the option @option{-snapshot}, all disk images are |
If you use the option @option{-snapshot}, all disk images are |
606 |
considered as read only. When sectors in written, they are written in |
considered as read only. When sectors in written, they are written in |
607 |
a temporary file created in @file{/tmp}. You can however force the |
a temporary file created in @file{/tmp}. You can however force the |
608 |
write back to the raw disk images by pressing @key{C-a s}. |
write back to the raw disk images by using the @code{commit} monitor |
609 |
|
command (or @key{C-a s} in the serial console). |
|
NOTE: The snapshot mode only works with raw disk images. |
|
|
|
|
|
@subsection Copy On Write disk images |
|
|
|
|
|
QEMU also supports user mode Linux |
|
|
(@url{http://user-mode-linux.sourceforge.net/}) Copy On Write (COW) |
|
|
disk images. The COW disk images are much smaller than normal images |
|
|
as they store only modified sectors. They also permit the use of the |
|
|
same disk image template for many users. |
|
|
|
|
|
To create a COW disk images, use the command: |
|
|
|
|
|
@example |
|
|
qemu-mkcow -f myrawimage.bin mycowimage.cow |
|
|
@end example |
|
610 |
|
|
611 |
@file{myrawimage.bin} is a raw image you want to use as original disk |
@node qemu_img_invocation |
612 |
image. It will never be written to. |
@subsection @code{qemu-img} Invocation |
613 |
|
|
614 |
@file{mycowimage.cow} is the COW disk image which is created by |
@include qemu-img.texi |
|
@code{qemu-mkcow}. You can use it directly with the @option{-hdx} |
|
|
options. You must not modify the original raw disk image if you use |
|
|
COW images, as COW images only store the modified sectors from the raw |
|
|
disk image. QEMU stores the original raw disk image name and its |
|
|
modified time in the COW disk image so that chances of mistakes are |
|
|
reduced. |
|
|
|
|
|
If the raw disk image is not read-only, by pressing @key{C-a s} you |
|
|
can flush the COW disk image back into the raw disk image, as in |
|
|
snapshot mode. |
|
|
|
|
|
COW disk images can also be created without a corresponding raw disk |
|
|
image. It is useful to have a big initial virtual disk image without |
|
|
using much disk space. Use: |
|
|
|
|
|
@example |
|
|
qemu-mkcow mycowimage.cow 1024 |
|
|
@end example |
|
|
|
|
|
to create a 1 gigabyte empty COW disk image. |
|
|
|
|
|
NOTES: |
|
|
@enumerate |
|
|
@item |
|
|
COW disk images must be created on file systems supporting |
|
|
@emph{holes} such as ext2 or ext3. |
|
|
@item |
|
|
Since holes are used, the displayed size of the COW disk image is not |
|
|
the real one. To know it, use the @code{ls -ls} command. |
|
|
@end enumerate |
|
|
|
|
|
@subsection Convert VMware disk images to raw disk images |
|
|
|
|
|
You can use the tool @file{vmdk2raw} to convert VMware disk images to |
|
|
raw disk images directly usable by QEMU. The syntax is: |
|
|
@example |
|
|
vmdk2raw vmware_image output_image |
|
|
@end example |
|
615 |
|
|
616 |
@section Network emulation |
@section Network emulation |
617 |
|
|