Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Feature Request: Add support to Compact VHD image #37

Open
timstockford opened this issue May 14, 2020 · 2 comments
Open

Feature Request: Add support to Compact VHD image #37

timstockford opened this issue May 14, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@timstockford
Copy link

I am considering using Azure Image Builder to build images that can be used both in Azure and on-premise. However the generated VHD physical size is large, as it is a fully expanded disk image. This means effectively downloading a large file (e.g. 127gb) from the internet which is mostly unused space.

It would be great if we could have an added property to the "VHD" distribute type that runs the "Compact" operation if set to true, so that the generated VHD is significantly smaller for download.

So for example the VHD distribute section of the AIB ARM template might look like:

"distribute": 
[
    { 
        "type": "VHD",
        "runOutputName": "aibTemplate",
        "compact": true
    } 
    
]

The Powershell commands required to compact a VHD are:

Mount-VHD .\aibImage.vhd -ReadOnly
Optimize-VHD .\aibImage.vhd -Mode Pretrimmed
Dismount-VHD .\aibImage.vhd

# Pretrimmed: Utilizes information from the trim/unmap commands to detect unused blocks.
# Does not look for empty blocks and does not query the contained file system for unused blocks.

This site contains a nice powershell function to do this.

Many thanks
Tim

@danielsollondon danielsollondon added the enhancement New feature or request label Jun 15, 2020
@danielsollondon
Copy link
Owner

Hi @timstockford - great feedback, added to the backlog, we will review in August.

@timstockford
Copy link
Author

In testing this myself [manually] I did come across some challenges:

  • you need to use a minimum of a D_v3 or E_v3 to get the hyper-v support to load the necessary features to tun the hyper-v cmdlets.
  • using storage explorer to copy the VHD locally times out everytime. Need to try AZcopy.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants