virt-sparsify(1) | Virtualization Support | virt-sparsify(1) |
virt-sparsify - 仮想マシンのディスクをスパースにします
virt-sparsify [--options] indisk outdisk virt-sparsify [--options] --in-place disk
Virt-sparsify is a tool which can make a virtual machine disk (or any disk image) sparse a.k.a. thin-provisioned. This means that free space within the disk image can be converted back to free space on the host.
Virt-sparsify can locate and sparsify free space in most filesystems (eg. ext2/3/4, btrfs, NTFS, etc.), and also in LVM physical volumes.
Virt-sparsify はさまざまなディスクフォーマットを変換することができます。例えば、raw ディスクイメージをシンプロビジョニングされた qcow2 イメージに変換することができます。
Virt-sparsify can operate on any disk image, not just ones from virtual machines. However if a virtual machine has multiple disks and uses volume management, then virt-sparsify will work but not be very effective (http://bugzilla.redhat.com/887826).
If the input is raw, then the default output is raw sparse. You must check the output size using a tool that understands sparseness such as "du -sh". It can make a huge difference:
$ ls -lh test1.img -rw-rw-r--. 1 rjones rjones 100M Aug 8 08:08 test1.img $ du -sh test1.img 3.6M test1.img
(見た目の容量 100M と実際の容量 3.6M を比較します)
If you are using the --in-place option, then large amounts of temporary space are not required.
You may also want to read the manual pages for the associated tools virt-filesystems(1) and virt-df(1) before starting.
一般的な使用法は次のとおりです:
virt-sparsify indisk outdisk
which copies "indisk" to "outdisk", making the output sparse. "outdisk" is created, or overwritten if it already exists. The format of the input disk is detected (eg. qcow2) and the same format is used for the output disk.
形式を変換するには --convert オプションを使用します:
virt-sparsify disk.raw --convert qcow2 disk.qcow2
Virt-sparsify tries to zero and sparsify free space on every filesystem it can find within the source disk image. You can get it to ignore (don't zero free space on) certain filesystems by doing:
virt-sparsify --ignore /dev/sda1 indisk outdisk
ディスクイメージにあるファイルシステムの一覧を取得するには virt-filesystems(1) を参照してください。
Since virt-sparsify ≥ 1.26, you can now sparsify a disk image in place by doing:
virt-sparsify --in-place disk.img
If the check indicates a problem, then you can either:
You cannot use this option and --in-place together.
You cannot use this option and --in-place together.
サポートされる既知の動作済み出力形式は次のとおりです: "raw", "qcow2", "vdi"。
qemu-img(1) プログラムによりサポートされるすべての形式を使用できます。たとえば、"vmdk" ですが、他の形式のサポートは QEMU に依存します。
Specifying the --convert option is usually a good idea, because then virt-sparsify doesn't need to try to guess the input format.
出力形式を詳細に調整します。関連項目: --compress, -o.
You cannot use this option and --in-place together.
If working with untrusted raw-format guest disk images, you should ensure the format is always specified.
When not using --in-place: Free space on the filesystem will not be zeroed, but existing blocks of zeroes will still be sparsified.
When using --in-place, the filesystem is ignored completely.
In the second form, this ignores the named volume group. Use the volume group name without the /dev/ prefix, eg. --ignore vg_foo
このオプションは複数回指定できます。
Use the specified "KEY_STRING" as passphrase.
Note that if any such option is present on the command line, QEMU user networking will be automatically enabled for the libguestfs appliance.
If there are multiple encrypted devices then you may need to supply multiple keys on stdin, one per line.
You should use -o at most once. To pass multiple options, separate them with commas, eg:
virt-sparsify --convert qcow2 \ -o cluster_size=512,preallocation=metadata ...
You cannot use this option and --in-place together.
If the parameter given is a block device, then the block device is written to directly. Note this erases the existing contents of the block device.
If the parameter is a directory, then this is the same as setting the "TMPDIR" environment variable.
You cannot use this option and --in-place together.
This option is used by oVirt which requires a specially formatted temporary file.
Since virt-sparsify ≥ 1.26, the tool is able to do in-place sparsification (instead of copying from an input disk to an output disk). This is more efficient. It is not able to recover quite as much space as copying sparsification.
To use this mode, specify a disk image which will be modified in place:
virt-sparsify --in-place disk.img
Some options are not compatible with this mode: --convert, --compress and -o because they require wholesale disk format changes; --check-tmpdir because large amounts of temporary space are not required.
In-place sparsification works using discard (a.k.a trim or unmap) support.
The --machine-readable option can be used to make the output more machine friendly, which is useful when calling virt-sparsify from other programs, GUIs etc.
このオプションを使用するには 2 通りの方法があります。
Firstly use the option on its own to query the capabilities of the virt-sparsify binary. Typical output looks like this:
$ virt-sparsify --machine-readable virt-sparsify ntfs btrfs
A list of features is printed, one per line, and the program exits with status 0.
Secondly use the option in conjunction with other options to make the regular program output more machine friendly.
At the moment this means:
^[0-9]+/[0-9]+$
All versions of virt-sparsify have supported the --machine-readable option.
It is possible to specify a format string for controlling the output; see "ADVANCED MACHINE READABLE OUTPUT" in guestfs(3).
Windows 8 "fast startup" can prevent virt-sparsify from working. See "WINDOWS HIBERNATION AND WINDOWS 8 FAST STARTUP" in guestfs(3).
In virt-sparsify ≥ 1.28, you can override this environment variable using the --tmp option.
You should ensure there is enough free space in the worst case for a full copy of the source disk (virtual size), or else set $TMPDIR to point to another directory that has enough space.
This defaults to /tmp.
Note that if $TMPDIR is a tmpfs (eg. if /tmp is on tmpfs, or if you use "TMPDIR=/dev/shm"), tmpfs defaults to a maximum size of half of physical RAM. If virt-sparsify exceeds this, it will hang. The solution is either to use a real disk, or to increase the maximum size of the tmpfs mountpoint, eg:
mount -o remount,size=10G /tmp
If you are using the --in-place option, then large amounts of temporary space are not required.
他の環境変数は "環境変数" in guestfs(3) を参照してください。
This program returns 0 if the operation completed without errors. (This doesn't necessarily mean that space could be freed up.)
A non-zero exit code indicates an error.
If the exit code is 3 and the --in-place option was used, that indicates that discard support is not available in libguestfs, so copying mode must be used instead.
virt-df(1), virt-filesystems(1), virt-resize(1), virt-rescue(1), guestfs(3), guestfish(1), truncate(1), fallocate(1), qemu-img(1), http://libguestfs.org/.
Richard W.M. Jones http://people.redhat.com/~rjones/
Copyright (C) 2011-2023 Red Hat Inc.
To get a list of bugs against libguestfs, use this link: https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
To report a new bug against libguestfs, use this link: https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
When reporting a bug, please supply:
2024-01-04 | guestfs-tools-1.52.0 |