virt-v2v(1)
π NAME π
virt-v2v β the vibe-shift tool that converts a guest so it runs on KVM. Literally takes your foreign-hypervisor guest and gives it a KVM glow-up. The manual you're reading right now is virt-v2v(1), page one of your fave.
β¨ SYNOPSIS β¨
virt-v2v [-i mode] [other -i* options]
[-o mode] [other -o* options]
[virt-customize options]
[guest|filename]
π¦ DESCRIPTION π¦
Okay so bestie, here's the tea: virt-v2v converts a single guest from a foreign hypervisor so it can run on KVM. It can read Linux and Windows guests running on VMware, Hyper-V and some other hypervisors, and convert them over to KVM managed by libvirt, OpenStack, or several other targets. It can also modify the guest so it actually boots on KVM, and it installs virtio drivers so the thing runs fast β we love a performance moment. π₯
There's also a companion front-end called virt-p2v(1) β that one ships as an ISO, CD or PXE image that you boot on physical machines to virtualize those machines (physical to virtual, or p2v, iykyk). Glow-up for actual hardware, no cap.
Wanna estimate the disk space you'll need before conversion? Go see virt-v2v-inspector(1). π
And for in-place conversion, there's a whole separate tool called virt-v2v-in-place(1).
π Input and Output π
Normally you run virt-v2v with several -i* options controlling the input mode and also several -o* options controlling the output mode. In this sense, "input" refers to the source foreign hypervisor (like VMware), and "output" refers to the target KVM-based management system (like oVirt or OpenStack).
The input and output sides of virt-v2v are completely separate and unrelated β not me shipping them together, they're literally independent. virt-v2v can read from any input and write to any output. That's why these two sides are documented separately in this manual.
virt-v2v normally copies from the input to the output, called "copying mode". In this case the source guest is always left unchanged β your original stays untouched, periodt. In-place conversions may be done using virt-v2v-in-place(1).
πΈ Customization πΈ
virt-v2v can also customize the guest during conversion, using the same options as virt-customize(1). For example, injecting files using --upload, or using --firstboot-script to add additional script(s) to run at the first boot after conversion. Read the virt-customize manual for more info on this topic β it's giving very much "read the syllabus" energy but it's worth it. π«Ά
β Other virt-v2v topics β
virt-v2v-support(1)β Supported hypervisors, virtualization management systems, guests.virt-v2v-input-vmware(1)β Input from VMware.virt-v2v-output-local(1)β Output to local files or local libvirt.virt-v2v-output-openstack(1)β Output to OpenStack.virt-v2v-release-notes-1.42(1)β Release notes for 1.42 release.virt-v2v-release-notes-2.0(1)β Release notes for 2.0 release.virt-v2v-release-notes-2.2(1)β Release notes for 2.2 release.virt-v2v-release-notes-2.4(1)β Release notes for 2.4 release.virt-v2v-release-notes-2.6(1)β Release notes for 2.6 release.virt-v2v-release-notes-2.8(1)β Release notes for 2.8 release.virt-v2v-release-notes-2.10(1)β Release notes for 2.10 release.virt-v2v-release-notes-2.12(1)β Release notes for 2.12 release.
π EXAMPLES π
π§ Convert from VMware vCenter server to local libvirt π§
Picture it: you have a VMware vCenter server called vcenter.example.com, a datacenter called Datacenter, and an ESXi hypervisor called esxi. You want to convert a guest called vmware_guest so it runs locally under libvirt.
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi vmware_guest
In this case you will most likely have to run virt-v2v as root, since it needs to talk to the system libvirt daemon and copy the guest disks to /var/lib/libvirt/images. Root privileges β the original main character energy, sadly unavoidable here. π
For more information see virt-v2v-input-vmware(1).
π Convert from ESXi hypervisor over SSH to local libvirt π
You have an ESXi hypervisor called esxi.example.com with SSH access enabled. You want to convert from VMFS storage on that server to a local file.
virt-v2v \
-i vmx -it ssh \
"ssh://root@esxi.example.com/vmfs/volumes/datastore1/guest/guest.vmx" \
-o local -os /var/tmp
The guest must not be running. Like, dead-ass off. Not a suggestion, bestie. π
virt-v2v does not need to be run as root here β slay, no sudo required.
For more information about converting from VMX files see virt-v2v-input-vmware(1).
π Convert disk image to OpenStack π
Given a disk image from another hypervisor that you want to convert to run on OpenStack (only KVM-based OpenStack is supported β that's the rule, no cap), you can run virt-v2v inside an OpenStack VM (called v2v-vm below), and do:
virt-v2v -i disk disk.img -o openstack -oo server-id=v2v-vm
See virt-v2v-output-openstack(1).
π Convert disk image to disk image π
Given a disk image from another hypervisor that you want to convert to run on KVM, you have two options. The simplest way is to try:
virt-v2v -i disk disk.img -o local -os /var/tmp
where virt-v2v guesses everything about the input disk.img and (in this case) writes the converted result to /var/tmp. Manifesting "just works" energy. β¨
A more complex method is to write some libvirt XML describing the input guest (if you can get the source hypervisor to provide you with libvirt XML, then so much the better). You can then do:
virt-v2v -i libvirtxml guest-domain.xml -o local -os /var/tmp
Since guest-domain.xml contains the path(s) to the guest disk image(s) you do not need to specify the name of the disk image on the command line. Convenient or what. π
π OPTIONS π
--helpβ Display help. The "help me help you" of flags.-b ...,--bridge ...β See--networkbelow.--collect GUEST[:LOCAL],--collect-output PATH/TO/OUTPUT.tar.xzβ See "Collecting files for later diagnostics".--colors,--coloursβ Use ANSI colour sequences to colourize messages. This is the default when the output is a tty. If the output of the program is redirected to a file, ANSI colour sequences are disabled unless you use this option. (Two spellings, same aesthetic. π)--echo-keysβ When prompting for keys and passphrases,virt-v2vnormally turns echoing off so you cannot see what you are typing. If you are not worried about Tempest attacks and there is no one else in the room you can specify this flag to see what you are typing.
Note this options only applies to keys and passphrases for encrypted devices and partitions, not for passwords used to connect to remote servers. π
-i disk disk [disk ...]β Set the input method todisk.
In this mode you can read a virtual machine disk image with no metadata. virt-v2v tries to guess the best default metadata. This is usually adequate but you can get finer control (eg. of memory and vCPUs) by using -i libvirtxml instead.
Each disk can be a local file or an nbd:// URI if you want to pull the guest disk from an NBD server (see nbd_connect_uri(3) for the supported URI formats).
-i libvirt name|UUIDβ Set the input method tolibvirt. This is the default.
In this mode you have to specify a libvirt guest name or UUID on the command line. You may also specify a libvirt connection URI (see -ic).
See "Starting the libvirt system instance" below.
-i libvirtxml guest.xmlβ Set the input method tolibvirtxml.
In this mode you have to pass a libvirt XML file on the command line. This file is read in order to get metadata about the source guest (such as its name, amount of memory), and also to locate the input disks. See "Minimal XML for -i libvirtxml option" below.
-i local disk [disk ...]β This is the same as-i disk. Same vibe, different name.-i ova guest.ovaβ Set the input method toova.
In this mode you can read a VMware ova file. virt-v2v will read the ova manifest file and check the vmdk volumes for validity (checksums) as well as analyzing the ovf file, and then convert the guest. See virt-v2v-input-vmware(1).
-i vmx guest.vmx|ssh://...β Set the input method tovmx.
In this mode you can read a VMware vmx file directly or over SSH. This is useful when VMware VMs are stored on an NFS server which you can mount directly, or where you have access by SSH to an ESXi hypervisor. See virt-v2v-input-vmware(1).
-ic libvirtURIβ Specify a libvirt connection URI to use when reading the guest. This is only used when-i libvirt.
Only local libvirt connections, or VMware vCenter connections can be used. Other remote libvirt connections will not work in general.
See also: virt-v2v-input-vmware(1)
-if formatβ For-i diskonly, this specifies the format of the input disk image. For other input methods you should specify the input format in the metadata.-io OPTION=VALUEβ Set input option(s) related to the current input mode or transport. To display short help on what options are available you can use:
virt-v2v -it vddk -io "?"
-io vddk-libdir=LIBDIRβ Set the VDDK library directory. This directory should contain subdirectories calledinclude,lib64etc., but do not includelib64actually in the parameter. Read that twice, bestie. π
In most cases this parameter is required when using the -it vddk (VDDK) transport. See virt-v2v-input-vmware(1) for details.
-io vddk-thumbprint=xx:xx:xx:...β Set the thumbprint of the remote VMware server.
See "VDDK: Thumbprint" in virt-v2v-input-vmware(1) for details.
-io vddk-compression=COMPRESSION,-io vddk-config=FILENAME,-io vddk-cookie=COOKIE,-io vddk-file=FILE,-io vddk-nfchostport=PORT,-io vddk-port=PORT,-io vddk-snapshot=SNAPSHOT-MOREF,-io vddk-transports=MODE:MODE:...β When using VDDK mode, these options are passed unmodified to thenbdkit(1)VDDK plugin. Please refer tonbdkit-vddk-plugin(1). Do not use these options unless you know what you are doing. These are all optional.-ip filenameβ Supply a file containing a password to be used when connecting to the target hypervisor. If this is omitted then the input hypervisor may ask for the password interactively. Note the file should contain the whole password, without any trailing newline, and for security the file should have mode0600so that others cannot read it. π-it sshβ When using-i vmx, this enables the ssh transport. Seevirt-v2v-input-vmware(1).-it vddkβ Use VMware VDDK as a transport to copy the input disks. Seevirt-v2v-input-vmware(1). If you use this parameter then you may need to use other-io vddk*options to specify how to connect through VDDK.--key SELECTORβ Specify a key for LUKS, to automatically open a LUKS device when using the inspection.--key NAME:key:KEY_STRING--key UUID:key:KEY_STRING--key all:key:KEY_STRING
NAME is the libguestfs device name (eg. /dev/sda1). UUID is the device UUID. all means try the key against any encrypted device.
Use the specified KEY_STRING as passphrase. ποΈ
--key NAME:file:FILENAME,--key UUID:file:FILENAME,--key all:file:FILENAMEβ okay so this one reads the passphrase straight out of FILENAME. π That's it, that's the whole vibe.--key NAME:clevis,--key UUID:clevis,--key all:clevisβ this attempts passphrase-less unlocking for the device with Clevis, over the network π¦. Bestie, go read "ENCRYPTED DISKS" inguestfs(3)if you want the full tea on network-bound disk encryption (NBDE), it's all there.
Heads up fr fr: if any of these options is present on the command line, QEMU user networking gets automatically enabled for the libguestfs appliance. No cap, it just happens.
--key NAME:error,--key UUID:error,--key all:errorβ any encrypted device that matches will cause an error π. And--key all:erroris the icon that lets you reject any disk image containing an encrypted partition. Very gatekeep, very demure.--keys-from-stdinβ read key or passphrase parameters from stdin π. The default behaviour is to try to read passphrases from the user by opening/dev/tty.
If there are multiple encrypted devices then you may need to supply multiple keys on stdin, one per line. Slay, but be organized about it π .
Note: --keys-from-stdin only applies to keys and passphrases for encrypted devices and partitions β not for passwords used to connect to remote servers. Different thing entirely, don't mix them up π«Ά.
--mac aa:bb:cc:dd:ee:ff:network:out,--mac aa:bb:cc:dd:ee:ff:bridge:outβ map a source NIC MAC address to a network or bridge π. See "Networks and bridges" below for the full story.--mac aa:bb:cc:dd:ee:ff:ip:ipaddr[,gw[,len[,ns,ns,...]]]β force a particular interface (controlled by its MAC address) to have a static IP address after boot β.
The fields in the parameter are: ipaddr is the IP address. gw is the optional gateway IP address. len is the optional subnet mask length (an integer). The final parameters are zero or more nameserver IP addresses.
This option can be supplied zero or more times. Go off, supply it a bunch π₯.
You only need this option for certain broken guests such as Windows which are unable to preserve MAC to static IP address mappings automatically. You don't need it if Windows is using DHCP. It is currently ignored for Linux guests since they do not have this problem β Linux said "not my problem, bestie" π .
--machine-readable,--machine-readable=formatβ this makes the output more machine friendly when it's being parsed by other programs π€. See "Machine readable output" below.-mMB,--memsizeMB β change the amount of memory allocated when doing the conversion π§ . Virt-v2v will usually choose a suitable default. Bump this up if you see that the conversion step is running out of memory.
See also "Adjusting memory available for conversion".
-n in:out,-n out,--network in:out,--network out,-b in:out,-b out,--bridge in:out,--bridge outβ map a network (or bridge) called "in" to a network (or bridge) called "out" π. If no "in:" prefix is given, all other networks (or bridges) are mapped to "out".
See "Networks and bridges" below, iykyk.
--no-fstrimβ do not trim the filesystem β¨. See "Trimming" below.-o diskβ this is the same as-o local. Same energy, different name π«Ά.-o kubevirtβ set the output method to kubevirt πΈ. Note the way this mode works is experimental and will change in future β so enjoy the ride, but don't build your whole life on it π.
In this mode, the converted guest is written to a local directory specified by -os /dir (the directory must exist).
By default the converted guest's disks are written to:
/dir/name-sda
/dir/name-sdb
[etc]
and guest metadata is created in the associated YAML file:
/dir/name.yaml
where "name" is the guest name.
You can override the disk paths by using -oo disk=... option(s).
-o libvirtβ set the output method to libvirt π. This is the default, so if you're just vibing with no-oat all, this is what you get.
In this mode, the converted guest is created as a libvirt guest. You may also specify a libvirt connection URI (see -oc).
See "Starting the libvirt system instance" below, and virt-v2v-output-local(1).
-o localβ set the output method to local π.
In this mode, the converted guest is written to a local directory specified by -os /dir (the directory must exist). The converted guest's disks are written as:
/dir/name-sda
/dir/name-sdb
[etc]
and a libvirt XML file is created containing guest metadata:
/dir/name.xml
where "name" is the guest name.
-o nullβ set the output method to null π. The guest is converted and copied but the results are thrown away and no metadata is written. It's giving "did all that work for nothing" but honestly sometimes that's the assignment.-o openstackβ set the output method to OpenStack βοΈβ¨. Seevirt-v2v-output-openstack(1).-o qemuβ set the output method to qemu π.
This is similar to -o local, except that a shell script is written which you can use to boot the guest in qemu π₯. The converted disks and shell script are written to the directory specified by -os.
-oa sparse,-oa preallocatedβ set the output file allocation mode πΎ. The default issparse.-oc URIβ specify a connection URI to use when writing the converted guest π¦.
For -o libvirt this is the libvirt URI. Only local libvirt connections can be used. Remote libvirt connections will not work β like, at all, don't try it π. See virt-v2v-output-local(1) for further information.
-offormat β when converting the guest, convert the disks to the given format π.
If not specified, then the input format is used.
-onname β rename the guest when converting it β. If this option is not used then the output name is the same as the input name. Iconic behaviour tbh.-oo OPTION=VALUEβ set output option(s) related to the current output mode π . To display short help on what options are available you can use:
$ virt-v2v -o libvirt -oo "?"
Output options that can be used with -o libvirt:
-oo compressed Compress the output file (used only with
-of qcow2)
Look at that, self-documenting. We love to see it π«Ά.
-oo compressedβ for outputs which support qcow2 format (-of qcow2), this writes a compressed qcow2 file ποΈβ¨. It is the equivalent to the-coption ofqemu-img(1).-oo create=falseβ for-o kubevirt, indicate that another management process will create the output disks, so do not (re-)create them in virt-v2v π. Basically "someone else's problem" mode.-oo disk=DISKβ for-o kubevirtthis overrides the path to each output disk, instead of using the default which isDISK-sdaetc in the output storage (-os) path πΈ. If you use this option at all, you must repeat it once for each guest disk. If you don't use it, then the default method of putting disks in the output storage path is used.-oo guest-id="ID"β for-o openstack(virt-v2v-output-openstack(1)) only, set a guest ID which is saved on each Cinder volume in thevirt_v2v_guest_idvolume property π.-oo os-*=*β for-o openstack(virt-v2v-output-openstack(1)) only, set optional OpenStack authentication π. For example-oo os-username=NAMEis equivalent toopenstack --os-username=NAME.-oo server-id="NAME|UUID"β for-o openstack(virt-v2v-output-openstack(1)) only, set the name of the conversion appliance where virt-v2v is running π₯οΈβ¨.-oo verify-server-certificate,-oo verify-server-certificate="true|false"β for-o openstack(virt-v2v-output-openstack(1)) only, this can be used to disable SSL certification validation when connecting to OpenStack by specifying-oo verify-server-certificate=falseπ¨. Yes bestie that's a real security tradeoff, treat it with the respect it deserves.-opfile β supply a file containing a password to be used when connecting to the target hypervisor π. Note the file should contain the whole password, without any trailing newline, and for security the file should have mode0600so that others cannot read it. Protect that file like it's your Notes app, fr fr π .-osstorage β the location of the storage for the converted guest π¦.
For -o libvirt, this is a libvirt directory pool (see "virsh pool-list") or pool UUID.
For -o local and -o qemu, this is a directory name. The directory must exist β no, it will not make it for you π.
For -o openstack, this is the optional Cinder volume type.
--parallel Nβ enable parallel copying if the guest has multiple disks β‘π₯. N is the maximum number of parallelnbdcopy(1)instances to run.
The default is to run at most one instance of nbdcopy (ie. --parallel=1). All versions of virt-v2v β€ 2.7.2 also did disk copies one at a time.
Within each guest disk, nbdcopy tries to copy in parallel if the underlying endpoints support that. This is not affected by this command line option. See the nbdcopy(1) manual page for details.
--print-sourceβ print information about the source guest and stop πβ¨. This option is useful when you are setting up network and bridge maps. See "Networks and bridges".-q,--quietβ this disables progress bars and other unnecessary output π€«. For when you want the silence, the peace, the zen.--root ask,--root singleβ choose the root filesystem to be converted π±.
In the case where the virtual machine is dual-boot or multi-boot, or where the VM has other filesystems that look like operating systems, this option can be used to select the root filesystem (a.k.a. "C:" drive or /) of the operating system that is to be converted. The Windows Recovery Console, certain attached DVD drives, and bugs in libguestfs inspection heuristics, can make a guest look like a multi-boot operating system π.
Either virt-inspector(1) or virt-v2v-open(1) can be used to list the roots for a dual-boot or multi-boot VM.
The default in virt-v2v β€ 0.7.1 was --root single, which causes virt-v2v to die if a multi-boot operating system is found π.
Since virt-v2v β₯ 0.7.2 the default is now --root ask: if the VM is found to be multi-boot, then virt-v2v will stop and list the possible root filesystems and ask the user which to use. This requires that virt-v2v is run interactively β so like, actually be there, bestie π.
--root firstβ choose the first root device in the case of a multi-boot operating system π₯. Since this is a heuristic, it may sometimes choose the wrong one, and it may not choose the default option from the guest bootloader. For predictable results it is better to usevirt-v2v-open(1)andvirt-inspector(1)to inspect the guest and then specify which root you want to convert. Guessing is cute but checking is cuter π .--root /dev/sdX,--root /dev/VG/LVβ name a specific root device to convert π―, eg.--root /dev/sda2would mean to use the second partition on the first hard drive. If the named root device does not exist or was not detected as a root device, then virt-v2v will fail π. So, like, be sure.
--smp Nβ sets how many virtual CPUs get used while the conversion is happening β¨ virt-v2v usually picks a sensible default for you, so you don't have to touch this. But! pushing it past8can legitimately make conversion faster if your host actually has the physical CPUs to back it up. Heads up though β you might also need to bump the memory size (that's the--memsizeoption) so everything stays fed π-v,--verboseβ turns on verbose messages for debugging. Basically the "tell me everything" button π«Ά-V,--versionβ shows the version number and then dips out. Iconic, brief, done π--wrapβ wraps error, warning, and informative messages. This is the default when the output is a tty π If the program's output is redirected to a file, wrapping gets disabled β unless you explicitly use this option. So if you want wrapping in a redirected file, this is your girl.-xβ enables tracing of libguestfs API calls π₯ (yes, the spicy debug one)
π Customization options π
--append-line FILE:LINEβ appends a single line of text to theFILEπΈ If the file doesn't already end with a newline, one gets added before the appended line. Also, a newline is added to the end of theLINEstring automatically.
So 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 second one only if the existing file doesn't already end with a newline.
β represents a newline character, which gets 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, no cap.
Wanna insert several lines? Just use the same option several times:
--append-line '/etc/hosts:10.0.0.1 foo'
--append-line '/etc/hosts:10.0.0.2 bar'
And to insert a blank line before the appended line, do:
--append-line '/etc/hosts:'
--append-line '/etc/hosts:10.0.0.1 foo'
--chmod PERMISSIONS:FILEβ changes the permissions ofFILEtoPERMISSIONSπ¦
Note:PERMISSIONSby default would be decimal, unless you prefix it with0to get octal β ie. use0700not700. Don't get caught out bestie π
--chown UID:GID:PATHβ changes the owner user and group ID of a file or directory in the guest. Note:- Only numeric UIDs and GIDs will work, and these may not be the same inside the guest as on the host π
- This will not work with Windows guests.
For example:
virt-customize --chown '0:0:/var/log/audit.log'
See also: --upload.
--commands-from-file FILENAMEβ reads the customize commands from a file, one (and its arguments) each line π
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 get ignored too. Furthermore, arguments can be spread across multiple lines by adding a \ (continuation character) at the end 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. Order is everything β¨
--copy SOURCE:DESTβ copies files or directories recursively inside the guest. Wildcards cannot be used π--copy-in LOCALPATH:REMOTEDIRβ copies local files or directories recursively into the disk image, placing them in the directoryREMOTEDIR(which must exist!). Wildcards cannot be used π¦--delete PATHβ deletes a file from the guest. Or deletes a directory (and all its contents, recursively) π
You can use shell glob characters in the specified path. Just be careful to escape glob characters from the host shell, if that's required. For example:
virt-customize --delete '/var/log/*.log'.
See also: --upload, --scrub.
--edit FILE:EXPRβ editsFILEusing the Perl expressionEXPRπΈ
Be careful to properly quote the expression so the shell doesn't alter it before it gets there, ok?
Note that this option is only available when Perl 5 is installed.
See "NON-INTERACTIVE EDITING" in virt-edit(1).
--firstboot SCRIPTβ installsSCRIPTinside the guest, so that when the guest first boots up, the script runs (as root, late in the boot process) π₯
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. Cute, right?
You can have multiple --firstboot options. They run in the same order that they appear on the command line π
See also: "FIRSTBOOT" in virt-customize(1), --run.
--firstboot-command 'CMD+ARGS'β runs the command (and arguments) inside the guest when the guest first boots up (as root, late in the boot process) β¨
You can have multiple --firstboot options. They run in the same order that they appear on the command line.
See also: "FIRSTBOOT" in virt-customize(1), --run.
--firstboot-install PKG,PKG..β installs the named packages (a comma-separated list) π These get installed when the guest first boots, using the guest's package manager (eg. apt, yum, etc.) and the guest's network connection.
For an overview on the different ways to install packages, see "INSTALLING PACKAGES" in virt-builder(1).
--hostname HOSTNAMEβ sets the hostname of the guest toHOSTNAMEπ¦ You can use a dottedhostname.domainname(FQDN) if you want. Main character naming energy, honestly.--install PKG,PKG..β installs the named packages (a comma-separated list) π These get installed during the image build, using the guest's package manager (eg. apt, yum, etc.) and the host's network connection.
For an overview on the different ways to install packages, see "INSTALLING PACKAGES" in virt-builder(1).
See also --update, --uninstall.
--link TARGET:LINK[:LINK..]β creates symbolic link(s) in the guest, starting atLINKand pointing atTARGETπ--mkdir DIRβ creates a directory in the guest π
This uses mkdir -p so any intermediate directories get created too, and it also works if the directory already exists. No fuss, no errors, just vibes.
--move SOURCE:DESTβ moves files or directories inside the guest. Wildcards cannot be used β¨--no-logfileβ scrubsbuilder.log(the log file from build commands) from the image after building is complete π If you don't want to reveal precisely how the image was built, use this option. Sneaky but valid.
See also: "LOG FILE".
--no-selinux-relabelβ do not attempt to correct the SELinux labels of files in the guest π
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. So likeβ¦ it literally does nothing there π«Ά
--password USER:SELECTORβ sets the password forUSERπ₯ (Note this option does not create the user account β it only sets the password, so the user better already exist, ok?)
See "USERS AND PASSWORDS" in virt-builder(1) for the format of the SELECTOR field, and also how to set up user accounts.
--password-crypto md5|sha256|sha512β when the virt tools change or set a password in the guest, this option sets the password encryption of that password tomd5,sha256orsha512π
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 π So like, only reach for it when you genuinely have to.
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--editoption to modify/etc/sysconfig/authconfig(Fedora, RHEL) or/etc/pam.d/common-password(Debian, Ubuntu).
--root-password SELECTORβ sets the root password π (yes, the big one)
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. So don't just assume it'll be blank, bestie π
--run SCRIPTβ runs the shell script (or any program) calledSCRIPTon the disk image πΈ The script runs virtualized inside a small appliance, chrooted into the guest filesystem.
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). So many options, all valid β¨
You can have multiple --run options. They run in the same order that they appear on the command line.
See also: --firstboot, --attach, --upload.
--run-command 'CMD+ARGS'β runs the command and arguments on the disk image π The command runs virtualized inside a small appliance, chrooted into the guest filesystem.
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.
--scrub FILEβ scrubs a file from the guest π§ This is like--deleteexcept that:- It scrubs the data so a guest could not recover it.
- It cannot delete directories, only regular files.
--selinux-relabelβ this is a compatibility option that does nothing π«Ά Truly the "I'm just here so I don't get fined" of options.--selinux-relabel-at-bootβ this advanced option lets you defer SELinux relabelling until the first time the guest boots after conversion π
The advantage of doing this is that conversion is quicker and uses less memory. Faster + lighter = slay.
The disadvantages are:
- It's genuinely so hard to know when this option is even safe to use π like other totally normal options such as
--installmay conflict with it. And especially on systemd-based distros β because of bugs in systemd, this option may not work at all (<https://bugzilla.redhat.com/show_bug.cgi?id=2021835>). Not a link, just the URL, bestie, don't come for me. - The guest is gonna take so much longer to boot up and be ready that first time. it's giving loading screen π
- The guest will reboot at least once. yes, really.
- SELinux relabelling problems cannot be detected during conversion. so you find out later. fun!
If in doubt, do not use this option. periodt.
--selinux-relabel-exclude DIRβ exclude directories from being relabelled π
Okay so this is an advanced option β it lets you list directories inside the guest that should not be relabelled, even when SELinux relabelling is enabled. Use it carefully, because any changes made inside these directories during customization will have incorrect SELinux labels, which leads to potential failures later. So you gotta be sure those directories don't need relabelling.
If in doubt, do not use this option.
You can pass the option multiple times, eg. --selinux-relabel-exclude=/foo --selinux-relabel-exclude=/bar
--ssh-inject USER[:SELECTOR]β inject an ssh key so the givenUSERcan log in over ssh without supplying a password π TheUSERmust exist already in the guest.
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. slay.
--tar-in TARFILE:REMOTEDIRβ copy local files or directories from a local tar file calledTARFILEinto the disk image, placing them in the directoryREMOTEDIR(which must exist). Note that the tar file must be uncompressed (.tar.gzfiles will not work here π« )--timezone TIMEZONEβ set the default timezone of the guest toTIMEZONE. Use a location string likeEurope/Londonπ--touch FILEβ this command performs atouch(1)-like operation onFILE.--truncate FILEβ this command truncatesFILEto a zero-length file. The file must exist already.--truncate-recursive PATHβ this command recursively truncates all files underPATHto zero-length. bye bye content π--uninstall PKG,PKG..β uninstall the named packages (a comma-separated list). These are removed during the image build using the guest's package manager (eg. apt, yum, etc.). Dependent packages may also need to be uninstalled to satisfy the request.
See also --install, --update.
--updateβ do the equivalent ofyum update,apt-get upgrade, or whatever command is required to update the packages already installed in the template to their latest versions. glow up β¨
See also --install, --uninstall.
--upload FILE:DESTβ upload local fileFILEto destinationDESTin the disk image. File owner and permissions from the original are preserved, so you should set them to what you want them to be in the disk image.
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.
--write FILE:CONTENTβ writeCONTENTtoFILE.
π₯ RESOURCE REQUIREMENTS π₯
π Network
The most important resource for virt-v2v appears to be network bandwidth. Virt-v2v should be able to copy guest data at gigabit ethernet speeds or greater. it's giving "your wifi is the villain" energy π
Ensure that the network connections between servers (conversion server, NFS server, vCenter, etc.) are as fast and as low latency as possible. lowkey the whole vibe depends on it.
πΎ Disk space
Virt-v2v places potentially large temporary files in $VIRT_V2V_TMPDIR (usually /var/tmp, see also "ENVIRONMENT VARIABLES" below). Using tmpfs is a bad idea. do not do it.
For each guest disk, an overlay is stored temporarily. This stores the changes made during conversion, and is used as a cache. The overlays are not particularly large β tens or low hundreds of megabytes per disk is typical. In addition to the overlay(s), input and output methods may use disk space, as outlined in the table below.
-i ovaThis temporarily places a full copy of the uncompressed source disks in$VIRT_V2V_TMPDIR(or/var/tmp). yeah. a full copy. plan accordingly π«Ά-o local-o qemuYou must ensure there is sufficient space in the output directory for the converted guest.
See also "Minimum free space check in the host" below.
π₯οΈ VMware vCenter resources
Copying from VMware vCenter is currently quite slow, but we believe this to be an issue with VMware. Ensuring the VMware ESXi hypervisor and vCenter are running on fast hardware with plenty of memory should alleviate this. ngl not much we can do on our end π
β‘ Compute power and RAM
Virt-v2v can be run in a virtual machine, but may run faster on bare metal. (iconic either way)
Virt-v2v is not especially compute or RAM intensive. If you are running many parallel conversions, then you may consider allocating one CPU core and 2 GB of RAM per running instance. (You may adjust the amount of memory used by conversion, see the next heading.)
π§ Adjusting memory available for conversion
virt-v2v --memsize=N can be used to increase the amount of memory available to do conversion. This rarely needs to be adjusted, but can help to workaround some conversion problems.
Linux: setfiles runs out of memory when relabelling
For Linux guests that use SELinux, setfiles can run out of memory if a single directory contains millions of files. As there is no simple way for virt-v2v to detect this problem in advance, you may have to use --memsize=4000 (or larger) to convert such guests. For details see <https://issues.redhat.com/browse/RHEL-125116>
βοΈ Trimming
Virt-v2v attempts to optimize the speed of conversion by ignoring guest filesystem data which is not used. This would include unused filesystem blocks, blocks containing zeroes, and deleted files.
To do this, virt-v2v issues a non-destructive fstrim(8) operation. As this happens to an overlay placed over the guest data, it does not affect the source in any way. no cap, source stays untouched π«Ά
If this fstrim operation fails, you will see a warning, but virt-v2v will continue anyway. It may run more slowly (in some cases much more slowly), because it is copying the unused parts of the disk. it's giving "dragging the whole closet on moving day" π₯²
Unfortunately support for fstrim is not universal, and it also depends on specific details of the filesystem, partition alignment, and backing storage. As an example, NTFS filesystems cannot be fstrimmed if they occupy a partition which is not aligned to the underlying storage. That was the default on Windows before Vista. As another example, VFAT filesystems (used by UEFI guests) cannot be trimmed at all.
fstrim support in the Linux kernel is improving gradually, so over time some of these restrictions will be lifted and virt-v2v will work faster. we love progress β¨
Use --no-fstrim to disable trimming.
π Free space for conversion
Free space in the guest
Virt-v2v checks there is sufficient free space in the guest filesystem to perform the conversion. Currently it checks:
- Linux root filesystem Minimum free space: 100 MB
- Linux /boot Minimum free space: 50 MB
This is because we need to build a new initramfs for some Enterprise Linux conversions.
- Windows
C:drive Minimum free space: 100 MB
We may have to copy in many virtio drivers and guest agents.
- Any other mountable filesystem Minimum free space: 10 MB
In addition to the actual free space, each filesystem is required to have at least 100 available inodes. yeah, inodes. they count too π
Minimum free space check in the host
You must have sufficient free space in the host directory used to store large temporary overlays. To find out which directory this is, use:
$ df -h "$(guestfish get-cachedir)"
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/root 50G 40G 6.8G 86% /
and look under the Avail column. Virt-v2v will refuse to do the conversion at all unless at least 1GB is available there. like it will straight up not do it π
You can change the directory that virt-v2v uses by setting $VIRT_V2V_TMPDIR.
π Running virt-v2v as root or non-root
Nothing in virt-v2v inherently needs root access, and it will run just fine as a non-root user. However, certain external features may require either root or a special user:
- Writing to libvirt When using
-o libvirt, you may need to run virt-v2v as root so that it can write to the libvirt system instance (ie.qemu:///system) and to the default location for disk images (usually/var/lib/libvirt/images).
You can avoid this by setting up libvirt connection authentication, see <http://libvirt.org/auth.html>. Alternatively, use -oc qemu:///session, which will write to your per-user libvirt instance.
See also "Starting the libvirt system instance".
- Writing to Openstack Because of how Cinder volumes are presented as
/devblock devices, using-o openstacknormally requires that virt-v2v is run as root. - Writing to block devices This normally requires root. See the next section.
π§± Writing to block devices
Some output modes write to local files. In general these modes also let you write to block devices, but before you run virt-v2v you may have to arrange for symbolic links to the desired block devices in the output directory.
For example if using -o local -os /dir then virt-v2v would normally create files called:
/dir/name-sda # first disk
/dir/name-sdb # second disk
...
/dir/name.xml # metadata
If you wish the disks to be written to block devices then you would need to create /dir/name-sda (etc) as symlinks to the block devices:
# lvcreate -L 10G -n VolumeForDiskA VG
# lvcreate -L 6G -n VolumeForDiskB VG
# ln -sf /dev/VG/VolumeForDiskA /dir/name-sda
# ln -sf /dev/VG/VolumeForDiskB /dir/name-sdb
Note that you must precreate the correct number of block devices of the correct size. Typically -of raw has to be used too, but other formats such as qcow2 can be useful occasionally so virt-v2v does not force you to use raw on block devices. considerate king behavior honestly π
π¨ PRE-CONVERSION TASKS π¨
okay bestie, before you yeet this guest into KVM there is homework. do it, i'm begging π₯Ί
π¦ Remove Anti-Virus (AV) and Group Policy (GPO)
Anti-Virus software and Windows Group Policy is designed to prevent the kind of driver installation and other changes that we may make to Windows guests. So yeah β it is recommended that you disable or remove this before conversion. Good news: it may be enabled again after conversion. π
π Relax Windows PowerShell ExecutionPolicy
Virt-v2v runs unsigned firstboot PowerShell scripts. Certain Windows PowerShell "ExecutionPolicy" settings such as "AllSigned" may cause the scripts to fail to run. tragic, honestly.
To find the current policy use the Get-ExecutionPolicy command:
Get-ExecutionPolicy -List
To relax the policy use Set-ExecutionPolicy. And you can set the policy back after conversion, no biggie. π«Ά
See also: https:/go.microsoft.com/fwlink/?LinkID=135170 https://redhat.atlassian.net/browse/MTV-4424
π The guest should not be running
The guest must be cleanly shut down before conversion begins, and must not be restarted on the source except if conversion fails. If the guest is running or starts running during conversion then you will end up with filesystem corruption in the converted guest. like literally corrupted. do not do this. π
Virt-v2v tries to ensure the guest is shut down before conversion when it can, but sometimes that is not possible. It is also not possible to prevent a guest from being started while conversion is going on, or after a successful conversion. That must be done by some higher layer management tool instead.
It is possible to convert from a snapshot, but this should only be done to test if a conversion would succeed (with the result being thrown away), and you should fully understand what you are doing. π§
β¨ POST-CONVERSION TASKS β¨
the guest is out, now what π
π Guest network configuration
Virt-v2v cannot currently reconfigure a guest's network configuration. If the converted guest is not connected to the same subnet as the source, its network configuration may have to be updated. See also virt-customize(1).
πͺ Converting a Windows guest
When converting a Windows guests, the conversion process is split into two stages:
- Offline conversion.
- First boot.
The guest will be bootable after the offline conversion stage, but will not yet have all necessary drivers installed to work correctly. These will be installed automatically the first time the guest boots. β¨
N.B. Windows may reboot 4 or more times the first time after conversion. This is required to install the required drivers, guest agents, remove VMware Tools, and configure the network. Take care not to interrupt the automatic driver installation process when logging in to the guest for the first time, as this may prevent the guest from subsequently booting correctly. π yes it really does reboot that many times.
π§Ή Removing VMware Tools from Windows guests
Virt-v2v attempts to remove VMware Tools. For Windows guests this is supposed to happen during the first boot after conversion.
We use VMware's recommended uninstallation method as that is the safest choice. Unfortunately this method is known not to work in most cases (it makes the assumption that it is running on top of VMware, and fails with error 1603). So VMware Tools must be manually removed by some other method. classic. π
VMware's officially documented method for manually removing VMware Tools is here: https://knowledge.broadcom.com/external/article/315629/clean-uninstallation-of-vmware-tools-in.html
Another, unofficial method is described here: https://gist.github.com/broestls/f872872a00acee2fca02017160840624
You should carefully check this script since it makes very invasive changes to the Windows Registry and filesystem. like, very invasive. read it first, bestie. π
π NOTES π
β‘ Enabling virtio
"Virtio" is the name for a set of drivers which make disk (block device), network and other guest operations work much faster on KVM. it's giving speed. it's giving performance. ποΈ
Older versions of virt-v2v could install these drivers for certain Linux guests. This version of virt-v2v does not attempt to install new Linux kernels or drivers, but will warn you if they are not installed already.
In order to enable virtio, and hence improve performance of the guest after conversion, you should ensure that the minimum versions of packages are installed before conversion, by consulting the table below. π
- RHEL 4 β needs
kernel >= 2.5.9-89.EL,lvm2 >= 2.02.42-5.el4,device-mapper >= 1.02.28-2.el4,selinux-policy-targeted >= 1.17.30-2.152.el4,policycoreutils >= 1.18.1-4.13 - RHEL 5 β needs
kernel >= 2.6.18-128.el5,lvm2 >= 2.02.40-6.el5,selinux-policy-targeted >= 2.4.6-203.el5 - RHEL 6+ β All versions support virtio
- Fedora β All versions support virtio
- SLES 11+ β All versions support virtio
- SLES 10 β needs
kernel >= 2.6.16.60-0.85.1 - OpenSUSE 11+ β All versions support virtio
- OpenSUSE 10 β needs
kernel >= 2.6.25.5-1.1 - Debian 6+ β All versions support virtio
- Ubuntu 10.04+ β All versions support virtio
- Windows β Drivers are installed from the ISO or directory pointed to by the
VIRTIO_WINenvironment variable if present. If theVIRTIO_WINenvironment variable is absent (which is the recommended setting), then drivers are searched for in/usr/share/virtio-win, as installed by the virtio-win RPM.
π RHEL 4: SELinux relabel appears to hang forever
In RHEL β€ 4.7 there was a bug which causes SELinux relabelling to appear to hang forever at:
*** Warning -- SELinux relabel is required. ***
*** Disabling security enforcement. ***
*** Relabeling could take a very long time, ***
*** depending on file system size. ***
In reality it is waiting for you to press a key (but there is no visual indication of this). π so rude. You can either hit the [Return] key, at which point the guest will finish relabelling and reboot, or you can install policycoreutils β₯ 1.18.1-4.13 before starting the v2v conversion. See also https://bugzilla.redhat.com/show_bug.cgi?id=244636
𧨠RHEL 8: dracut network-legacy error
In RHEL 8, a conversion fails with:
dracut: dracut module 'network-legacy' cannot be found or installed
This is caused by an issue with a dracut update during the RHEL 8 lifecycle. You can fix it by either installing the dhclient package, or by removing the file /etc/dracut.conf.d/50-network-legacy.conf. Either operation should be done inside the guest before conversion. For more information, see:
https://access.redhat.com/articles/7112814
π§ Linux: "rename: /sysroot/etc/resolv.conf" failure
(This issue is fixed in libguestfs β₯ 1.60, the following documentation is for historical versions.)
In a Linux guest, you see an error such as this:
virt-v2v: error: libguestfs error: command lines: rename: /sysroot/etc/resolv.conf to /sysroot/etc/lwdhuh36: Operation not permitted
This can be caused because the file /etc/resolv.conf in the guest has the immutable bit set. You can use the chattr(1) command before converting the guest:
chattr -i /etc/resolv.conf
and then restore it (+i) after conversion. π
π§ Debian/Ubuntu: "warning: could not determine a way to update the configuration of Grub2"
Currently, virt-v2v has no way to set the default kernel in Debian and Ubuntu guests using GRUB 2 as bootloader. This means that virt-v2v will not change the default kernel used for booting, even in case it is not the best kernel available on the guest. A recommended procedure is, before using virt-v2v, to check that the boot kernel is the best kernel available in the guest (for example by making sure the guest is up-to-date). π
π Debian: "vsyscall attempted with vsyscall=none"
When run on a recent Debian host virt-v2v may fail to convert guests which were created before 2013. In the debugging output you will see a crash message similar to:
vsyscall attempted with vsyscall=none ip:...
segfault at ...
This is caused because Debian removed support for running old binaries which used the legacy vsyscall page to call into the kernel.
You can work around this problem by running this command before running virt-v2v:
export LIBGUESTFS_APPEND="vsyscall=emulate"
For more information, see https://bugzilla.redhat.com/1592061
πͺ Windows: System disk on a Dynamic Disk is not supported
If the Windows system disk (the drive containing \windows) is located on a Dynamic Disk then it cannot be converted. Data disks β that is, disks which are part of the guest but do not contain parts of the Windows operating system β may be Dynamic Disks. π«Ά
See https://bugzilla.redhat.com/2140548.
π΄ Windows β₯ 8 Fast Startup is incompatible with virt-v2v
Guests which use the Windows β₯ 8 "Fast Startup" feature (or guests which are hibernated) cannot be converted with virt-v2v. You will see an error:
virt-v2v: error: unable to mount the disk image for writing. This has
probably happened because Windows Hibernation or Fast Restart is being
used in this guest. You have to disable this (in the guest) in order
to use virt-v2v.
As the message says, you need to boot the guest and disable the "Fast Startup" feature (Control Panel β Power Options β Choose what the power buttons do β Change settings that are currently unavailable β Turn on fast startup), and shut down the guest, and then you will be able to convert it. β¨
For more information, see: "WINDOWS HIBERNATION AND WINDOWS 8 FAST STARTUP" in guestfs(3).
π©Ή Windows: Boot failure: 0x0000007B
This boot failure is caused by Windows being unable to find or load the right disk driver (eg. viostor.sys). If you experience this error, here are some things to check:
- First ensure that the guest boots on the source hypervisor before conversion.
- Check you have the Windows virtio drivers available in
/usr/share/virtio-win, and that virt-v2v did not print any warning about not being able to install virtio drivers.- On Red Hat Enterprise Linux 7, you will need to install the signed drivers available in the
virtio-winpackage. If you do not have access to the signed drivers, then you will probably need to disable driver signing in the boot menus.
- On Red Hat Enterprise Linux 7, you will need to install the signed drivers available in the
- Check that you are presenting a
virtio-blkinterface (notvirtio-scsiand notide) to the guest. On the qemu/KVM command line you should see something similar to this:
... -drive file=windows-sda,if=virtio ...
In libvirt XML, you should see:
<target dev='vda' bus='virtio'/>
- Check that Windows Group Policy does not prevent the driver from being installed or used. Try deleting Windows Group Policy before conversion.
- Check there is no anti-virus or other software which implements Group Policy-like prohibitions on installing or using new drivers.
- Enable boot debugging and check the
viostor.sysdriver is being loaded. π
OpenStack and Windows reactivation π
okay so here's the tea on OpenStack: it literally does not do stable device / PCI addresses for guests. Every single time it creates or starts a guest, it regenerates the libvirt XML for that guest from scratch β brand new, no memories of the past. That XML will have no <address> fields. So libvirt then assigns addresses to devices, in a predictable manner. Cute, right? Except the addresses may change if any of these are true:
- A new disk or network device has been added or removed from the guest. π
- The version of OpenStack or (possibly) libvirt has changed.
And because Windows does not like "hardware" changes of this kind, it may trigger Windows reactivation. Not the vibe.
This can also prevent booting with a 7B error [see previous section] if the guest has group policy containing "Device Installation Restrictions".
Support for SHA-2 certificates in Windows 7 and Windows Server 2008 R2 π
So later versions of the Windows virtio drivers are signed using SHA-2 certificates (instead of SHA-1). And the original shipping Windows 7 and Windows Server 2008 R2? They literally did not understand SHA-2 certificates, so the Windows virtio drivers will not install properly. Tragic.
To fix this you must apply SHA-2 Code Signing Support from: https://docs.microsoft.com/en-us/security-updates/SecurityAdvisories/2015/3033929 before converting the guest. Before, bestie. Not after.
For further information see: https://bugzilla.redhat.com/show_bug.cgi?id=1624878
After conversion, Windows guest cannot be upgraded π
So after a successful conversion, the Windows guest cannot be upgraded to a later release of Windows (eg. from Windows Server 2016 to 2019). Yeah. That's a thing.
Another symptom is that the pnputil /enum-drivers command cannot list all drivers. A few drivers are shown and then the command crashes with the error:
Failed to enumerate driver packages: The parameter is incorrect.
What's causing this? The guestor_tmp temporary driver that we preinstall during conversion so that Windows can see the boot device. Because only minimal changes are made to the Registry to make this work, Windows later gets confused when it sees these partial Registry entries. It's giving "half-finished homework" energy ngl.
The fix is to delete the Registry entries, after conversion but before trying to upgrade Windows. This can be achieved using virt-win-reg(1).
The Windows guest should be shut down. π
The following .reg file should be merged into the Windows Registry: https://github.com/libguestfs/virt-v2v/blob/master/contrib/remove-guestor.reg
# virt-win-reg --merge WindowsGuest remove-guestor.reg
Then the Windows guest can be booted and used / upgraded as normal. Slay.
Alternatively, a WinPE environment can be used to remove the Registry entries.
For further information see: https://issues.redhat.com/browse/MTV-2256
Windows: "Activation of partially decrypted BITLK device is not supported" π
This error from cryptsetup(8) may occur for Windows 11 guests that have a virtual TPM. Even if Bitlocker is not activated, the disk is still encrypted, and so a --key parameter is still required. However it may not be possible to retrieve the key from the TPM. Awkward.
A workaround is to turn on Bitlocker in the Bitlocker Drive Encryption settings in the Control Panel. The Bitlocker key must be passed to virt-v2v on the command line.
For further information see: https://issues.redhat.com/browse/RHEL-70840 and https://windowstechpro.com/how-to-enable-bitlocker-on-windows-11/
Windows: "Enter the recovery key for this drive" π
After conversion, you may be presented with a Windows boot screen showing:
BitLocker recovery
Enter the recovery key for this drive
[|___________________]
(See screenshot on https://issues.redhat.com/browse/RHEL-103915)
This happens when the Windows BitLocker disk encryption key is contained in the VMware Virtual Trusted Platform Module (vTPM). And like... the vTPM is working exactly as designed. It's preventing the encrypted disk from being moved from one machine to another by storing the encryption key in trusted storage on the source. By design, we cannot access or move this key to the target. No cap, it's doing its job.
To start the VM you will need to enter the BitLocker recovery key. This will also register the disk against the new vTPM on the target, so it should only be necessary to do this once. π«Ά
For help finding the recovery key: https://aka.ms/recoverykeyfaq
Linux: Guests with LUKS encryption and TPM fail to boot after conversion π§
Linux guests (such as Ubuntu) that use LUKS-encrypted disks with keys sealed to a Trusted Platform Module (TPM) will fail to boot after virt-v2v conversion. And again β the TPM is working exactly as designed: it prevents the encrypted disk from being used on a different machine. After conversion, the guest runs on a new KVM host with a different vTPM, so the TPM-sealed key is no longer valid.
To convert such a guest, a passphrase-based LUKS keyslot must exist so that virt-v2v can unlock the disk using the --key option. If the guest only has a TPM-sealed key, you must add a passphrase keyslot before conversion. Do not remove the TPM binding on the source VM as it must remain bootable in case the conversion fails. Like, do not touch it, bestie.
The following commands should be run inside the source guest while it is still running on the source hypervisor (where the TPM is valid). In these examples /dev/sda3 is the LUKS partition; substitute the appropriate device for your guest.
If the guest uses clevis for TPM2 binding (e.g. Ubuntu 22.04), first recover the sealed passphrase, then add a new keyslot:
clevis luks list -d /dev/sda3
clevis luks pass -d /dev/sda3 -s SLOT > /tmp/recovered-key
cryptsetup luksAddKey /dev/sda3 --key-file /tmp/recovered-key
If the guest uses systemd-cryptenroll (e.g. Ubuntu 24.04+), systemd-cryptenroll does not expose the sealed passphrase, so you must supply the original installation passphrase when adding a new keyslot:
cryptsetup luksDump /dev/sda3 # verify tpm2 token is present
cryptsetup luksAddKey /dev/sda3
Then convert with virt-v2v, passing the passphrase you enrolled above:
virt-v2v [...] --key all:key:PASSPHRASE
After conversion, the old TPM binding will no longer be valid. Boot the converted guest and remove the stale binding:
clevis luks unbind -d /dev/sda3 -s SLOT -f # clevis
systemd-cryptenroll --wipe-slot=tpm2 /dev/sda3 # systemd-cryptenroll
If you want to re-seal LUKS against the new KVM vTPM, you can then run clevis luks bind -d /dev/sda3 tpm2 '{}' or systemd-cryptenroll --tpm2-device=auto /dev/sda3 inside the converted guest. Fancy. π
For further information see: https://issues.redhat.com/browse/RHEL-85154
Networks and bridges π
Guests are usually connected to one or more networks, and when converted to the target hypervisor you usually want to reconnect those networks at the destination. The options --network, --bridge and --mac allow you to do that. Three little icons, one big glow-up.
If you are unsure of what networks and bridges are in use on the source hypervisor, then you can examine the source metadata (libvirt XML, vCenter information, etc.). Or you can run virt-v2v with the --print-source option which causes virt-v2v to print out the information it has about the guest on the source and then exit.
In the --print-source output you will see a section showing the guest's Network Interface Cards (NICs):
$ virt-v2v [-i ...] --print-source name
[...]
NICs:
Network "default" mac: 52:54:00:d0:cf:0e
Bridges are special classes of network devices which are attached to a named external network on the source hypervisor, for example:
$ virt-v2v [-i ...] --print-source name
[...]
NICs:
Bridge "br0"
To map a specific source bridge to a target network, for example br0 on the source to ovirtmgmt on the target, use:
virt-v2v [...] --bridge br0:ovirtmgmt
To map every bridge to a target network, use:
virt-v2v [...] --bridge ovirtmgmt
Fine-grained mapping of guest NICs β¨
The --mac option gives you more control over the mapping, letting you map single NICs to either networks or bridges on the target. For example a source guest with two NICs could map them individually to two networks called mgmt and clientdata like this:
$ virt-v2v [...] \
--mac 52:54:00:d0:cf:0e:network:mgmt \
--mac 52:54:00:d0:cf:0f:network:clientdata
Note that virt-v2v does not have the ability to change a guest's MAC address. The MAC address is part of the guest metadata and must remain the same on source and target hypervisors. Most guests will use the MAC address to set up persistent associations between NICs and internal names (like eth0), with firewall settings, or even for other purposes like software licensing. So yeah, hands off the MAC. π
Collecting files for later diagnostics π
The virt-v2v --collect and --collect-output options are used to collect files and directories from inside the guest, before conversion, for later diagnosis in case the conversion goes wrong, especially if driver installation at firstboot fails. Forensics, basically.
Typical usage is:
virt-v2v [...] \
--collect /windows/system32/config/ \
--collect /windows/system32/winevt/logs/ \
--collect /etc/ \
--collect-output output.tar.xz
which would save the Windows registry, Windows event logs, and Linux /etc directory to output.tar.xz.
Guest files/directories which do not exist are ignored. The information collected may include sensitive data like passwords. The output could be arbitrarily large since it copies everything specified from the guest. Like, arbitrarily. Be aware bestie.
You can rename directories in the output tarball by adding :dir suffix to the --collect option, eg:
virt-v2v [...] \
--collect /windows/system32/config/:registry
which would create a registry/ directory in the tarball.
Minimal XML for -i libvirtxml option π¦
When using the -i libvirtxml option, you have to supply some libvirt XML. Writing this from scratch is hard, so the template below is helpful.
Note this should only be used for testing and/or where you know what you're doing! If you have libvirt metadata for the guest, always use that instead. π
<domain type='kvm'>
<name> NAME </name>
<memory>1048576</memory>
<vcpu>2</vcpu>
<os>
<type>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/path/to/disk/image'/>
<target dev='hda' bus='ide'/>
<checksum method='sha256' fail='error'>123123...</checksum>
</disk>
<interface type='network'>
<mac address='52:54:00:01:02:03'/>
<source network='default'/>
<model type='rtl8139'/>
</interface>
</devices>
</domain>
π Machine readable output
okay so if you're calling virt-v2v from another program, a GUI, whatever β the --machine-readable option is about to be your bestie β¨ It makes the output way more machine friendly.
There are literally two ways to use this option, and both eat.
First way: use it all on its own to query the capabilities of the virt-v2v binary. Typical output is giving:
$ virt-v2v --machine-readable
virt-v2v
libguestfs-rewrite
colours-option
input:disk
[...]
output:local
[...]
convert:linux
convert:windows
A list of features gets printed, one per line, and then the program exits with status 0 π
iconic behaviour ngl.
The input: and output: features refer to -i and -o (input and output mode) options supported by this binary. The convert: features refer to guest types that this binary knows how to convert.
Second way: use the option together with other options to make the regular program output more machine friendly π«Ά
At the moment this means:
- Progress bar messages can be parsed from stdout by looking for this regular expression:
^[0-9]+/[0-9]+$
- The calling program should treat messages sent to stdout (except for progress bar messages) as status messages. They can be logged and/or displayed to the user.
- The calling program should treat messages sent to stderr as error messages. In addition, virt-v2v exits with a non-zero status code if there was a fatal error.
Virt-v2v β€ 0.9.1 did not support the --machine-readable option at all. The option was added when virt-v2v was rewritten in 2014. ancient history fr π
It is possible to specify a format string for controlling the output; see "ADVANCED MACHINE READABLE OUTPUT" in guestfs(3).
π§ Starting the libvirt system instance
ok so picture this: you're just vibing, you install everything, and then you get hit with these two lines:
Failed to connect socket to '/var/run/libvirt/virtqemud-sock': No such file or directory
Failed to connect socket to '/var/run/libvirt/virtqemud-sock-ro': Connection refused
If you have just installed libvirt and virt-v2v, then you may see the errors above π This is caused by libvirt daemons that provide various services not running straight after installation. (This may depend on your distribution and vendor presets β so it's not you, it's them.)
To fix this on systemd-based distributions, do:
systemctl isolate multi-user.target
See also https://bugzilla.redhat.com/2182024.
ποΈ FILES
/usr/share/virtio-winβ (Optional π) If this directory is present, then virtio drivers for Windows guests will be found from this directory and installed in the guest during conversion.
π± ENVIRONMENT VARIABLES
VIRT_V2V_TMPDIRLIBGUESTFS_CACHEDIRβ Location of the temporary directory used for the potentially large temporary overlay file. If neither environment variable is set then/var/tmpis used.
To reliably ensure large temporary files are cleaned up (for example in case virt-v2v crashes), you should create a randomly named directory under /var/tmp, set VIRT_V2V_TMPDIR to point to this directory, then when virt-v2v exits remove the directory. bestie please actually do this π
See the "Disk space" section above.
VIRT_TOOLS_DATA_DIRβ This can point to the directory containing data files used for Windows conversion.
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:
rhsrvany.exeβ (Required when doing conversions of Windows guests π) This is the RHSrvAny Windows binary, used to install a "firstboot" script in the guest during conversion of Windows guests.
See also: "https://github.com/rwmjones/rhsrvany"
pnp_wait.exeβ (Recommended when doing conversions of Windows guests β¨) This tool waits for newly installed Windows devices to become available before trying to configure them, for example to set network configuration. It is part of the RHSrvAny project.pvvxsvc.exeβ This is a Windows binary shipped with SUSE VMDP, used to install a "firstboot" script in Windows guests. It is an alternative to RHSrvAny.
VIRTIO_WINβ This is an override for where virtio drivers for Windows are searched for. It can be a directory or point tovirtio-win.iso(CD ROM image containing drivers).
If unset, then we look for drivers via whichever of these methods succeeds first:
/usr/share/virtio-win/virtio-win.isoβ The ISO containing virtio drivers for Windows./usr/share/virtio-winβ The exploded tree of virtio drivers for Windows.
See "Enabling virtio".
For other environment variables, see "ENVIRONMENT VARIABLES" in guestfs(3).
π§° OTHER TOOLS
engine-image-uploader(8)β Variously called "engine-image-uploader", "ovirt-image-uploader" or "rhevm-image-uploader", this tool allows you to copy a guest from one oVirt Export Storage Domain to another. It only permits importing a guest that was previously exported from another oVirt instance. very niche, very slay πimport-to-ovirt.plβ This script can be used to import guests that already run on KVM to oVirt. For more information, see this blog posting by the author of virt-v2v:
https://rwmj.wordpress.com/2015/09/18/importing-kvm-guests-to-ovirt-or-rhev/#content
π SEE ALSO
virt-p2v(1), virt-v2v-inspector(1), virt-v2v-in-place(1), virt-v2v-open(1), virt-customize(1), virt-df(1), virt-filesystems(1), virt-inspector(1), virt-sparsify(1), virt-sysprep(1), virt-win-reg(1), guestfs(3), guestfish(1), qemu-img(1), engine-image-uploader(8), import-to-ovirt.pl, nbdkit(1), nbdkit-vddk-plugin(1), http://libguestfs.org/. the whole friend group honestly π«Ά
π AUTHORS
the literal icons who made this happen:
- Matthew Booth
- CΓ©dric Bosdonnat
- Laszlo Ersek
- TomΓ‘Ε‘ GolembiovskΓ½
- Shahar Havivi
- Richard W.M. Jones
- Roman Kagan
- Mike Latimer
- Nir Soffer
- Pino Toscano
- Xiaodai Wang
- Ming Xie
- Tingting Zheng
Β©οΈ COPYRIGHT
Copyright (C) 2009-2025 Red Hat Inc.
π LICENSE
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. (yes the caps are doing the yelling for a reason, bestie π)
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.
π BUGS
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:
- The version of libguestfs.
- Where you got libguestfs (eg. which Linux distro, compiled from source, etc)
- Describe the bug accurately and give a way to reproduce it.
- Run
libguestfs-test-tool(1)and paste the complete, unedited output into the bug report. complete AND unedited, no cherry-picking β¨
and that's the whole page, bestie π you made it to the end, main character energy fr. this was virt-v2v-2.13.8, dated 2026-10-05 β go forth and convert something iconic ππ¦
π¦ where this page comes from
- centos-stream 10: virt-v2v 1:2.13.8-1.el10 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms