Restoring VHDX Hyper-V

Hello,

My current server setup is using a FreeNas as storage and jail as the server.

When i restore a Hyper-V VHDX the VM will not start i get the following error.

The only way i can fix it is using a powershell command for example

Convert-VHD -Path .\testserver.vhdx -DestinationPath .\fixed.vhdx

But this takes more time if we were to restore a disk.

Does anyone know why this happens?

I am now also getting this error when a VHDX is restored

The system failed to convert ‘c:\users\public\documents\hyper-v\virtual hard disks\fixed3.vhdx’: The requested
operation could not be completed due to a virtual disk system limitation. Virtual hard disk files must be
uncompressed and unencrypted and must not be sparse. (0xC03A001A).

I have managed to get it working.

You need to do for example

fsutil sparse setflag “C:\Users\Public\Documents\Hyper-V\Virtual hard disks\testserver.vhdx” 0

This will fix the permissions.

How did you restore the .vhdx?

Tried the component and the normal backup restore.

I think the issue was when it backups up to a FreeNas it looses its permissions.

But that one little command fixes it.

Also is there away to backup components without adding a folder?

Is there any way to add in a script to automatically run a command at the end of the restore?