cloudbase / windows-imaging-tools

Tools to automate the creation of a Windows image for OpenStack, supporting KVM, Hyper-V, ESXi and more.
Apache License 2.0
675 stars 227 forks source link

Error during Resize-Image when making windows 10 image #289

Closed icksa closed 5 years ago

icksa commented 5 years ago

I'm trying to create a windows 10 openstack image. During the Resize-Image step, I am getting a "Not Enough Available Capacity" error. Do you have any suggestions about how to get around this?

Thanks

Applying image
[==========================100.0%==========================]
The operation completed successfully.
8/21/2019 6:06:25 AM - Create BCDBoot Config for Windows 10 Pro
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
8/21/2019 6:06:28 AM - BCDBoot config has been created.
8/21/2019 6:06:30 AM - Cloud image generation finished.
8/21/2019 6:06:30 AM - Creating VM WindowsOnlineImage-Sysprep1135807869 attached to ExternalSwitch
8/21/2019 6:06:32 AM - Starting WindowsOnlineImage-Sysprep1135807869
8/21/2019 6:06:37 AM - Waiting for WindowsOnlineImage-Sysprep1135807869 to finish sysprep.
8/21/2019 6:18:42 AM - Shrinking VHD to minimum size
8/21/2019 6:18:43 AM - Initial VHD size is: 80 GB
8/21/2019 6:18:50 AM - Current partition size: 79.998046875 GB
8/21/2019 6:18:50 AM - New partition size: 12 GB
8/21/2019 6:18:50 AM - Size increased: 12884901888
WARNING: Not enough available capacity
Activity ID: {9e74ec16-5791-0000-5877-759e9157d501}
8/21/2019 6:18:56 AM - Size increased: 12989759488
WARNING: Not enough available capacity
Activity ID: {9e74ec16-5791-0000-5877-759e9157d501}
8/21/2019 6:19:02 AM - Size increased: 13094617088
WARNING: Not enough available capacity
Activity ID: {9e74ec16-5791-0000-5877-759e9157d501}
8/21/2019 6:19:08 AM - Size increased: 13199474688
8/21/2019 6:19:11 AM - Not enough available capacity
Activity ID: {9e74ec16-5791-0000-5877-759e9157d501}
Resize-Partition : Not enough available capacity
Activity ID: {9e74ec16-5791-0000-5877-759e9157d501}
At C:\Users\Administrator\projects\windows-openstack-imaging-tools\WinImageBuilder.psm1:994 char:17
+ ...             Resize-Partition -DriveLetter $Drive -Size $sizeIncreased ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (StorageWMI:ROOT/Microsoft/.../MSFT_Partition) [Resize-Partition], CimException
    + FullyQualifiedErrorId : StorageWMI 40000,Resize-Partition
ilenghel commented 5 years ago

Hello, Could you give us some details about your workflow? Did you use the New-WindowsOnlineImage or New-WindowsCloudImage? How does your config file look like?

ader1990 commented 5 years ago

Hello,

You have hit a weird PowerShell issue for the Resize-Partition, as the minimum partition size does not coincide with the minimum resizeable partition size. As your image file has already been generated, you can unmount it manually and run "qemu-img.exe convert -O qcow2 image.vhdx image.qcow2". You will find qemu-img.exe in the bin folder.

To try to fix the code, you can increase the number of retries of the resize or increase the minimum buffer for the resize. https://github.com/cloudbase/windows-openstack-imaging-tools/blob/master/WinImageBuilder.psm1#L990 or https://github.com/cloudbase/windows-openstack-imaging-tools/blob/master/WinImageBuilder.psm1#L963

By default, the number of retries is 4.

icksa commented 5 years ago

Thank you for responding so quickly. I increased the retry count in WinImageBuilder.psm1 and was able to get around this issue.

Thanks again.

ader1990 commented 5 years ago

@icksa I will make a patch to increase the retry count to a higher value so that this issue does not happen anymore.

ader1990 commented 5 years ago

@icksa I added also a binary search resize retry as sometimes not even 20 or 30 retries are not enough on Windows 10 updated. https://github.com/cloudbase/windows-openstack-imaging-tools/pull/294