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