blob: 0e94ed5b33b79a73ce0a1995208123858b89dfae (
plain)
1 Converting Hyper-V VHDs
2 =======================
3 :author: Aaron Ball
4 :email: nullspoon@iohq.net
5
6
7
8 I recently was assigned the task of rebuilding our Team Foundation Server with
9 TFS 2010 for many reasons. One of those is because the old one has a VHD that
10 is consuming far more resources than it should be (it's a 100 gigabyte vhd and
11 only 8 gigabytes are in use). I seemed to recall somewhere that Hyper-V could
12 "compact" a virtual hard drive, but I couldn't remember where. After doing a
13 bit of searching around Hyper-V, I found what I needed. Here's a few facts
14 about this before getting started.
15
16 First, shrinking a hard drive only applies to Dynamically sizing disks. Since
17 these do no shrink on their own (there's a lot of reasons why) but only grow,
18 they might need to be compacted later to free up host space. It only reduces
19 the .vhd file size by shrinking the 'shell' (if you will) to take up the drive
20 space that is not being used by the guest OS.
21
22 In my situation, I was dealing with a drive that was not dynamically sizing but
23 was static. If the vhd is static, the Compact button will not show up when you
24 go to edit the drive.
25
26 In my case, I did not have to compact the drive. As I said, a drive cannot be
27 compacted unless it is dynamic. Since mine was static, I converted it to
28 dynamic to regain the compacting functionality but because of the way the
29 conversion process works, it automatically 'compacts' the .vhd. My original
30 static .vhd was 100 gigabytes. The output was 15.5 gigabytes.
31
32 Though I did not have to compact my .vhd because the conversion process did it
33 for me, I'm going to put the instructions on how to compact the .vhd anyways.
34
35 For starters, the virtual machine that the hard drive is attached to must be
36 turned off. Once the server is offline, from within the Hyper-V Manager (it's
37 an mmc snap-in) go to the virtual machine's properties (right click the machine
38 and select properties). Select the drive you want to shrink on the left panel
39 that lists the various devices attached to the virtual machine. After selecting
40 the drive, on the right panel, select Edit. This will bring up a window that
41 tells you what editing a drive does and gives you the option to not show that
42 screen again. Click Next. From here you should have three options (unless the
43 .vhd is static). Select Compact and click Next. Finally, click Finish and
44 Hyper-V Manager will shrink the .vhd as much as it can.
45
46
47
48 Category:Microsoft
49 Category:Hyper-V
50
51
52 // vim: set syntax=asciidoc:
|