virt-customize(1) | Virtualization Support | virt-customize(1) |
virt-customize - Customize a virtual machine
virt-customize [ -a disk.img [ -a disk.img ... ] | -d domname ] [--attach ISOFILE] [--attach-format FORMAT] [ -c URI | --connect URI ] [ -n | --dry-run ] [ --format FORMAT] [ -m MB | --memsize MB ] [ --network | --no-network ] [ -q | --quiet ] [--smp N] [ -v | --verbose ] [-x] virt-customize [ -V | --version ]
Virt-customize can customize a virtual machine (disk image) by installing packages, editing configuration files, and so on.
Virt-customize modifies the guest or disk image in place. The guest must be shut down. If you want to preserve the existing contents of the guest, you must snapshot, copy or clone the disk first.
You do not need to run virt-customize as root. In fact we'd generally recommend that you don't.
Related tools include: virt-sysprep(1) and virt-builder(1).
ディスクイメージの形式は自動的に検出されます。強制的に特定の形式を使用するには --format オプションを使用します。
You probably want to ensure the volume(s) or filesystems in the attached disks are labelled (or use an ISO volume name) so that you can mount them by label in your run-scripts:
mkdir /tmp/mount mount LABEL=EXTRA /tmp/mount
You can have multiple --attach options, and the format can be any disk format (not just an ISO).
ゲストのブロックデバイスを直接指定していると((-a))、libvirt は何も使用されません。
例:
virt-customize --format raw -a disk.img
forces raw format (no auto-detection) for disk.img.
virt-customize --format raw -a disk.img --format auto -a another.img
forces raw format (no auto-detection) for disk.img and reverts to auto-detection for another.img.
仮想マシンのディスクイメージが信頼できない raw 形式である場合、 ディスク形式を指定するためにこのオプションを使用すべきです。 これにより、悪意のある仮想マシンにより起こり得る セキュリティ問題を回避できます (CVE-2010-3851)。
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.
The default can be found with this command:
guestfish get-memsize
Enabled is the default. Use --no-network to disable access.
The network only allows outgoing connections and has other minor limitations. See "NETWORK" in virt-rescue(1).
If you use --no-network then certain other options such as --install will not work.
This does not affect whether the guest can access the network once it has been booted, because that is controlled by your hypervisor or cloud environment and has nothing to do with virt-customize.
Generally speaking you should not use --no-network. But here are some reasons why you might want to:
To enable detailed logging of individual file operations, use -x.
For example (assuming ordinary shell quoting) this command:
--append-line '/etc/hosts:10.0.0.1 foo'
will add either "10.0.0.1 foo⏎" or "⏎10.0.0.1 foo⏎" to the file, the latter only if the existing file does not already end with a newline.
"⏎" represents a newline character, which is guessed by looking at the existing content of the file, so this command does the right thing for files using Unix or Windows line endings. It also works for empty or non-existent files.
To insert several lines, use the same option several times:
--append-line '/etc/hosts:10.0.0.1 foo' --append-line '/etc/hosts:10.0.0.2 bar'
To insert a blank line before the appended line, do:
--append-line '/etc/hosts:' --append-line '/etc/hosts:10.0.0.1 foo'
Note: "PERMISSIONS" by default would be decimal, unless you prefix it with 0 to get octal, ie. use 0700 not 700.
例:
virt-customize --chown '0:0:/var/log/audit.log'
See also: --upload.
Each line contains a single customization command and its arguments, for example:
delete /some/file install some-package password some-user:password:its-new-password
Empty lines are ignored, and lines starting with "#" are comments and are ignored as well. Furthermore, arguments can be spread across multiple lines, by adding a "\" (continuation character) at the of a line, for example
edit /some/file:\ s/^OPT=.*/OPT=ok/
The commands are handled in the same order as they are in the file, as if they were specified as --delete /some/file on the command line.
Wildcards cannot be used.
Wildcards cannot be used.
You can use shell glob characters in the specified path. Be careful to escape glob characters from the host shell, if that is required. For example:
virt-customize --delete '/var/log/*.log'.
See also: --upload, --scrub.
表現がシェルにより変更されるのを防ぐために、適切に引用符でくくるよう注意してください。
このオプションは Perl 5 がインストールされているときのみ利用可能であることに注意してください。
See "NON-INTERACTIVE EDITING" in virt-edit(1).
The script is automatically chmod +x after installation in the guest.
The alternative version --firstboot-command is the same, but it conveniently wraps the command up in a single line script for you.
You can have multiple --firstboot options. They run in the same order that they appear on the command line.
Please take a look at "FIRST BOOT SCRIPTS" in virt-builder(1) for more information and caveats about the first boot scripts.
See also --run.
You can have multiple --firstboot options. They run in the same order that they appear on the command line.
Please take a look at "FIRST BOOT SCRIPTS" in virt-builder(1) for more information and caveats about the first boot scripts.
See also --run.
For an overview on the different ways to install packages, see "INSTALLING PACKAGES" in virt-builder(1).
The parameter is the same as used by the --inject-virtio-win operation.
Note that to do a full conversion of a Windows guest from a foreign hypervisor like VMware (which involves many other operations) you should use the virt-v2v(1) tool instead of this.
The parameter can be one of:
Note that to do a full conversion of a Windows guest from a foreign hypervisor like VMware (which involves many other operations) you should use the virt-v2v(1) tool instead of this.
For an overview on the different ways to install packages, see "INSTALLING PACKAGES" in virt-builder(1).
See also --update, --uninstall.
This uses "mkdir -p" so any intermediate directories are created, and it also works if the directory already exists.
Wildcards cannot be used.
See also: "LOG FILE".
In such guests that support SELinux, customization automatically relabels files so that they have the correct SELinux label. (The relabeling is performed immediately, but if the operation fails, customization will instead touch /.autorelabel on the image to schedule a relabel operation for the next time the image boots.) This option disables the automatic relabeling.
The option is a no-op for guests that do not support SELinux.
See "USERS AND PASSWORDS" in virt-builder(1) for the format of the "SELECTOR" field, and also how to set up user accounts.
"sha256" and "sha512" require glibc ≥ 2.7 (check crypt(3) inside the guest).
"md5" will work with relatively old Linux guests (eg. RHEL 3), but is not secure against modern attacks.
The default is "sha512" unless libguestfs detects an old guest that didn't have support for SHA-512, in which case it will use "md5". You can override libguestfs by specifying this option.
Note this does not change the default password encryption used by the guest when you create new user accounts inside the guest. If you want to do that, then you should use the --edit option to modify "/etc/sysconfig/authconfig" (Fedora, RHEL) or "/etc/pam.d/common-password" (Debian, Ubuntu).
See "USERS AND PASSWORDS" in virt-builder(1) for the format of the "SELECTOR" field, and also how to set up user accounts.
Note: In virt-builder, if you don't set --root-password then the guest is given a random root password.
The script is automatically chmod +x.
If libguestfs supports it then a limited network connection is available but it only allows outgoing network connections. You can also attach data disks (eg. ISO files) as another way to provide data (eg. software packages) to the script without needing a network connection (--attach). You can also upload data files (--upload).
You can have multiple --run options. They run in the same order that they appear on the command line.
See also: --firstboot, --attach, --upload.
If libguestfs supports it then a limited network connection is available but it only allows outgoing network connections. You can also attach data disks (eg. ISO files) as another way to provide data (eg. software packages) to the script without needing a network connection (--attach). You can also upload data files (--upload).
You can have multiple --run-command options. They run in the same order that they appear on the command line.
See also: --firstboot, --attach, --upload.
See "SUBSCRIPTION-MANAGER" in virt-builder(1) for the format of the "SELECTOR" field.
See "SUBSCRIPTION-MANAGER" in virt-builder(1) for the format of the "SELECTOR" field.
This requires credentials being set using --sm-credentials.
See "SSH KEYS" in virt-builder(1) for the format of the "SELECTOR" field.
You can have multiple --ssh-inject options, for different users and also for more keys for each user.
See also --install, --update.
See also --install, --uninstall.
"DEST" could be the final filename. This can be used to rename the file on upload.
If "DEST" is a directory name (which must already exist in the guest) then the file is uploaded into that directory, and it keeps the same name as on the local filesystem.
See also: --mkdir, --delete, --scrub.
For guests which make use of SELinux, special handling for them might be needed when using operations which create new files or alter existing ones.
For further details, see "SELINUX" in virt-builder(1).
このプログラムは、成功すると 0 を返します。または、エラーが起きると 1 を返します。
Normally you do not need to set this. If not set, a compiled-in default will be used (something like /usr/share/virt-tools).
This directory may contain the following files:
See also: "https://github.com/rwmjones/rhsrvany"
他の環境変数は "環境変数" in guestfs(3) を参照してください。
guestfs(3), guestfish(1), virt-builder(1), virt-clone(1), virt-rescue(1), virt-resize(1), virt-sparsify(1), virt-sysprep(1), virsh(1), lvcreate(8), qemu-img(1), scrub(1), http://libguestfs.org/, http://libvirt.org/.
Richard W.M. Jones http://people.redhat.com/~rjones/
Copyright (C) 2011-2023 Red Hat Inc.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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 |