Unable to import Windows Guest to Red Hat Virtualization or RHEL KVM, RHOCP.

Solution Verified - Updated

Environment

  • Red Hat Virtualization 4.x
  • Red Hat Enterprise Linux 7, 8 and 9.
  • Red Hat OpenShift Container Platform 4.12
  • OpenShift Virtualization 4.12

Issue

  • Unable to convert Windows OVA Virtual Machine to run on RHEL
  • Unable to convert Windows OVA Virtual Machine to run on RHV
  • Unable to import Windows VM from VMware
  • Getting error "The NTFS partition is in an unsafe state" when trying to import/convert a Windows VM.
  • Getting error "Guest conversion failed" while migrating VM from VMware to RHOCP

Resolution

  • 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.

  • Refer virt-v2v upstream documentation for more information about Content from libguestfs.org is not included.fast startup incompatible with virt-v2v

Root Cause

  • Guests which use the Windows ≥ 8 "Fast Startup" feature (or guests which are hibernated) cannot be converted with virt-v2v as it cannot mount the NTFS file-system in RW if it was not cleanly shutdown.
 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.

Diagnostic Steps

  • In RHV /var/log/vdsm/import/import-****.log (or virt-v2v output on RHEL), the following is seen:
Failed to mount '/dev/sdaX': Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the 'ro' mount option.
guestfsd: main_loop: proc 1 (mount) took 0.03 seconds
libguestfs: trace: v2v: mount = -1 (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.

Original error message: mount: /dev/sdaX on / (options: ''): The disk 
contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
  • In OpenShift Virtualization, virt-v2v pod logs from the target namespace (where the VM is migrating into) contain the following message :
# oc logs <MIGRATIING_VM_NAME-migration-vm-***> -c virt-v2v
2023-03-24T08:07:14.837260271Z The disk contains an unclean file system (0, 0).
2023-03-24T08:07:14.837260271Z Metadata kept in Windows cache, refused to mount.
2023-03-24T08:07:14.837260271Z Falling back to read-only mount because the NTFS partition is in an
2023-03-24T08:07:14.838480711Z unsafe state. Please resume and shutdown Windows fully (no hibernation
2023-03-24T08:07:14.838480711Z or fast restarting.)
2023-03-24T08:07:14.838480711Z Could not mount read-write, trying read-only
2023-03-24T08:07:14.838480711Z libguestfs: trace: v2v: mount = 0
2023-03-24T08:07:14.838480711Z libguestfs: trace: v2v: touch "/7ueusyms"
2023-03-24T08:07:14.839514149Z guestfsd: => mount (0x1) took 0.01 secs
2023-03-24T08:07:14.840905028Z guestfsd: <= touch (0x3) request length 56 bytes
2023-03-24T08:07:14.840905028Z guestfsd: error: open: /7ueusyms: Read-only file system
2023-03-24T08:07:14.840905028Z guestfsd: => toulibguestfs: trace: v2v: touch = -1 (error)
2023-03-24T08:07:14.840934594Z virt-v2v: error: filesystem was mounted read-only, even though we asked for 
2023-03-24T08:07:14.840934594Z it to be mounted read-write.  This usually means that the filesystem was 
2023-03-24T08:07:14.840934594Z not cleanly unmounted.  **Possible causes include trying to convert a guest** 
**2023-03-24T08:07:14.840934594Z which is running, or using Windows Hibernation or Fast Restart**.
2023-03-24T08:07:14.840934594Z 
2023-03-24T08:07:14.840934594Z Original error message: touch: open: /7ueusyms: Read-only file system
2023-03-24T08:07:14.840977854Z rm -rf '/var/tmp/null.ngB3Vh'
2023-03-24T08:07:14.845168446Z libguestfs: trace: v2v: close

Confirm whether HiberbootEnabled is enabled or not in Powershell. (0=disabled, 1=enabled):

Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power" -Name "HiberbootEnabled" | Select-Object -ExpandProperty "HiberbootEnabled"

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.