mutipass:launch failed: Failed to resize instance image - error executing powershell command

744 Views Asked by At

I always have the following error when I install a virtual machine

launch failed: Failed to resize instance image - error executing powershell command. Detail: Resize-VHD : �޷������������̵Ĵ�С�� ϵͳ�޷�������C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\multipassd\vault\instances\krun\ubuntu-20.04-serv er-cloudimg-amd64.vhdx���Ĵ�С�� �޷������������̵Ĵ�С�� ϵͳ�޷�������C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\multipassd\vault\instances\krun\ubuntu-20.04-serv er-cloudimg-amd64.vhdx���Ĵ�С: ��һ����������ʹ�ô��ļ��������޷����ʡ� (0x80070020)�� ����λ�� ��:1 �ַ�: 1

  • Resize-VHD -Path C:/WINDOWS/system32/config/systemprofile/AppData/Roa ...
  •   + CategoryInfo          : ResourceBusy: (:) [Resize-VHD], VirtualizationException
      + FullyQualifiedErrorId : ObjectInUse,Microsoft.Vhd.PowerShell.Cmdlets.ResizeVhd
    
2

There are 2 best solutions below

0
On

You have to add the HyperV module to powershell in "Turn Windows features on or off", if you don't check this the checkbox, "Resize-VHD" won't work and will fail the multipass launch.

The direct command is:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell

0
On

Background

In my case, I changed the location of my multipass instance locations by following this post here. I then created a folder on my drive where I wanted the instances to be stored.

After doing so, multipass launch failed with your exact same error. After trying reboots, uninstall/reinstall multipass, etc. - I finally tried renaming the folder where I wanted to store my multipass instances, and this worked.

Apparently, if your destination multipass folder includes a space, some part of the script fails.

Workaround / Fix

When specifying a multipass instance destination: MULTIPASS_STORAGE -Value "<path>"

Make sure there are NO SPACES in the "<path>" you have provided.

Hope this helps.