Archive

Archive for June, 2012

Shrinking a fixed-size VHD file

June 18, 2012 Leave a comment

In playing around with the new Azure Virtual Machines I wanted to upload an existing demo VM. It was a dynamically expanding VHD capped at 250Gb, but Azure only accepts fixed-size disks, and I certainly didn’t want to upload anything larger than was necessary. So to convert and shrink the drive I had to go through a slightly convoluted process:

1. Compact the file through Hyper-V, and then Convert it to a Fixed size (use the Inspect Disk option in the right-hand pane of Hyper-V management console)

image

2. Boot into a Win PE environment in the VM, so you can get to the DiskPart utility. You need to select the relevant volume (SELECT VOLUME x), then run SHRINK to take the volume down to the size required. Bear in mind you probably want some extra overhead for growth again! After this you can turn the VM off again.

3. Download VHDResizer from http://vmtoolkit.com/files/folders/converters/entry87.aspx, this allows you to resize the VHD:

image

Categories: SQL / BI