Splitting a Virtual PC VHD

Two weeks ago me and some colleagues attended the U2U course Developing Microsoft SharePoint 2007 Solutions Part 2: Advanced, led by the legendary Jan “SmartPart” Tielens. I can recommend this course to everyone interested in SharePoint development. It’s filled with interesting topics and it was put together by the also legendary Patrick Tisseghem. During the course we had to practice the stuff we had learned by going through several hands-on labs. For this U2U provided us with a Virtual PC virtual hard disk image (VHD), that contained a complete SharePoint 2007 developer environment (Windows Server 2003, WSS 3.0, MOSS 2007, Visual Studio 2005, SQL Server 2005, Office 2007 etc.).

A couple of days ago, back at our office, me and my colleague Harmjan had some spare time and wanted to practice some of the hands-on labs from that course. Unfortunately the hard drive of my Harmjan’s laptop didn’t have enough free space to contain the U2U course VHD, which is about 11GB in size. He did however bring his brandnew iPod, which still had plenty of free disk space. So he asked me to copy the VHD to his iPod, so he could run it from there.

To my surprise the file copy operation failed! As it turned out Harmjan’s iPod was formatted with the FAT32 file system. One of the main limitations of this file system is, that the maximum size of a file you can put on it is 4GB (well, it’s 232-1 actually…). That meant the U2U VHD would never fit. Ofcourse I could have reformatted the iPod to NTFS, but since an iPod’s firmware doesn’t support this file system it would mean the iPod couldn’t be used as an iPod anymore.

So there had to be an alternative approach. I remembered I had once encountered a situation where a VHD was splitted into several smaller chunks. I searched for this behaviour in the Virtual PC help file and found this:

In some situations, Virtual PC might automatically split a virtual hard disk file into smaller files because of file-size limitations imposed by the host operating system. For example, if the virtual hard disk is stored on a FAT32 volume of the host operating system, it is split into multiple 4GB files.

So this was it! We just had to find a way to split the U2U VHD into several smaller chunks (each less than 4GB). But how to do it? As far as I know Virtual PC has no option to split an existing VHD into smaller chunks. The Virtual Disk wizard only supports this process in the opposite direction, i.e. merging several VHD chunks into one big VHD. I searched the internet, but didn’t find a solution. I did encounter several posts of people who had asked this question before. One of these posts was located on Ben Armstrong’s Virtual PC Guy blog. Unfortunately, from the comments on that post I concluded even he didn’t seem to have an answer. I still sent him an e-mail, asking how to do it, though.

While waiting for a reply from Ben I got bold and downloaded a copy of the official VHD specs from Microsoft. Maybe I could hack together a little tool that would do the job. The only information I could find about splitted VHD’s was this:

Versions prior to Microsoft Virtual Server 2005 supported splitting of disk images, if the disk image grew larger than the maximum supported file size on the host file system.

Some file systems, such as the FAT32 file system, have a 4-GB limit on file size. If the hard disk image expands more than 4 GB, Microsoft Virtual PC 2004 and previous versions will split the hard disk image into another file. The split files do not have any headers or footers, just raw data. The last split file has the footer stored at the end of the file. The first file in the split disk image has an extension of .vhd. The following split files use the .v01, .v02, … filename extension. The split files will be in the same directory as the main hard disk image. The maximum number of split files that can be present is 64.The size of the split file cannot be altered.

There it was! As it turns out a split VHD is nothing more than a normal VHD, chopped up into smaller chunks. No extra headers or footers, just a raw file splitting operation. I couldn’t believe it was this simple.

So I quickly downloaded a copy of the popular HJSplit file splitting utility and split the U2U VHD into several chunks, using a maximum chunk size of 3.5GB (I could have used a larger chunk size, but I wanted to be on the safe side). I then renamed the chunks, so they matched the pattern required by Virtual PC (i.e. U2U.vhd, U2U.v01, U2U.v02, U2U.v03, …). I copied the chunks to the iPod and created a new Virtual PC instance (.vmc), that used the newly, splitted, VHD. And guess what… It worked! I experimented with several other chunk sizes and it doesn’t really seem to matter what chunk size you choose.

I immediately notified Ben Armstrong of my findings and in his reply he said he too was surprised this approach had worked. By now he has already spoken to his colleagues at the Microsoft virtualization team and they confirmed that splitting VHD’s this way is safe and he said he planned to blog about this sometime in the near future.

Well, this concludes my first real blog post. It got a little longer than I had expected, but I hope you found it a good read.

Greetz,

Leon

Posted on October 26, 2007, in sharepoint, virtualization and tagged , , , , , , , . Bookmark the permalink. 21 Comments.

  1. Wow, great find! How does the virtual machine perform when it is run from an iPod?

  2. Bob, I don’t know the specs of the iPod. But I think my colleague had no problems with it.

  3. Hi Leon. Mate I stumbled across your site using google. Like most things, I was looking for something else and found your article. It was more interesting than what I was doing at the time, so I blogged it 🙂

  4. Does this also mean that going the other way (from split to single file) is as simple as cat’ing the pieces together in the right order?

  5. Julian, yes it should be no problem putting the pieces back together. As I stated in my blog the split is just a raw file split. So a join should be safe.

    The “normal” procedure for doing this is using the Virtual Disk wizard, though.

  6. Wow, just what I needed! I was planning on getting an external hard disk for hosting VPC’s. Using your trick I can just use my iPod. Thanks!

  7. The easiest way is to do it using Virtual PC’s “Virtual Disk Wizard”, select your big vhd file and choose to compact it to the FAT32 disk. It will split it automatically when it reaches the 4GB limitation

  8. Excellent text, thanks!

  9. This is a real good help for me.

  10. Hello, I’m interested in getting started in SharePoint development and in your blog here you mention a Virtual PC image with a complete SharePoint development environment.

    Do you know, or can you give me some pointers, as to where I could get such an image.

    Thanks

  11. Searched “splitting virtual pc image files” on Google, and you were #1 on the list, and you had exactly what I needed!

    Thank you!

    Paul

  12. Just when I was about to get disappointed and cynical with technology, your sweet little blog reaffirmed my faith

  13. A simpler way:
    open virtual pc / hard disk wizard / manage an actual vhd and compact the disk / save to fat32.

    …and you have the disk splitted!!!

  14. This feature no longer support in windows 10? I just split a large vhd file into pieces, and windows refuse to load the splitted files. It said the file is corrupted.

  15. Can anyone confirm if these split files are still able to be mounted in Windows 10? I am not having luck. Getting error that “The disc image file is corrupted.” 😦

  1. Pingback: Dugie’s Pensieve » Blog Archive » Q: Can I run a VHD onto my iPOD?

  2. Pingback: Virtual PC Guy's WebLog : Splitting VHDs

  3. Pingback: Splitting VHDs - Noticias externas

  4. Pingback: MSDN Blog Postings » Splitting VHDs

  5. Pingback: game reviews

Leave a comment