Disk Virtualization series (three): storage virtualization libraries and tools

kvm platform

tool

qemu-img (Disk Management tool)

  qemu-img is a QEMU disk management tool, after qemu-kvm-source compiler will default qemu-img compiled binary file. qemu-img is QEMU / KVM course a more important tool, this section introduces its usage and practice methods.

  Basic qemu-img command line tool usage is as follows:

  qemu-img command [command options]

It supports commands are divided into the following categories:

(1)check [-f fmt] filename

  Disk image file consistency checking, mirrored look for errors in the file, currently only supports "qcow2", "qed", check the "vdi" format file. Which, qcow2 image file format is introduced QEMU 0.8.3 version, it is currently the most widely used format. qed (QEMU enhanced disk) is an enhanced disk file format from the QEMU 0.14 version began to join, in order to avoid some of the disadvantages qcow2 format, but also in order to improve performance, but is still not mature enough. The vdi (Virtual Disk Image) is Oracle's VirtualBox virtual machine storage format. -F fmt parameter is specified file format, if the format is not specified qemu-img automatically detects, filename is the name of the disk image file (including the path).

(2)create [-f fmt] [-o options] filename [size]

  Fmt create a file named filename of size size of the image file format. Depending on the file format fmt, you can also add one or more options (options) to attach the various functions of the settings file, you can use the "-o?" Queried a certain format file support that option, "-o "options each option separated by commas.

  If the "-o" option used in backing_file this option to specify the back-end image file, then the difference in this part of the image file created only record and back-end image file. Back-end image file is not modified, unless "commit" command in QEMU monitor or use "qemu-img commit" command to manually submit these changes. In this case, size parameters not necessarily required, its value is the default size of the rear end of the image file. In addition, direct use of "-b backfile" parameter is also "backfile -o backing_file =" same effect.

  size option specifies the size of the image file, the default of bytes (bytes), may also be supported k (or K), M, G, T represent respectively KB, MB, GB, TB size. In addition, the size of the image file (size) is not a final order must be written in, it can also be written in "-o" option as one of the options.

(3)commit [-f fmt] filename

  Change the filename file submitted to backend supports image files (specified by backing_file when created) go in.

(4)convert [-c] [-f fmt] [-O output_fmt] [-o options] filename [filename2 […]] output_filename

  The filename of the image file format fmt options according to the option to convert image file format output_fmt named output_filename of. It supports conversion between different image file formats, such as files can be converted to qcow2 with VMware vmdk format file, which users transferred from other programs to the KVM virtualization is useful. In general, the input file format fmt qemu-img automatically detected by the tool, and the output file format needs to be specified in terms of their output_fmt, the default will be converted to the raw file format (default use sparse files and storage to save storage space ).

  Which, "- c" parameter is a compressed image file output, but only qcow2 and image file formats is supported qcow compressed, and this compression is read-only, if the compressed sector is rewritten, it will be rewritten as uncompressed data. Also you can use "-o options" to specify various options, such as: back-end image, file size, whether encryption and so on. Use backing_file option to specify the back-end image, so that the generated files are copy-on-write delta file, then the command must be allowed to convert the contents of the back-end image specified in the back-end image as the input file is the same, although mirroring their respective backend directory, the format may be different.

  If the image file (non-sparse file format) file format as the output format conversion of raw qcow2, qcow, cow and the like, may also function to convert the mirror image file conversion mirror smaller, because it can empty sector deleted so that it does not exist in the generated output file.

(5)info [-f fmt] filename

  Display information filename of the image file. If the file is a sparse file storage, it will exhibit its original size and allocation of disk space actually occupied. If storing client snapshot file, a snapshot of the information will also be displayed. The following command line demonstrates in front of the information file conversion of input and output files.

(6)snapshot [-l | -a snapshot | -c snapshot | -d snapshot] filename

  "-L" option is a query and list all the files in the snapshot mirror, "- a snapshot" image file is to use a snapshot, "- c snapshot" is to create a snapshot, "- d" to delete a snapshot.
(7) rebase [-f fmt] [-t cache] [-p] [-u] -b backing_file [-F backing_fmt] filename

  Change the image file back-end image file formats are supported only qcow2 and qed rebase command. Using the file specified in the "-b backing_file" as a rear mirror, the mirror can also be converted to a rear end "-F backing_fmt" backend specified image format.

  It can work in under two modes, one is safe mode (Safe Mode) is the default mode, qemu-img going to compare the original rear mirror reasonable deal with different back-end mirror current; another species non-secure mode (Unsafe mode), by "-u" parameter to specify this mode is mainly used to fix the rear end image processing performed after the front end of the image file renamed or moved position, to the user ensure the consistency of the back-end image.

(8)resize filename [+ | -]size

  Change the size of the image file so that it is different from the size when it is created. "+" And "-" represent increasing and decreasing the size of the image, but also supports the use of size K, M, G, T and other units. Prior to shrink the size of the mirror, it is necessary to ensure that the client file system in which there is free space, otherwise loss of data, in addition, qcow2 file format is not supported by reduced operating image. Increasing the size of the image file, but also need to go inside to start the client application "fdisk", "parted" partitioning tools such appropriate action can really make the client uses to mirror the increased space. But be careful (best to make a backup), if it fails, it may lead to the image file does not work properly and cause data loss when using the resize command.

libguestfs

  libguestfs is API C language under a set of Linux, used to access the virtual machine's disk image file. Tool comprising a tool has encapsulated the virt-cat, virt-df, virt-ls, virt-copy-in, virt-copy-out, virt-edit, guestfs, guestmount, virt-list-filesystems, virt-list- partitions and other tools

virt-v2v (v2v tool)

VMware

tool

vmkfstools

  vmkfstools- VMFS volume for managing vSphere CLI.

Storehouse

VDDK

  VDDK (VMware's Virtual Disk Development Kit, VMware Virtual Disk Development Kit): Development Kit VMware VMDK is official, which contains a series of "related VMDK C library" and, eg:

  • Virtual Disk Library VixDiskLib for managing VMDK, also known as virtual disk interface Virtual Disk API

  • It used to mount the partition VMDK VixMntApi

VixDiskLib Virtual Disk Library

  Is a set of "management VMDK function calls the collection", designed to help developers to integrate VMware platform product solutions.

  Index.html files can be found in the doc subdirectory under the VDDK installation directory, use a Web browser to open to see VixDiskLib interface reference documentation.

Published 93 original articles · won praise 28 · views 90000 +

Guess you like

Origin blog.csdn.net/shuzishij/article/details/104042905