Virtual hard drives: The IT pro trick that lets you back up your data for free
Once you finally start backing up your data (like you’ve been told to over, and over again), consider using a virtual hard drive (VHD). VHDs have been used by IT professionals for years in virtual machines and server applications, but you can also use them as a free, easy-to-use backup format—especially since the tools required to use it come with Windows
A VHD is a large container file that simulates the file structure of a hard drive. Think of it as a fancy ZIP file, but without the compression. Because VHDs are single files, they make handling and replicating your backups a cinch. They also allow for easy restores (more on that in a bit), and cross-application/platform compatibility.
A VHD file sits on the hard drive like any other file, however, so be sure you have enough space to accommodate it. And as soon as you're done archiving your files to the VHD, move the file to some other media, such as an external hard drive.
Many programs recognize the VHD format, including Oracle’s VirtualBox virtual machine software, which is available for Windows, OS X and Linux. VHD files can also be accessed via local networks, the Internet, the SMB protocol, or removable media. Once “attached” to the system, VHDs can be treated just like external hard drives or USB sticks.
How to use a VHD
After you’ve created and attached a VHD file, you can back up to it using any means you see fit: a favorite backup program, or a simple copy and paste. I recommend the latter, or a plain-file (no compression) backup utility.
One of the chief advantages of a VHD file is that you can easily browse and restore files using nothing more than the operating system. Just attach it and browse for what you need.
Creating a VHD file
To create a VHD file, open Device Manager or press Windows key + S (in Windows 7, click Start), and type
diskmgmt.msc to access Windows’ disk management features.
Open the Action menu and select Create VHD. You’ll be presented with a dialog to name the VHD file, choose its location, define its size, and choose its format.
A VHD file can be of fixed size, or it can start small and expand as necessary (dynamically expanding). A fixed size is slightly faster and slightly more robust in power-off situations. The dynamically expanding option can be better if you need to save space.
Because storage space for backups fills rapidly, I generally choose to use dynamically expanding VHDs.
Note that the default size is defined in megabytes. Unless you’re backing up nothing but text files, you might want to change the units to gigabytes or terabytes.
A VHD file can be up to 2.2TB. If you plan on using Virtual PC 2007, remember that Virtual PC can only use VHD files up to 127GB.
For easy management, name the file something meaningful. Don’t use the same simple name as the partition you’re backing up--that could get confusing. I use a combination of the name of the drive or partition I’m backing up, plus “backup,” plus the date. For example, “Music backup 08 15 2014.” The date makes it easier to find a specific backup if you create multiple backups of the same drive/partition.
Once you’ve created the VHD, it’ll be automatically attached to the system.
Right-click the VHD, which should say something like ‘DISK 2,’ and select Initialize disk. Choose MBR (Master Boot Record) or GPT (GUID Partition Table) and let it initialize. Unless you’ve got a specific use in mind, GPT and MBR should work equally well.
Right-click over the area to the right that says unallocated, select New Simple Volume, then follow the wizard to create and format a partition.
I recommend naming the partition something meaningful. I use the same format as I described above: name + “backup” + date. Shorten or drop the date if it's too long.
Check Windows Explorer and you’ll see the volume you created. You can treat it just like any other disk drive.
Attaching a VHD
To attach or mount an existing VHD, open Device Manager and select Disk Management, or type
Open the Action menu and select Attach VHD. Browse to the VHD file you want to attach and select it. If you’re restoring from a backup, check Read-only to prevent accidental erasures.
The drive should grab a drive letter on its own, generally the one you assigned originally. If it doesn’t, right-click over the partition in Drive Manager and select Change drive letter and paths.
Detaching a VHD file
Once you’re through using the VHD, detach it from the system to save memory and to prevent possible accidents.
Open Device Manager to get to Disk Management. Right-click the header of the drive and select Detach VHD.
Note that the option ‘Delete the virtual hard disk file after removing the disk,’ is deselected by default. The option is in the same location as the ‘Read-only’ option when you attach a VHD, so choose your options carefully.
When you can use VHD for recovery
Using VHD for backups works best when restoring to the same hard drive, a larger hard drive, or the same model hard drive. In any of these cases, Windows System Restore will work like a charm.
If you’re trying to restore to a smaller drive, as often is the case when users go from hard drives to SSDs, there are risks: The Windows restore routine can’t adjust for the location of some files, which may be placed beyond the limits of the new drive.
For disaster recovery, you’re better off with a program such as Acronis True Image that supports restoring to different hardware.
If you choose VHD as your backup format, just keep in mind what the format is good for and what it isn’t, and you’ll have a great backup solution that’s easy to use and nearly effortless to move around.