Windows 7 – the feature that caught my eye…

Windows 7, the most awesome OS till date, was released unto manufacturing on October 22nd, 2009. About 17 percent of the people in the world were already using it within a month of its release. ‘Windows 7 definitely is a great improvement over Windows Vista’, but in saying this I’m actually paraphrasing the millions who love this OS. So, does that mean I don’t like Windows 7?

Well, 7 is what Vista was intended to be; it indeed does a great job of it. True, Windows 7 has the upper hand due to its ability to troubleshoot compatibility better, hence making it possible to run applications once made for Windows 3 and it’s derivatives. The Windows XP mode has been a boon to companies that wish to flaunt license ownership of Windows 7 copies but too miserly to spend on newer software.

“Two out of three people have software problems only because they don’t upgrade their hardware when the time spells need.”

-Denver Dias

Consumers loved the Aero interface in Windows 7 better; it made capable some real futuristic stuff. The controls were also easy to understand – Aero shake and snap made a lot more sense to the masses than Aero peek introduced in Windows Vista. Windows 7 boots quicker and shuts down quicker – personally, I loved this part ever since the first beta release. To sum it up, Windows 7 is a great OS. It was still not that different from Vista. I never got why people hated Vista. There is not that much more in 7 on the surface that could make me upgrade from Vista. So, why was my Facebook username ‘Denver7’?

More importantly, why am I writing this post with Internet Explorer 9 on Windows 7?

7 had an awesome feature that caught my eye…

My favourite file-types

There is a huge gap between a computer user and a computer enthusiast in terms of thinking. It might sound weird as I say this and I don’t speak for the whole brotherhood, but the truth is every computer enthusiast has a few, at least one, favorite file types. While I’m ready to admit I do have a few and some of us actually list them, the others amongst us tend to avoid discussing it in public to make sure they’re not bullied or discriminated against – you know, like being called a nerd.

The following is a list of my favorites:

  • WIM: This is the Windows Imaging file format with an extension ‘.wim‘. It also has a variant with the ‘.swm‘ extension. This is the format Microsoft uses to store all the editions of Windows, since Vista, on a single disk. Yes, a DVD of Windows 7 contains all the editions of Windows 7 in it. The reason, I like this format a lot, is it’s ability to store a huge amount of data in an archival form. Also, it is a great format for incremental backup systems. My experiments with files of this type has shown that 50 GiB worth data can be stored on a WIM file of size lesser than 3 GiB.
  • VHD: This is an abbreviation for Virtual Hard Disk. The conventionally accepted format has an extension ‘.vhd‘ and like WIM it has varying extensions and hence a variety of data structures, some of them being ‘.vdi‘(Virtual Box), ‘.vmdk‘(VMware) and various others. One specific example that I could relate to, if I were a novice, when talking about VHDs is the extension ‘.vmdf‘ used by Acer in its eData Security on it’s Aspire series computers.
  • EXE: This abbreviates executable. Files with this extension are those that perform actual work in software. Executables are generally written in assembly code but newer executables tend to use APIs from the .Net Framework for streamlining the process of running all applications. Like WIM and VHD, the files classified as an executable had varying extensions earlier, like ‘.com‘ a.k.a command. As DOS steadily lost the position of kernel in the newer Microsoft OSs, the .exe extension came into prominence.

Lets move on to the more non-geek part of this enterprise, shall we?

Why it’s relevant

The best part of this said feature is that it uses just my favorite three file formats. So, technically all we’re going to do is use a few executables to create a virtual hard disk and later actually boot from the virtual hard disk.

Before we jump to actually creating a virtual hard disk, lets clearly understand what we’re about to do.

Virtual Hard Disk

A virtual hard disk is a file just like any other; it can vary in size but cannot be larger than your physical hard disk itself. Conversely, the contents of this file tends to replicate a physical hard disk as much as possible.

There are three types of virtual hard disks:

  1. Dynamically expanding: This kind occupies the least space possible your physical hard disk, but the VHD eventually expands to take in more files you throw into it. When a VHD of this kind is created, you get to mention the maximum file size, so the VHD does not expand limitlessly. Secondly, when you use VHDs in virtual machines, it shows you the maximum size of the hard disk you earlier defined. Thirdly, removal of files does not reduce the VHD size. In order to reduce the size a maintenance procedure needs to be followed; but it is too complex and requires a lot of physical hard disk space to perform successfully.
  2. Fixed size: In this variant, you get a VHD of a fixed size that does not expand, or contract. I recommend using this as your sizing parameter to avoid losing space later unexpectedly.
  3. Incremental: OK! There is not really a name for this one. It is generally a feature offered by a Virtualizing software to be able to undo recent operations on a VHD, a very handy feature. Microsoft Virtual PC has this as ‘Undo Disks’ and Oracle’s Virtual Box has this as ‘Differencing Disks’. What is done here, is that all your recent changes are stored in a separate file every session. When you start a new session the hard disk contains a summation of all the previous sessions. You could get your virtualizer to remove the last few sessions to get back to a previous state.

The Tutorial

Now, lets get to VHD creation. In Windows 7, open the Command Prompt with Administrator rights. The best way to do this, is type “cmd” in the Start search; some entries will appear; right click on “cmd” and click on ‘Run as administrator’. If a UAC promptpops up, permit the program.

This is how it looks more or less.

Now there is this executable called Diskpart. It should be typed in the command prompt as it is…

diskpart

On completely loading, this is how it appears.

It takes a little while, don't freak out.

Now, you’ll need to type the following command but feel free to change whatever you like.

create vdisk file=C:VHDDenver.vhd type=expandable maximum=30720

As you can see, I’m going to create a virtual disk with filename Denver.vhd of the expandable type. The maximum size I’ve mentioned is 30720 MiB which comes to exactly 30 GiB. Now, the first time I typed this command in it gave me an error message, because I didn’t create the folder VHD in my C: drive. So, I created the folder and retried the command, and it worked.

Tip: Instead of retyping the last command, just click the Up arrow key and the last command will appear.

The dialog appears only the first time.

And this is how the file looks in Explorer after creation.

The file shows a size 62 KiB only because it doesn't contain anything yet.

Then you go back to the command prompt and type the following…

select vdisk file=C:VHDDenver.vhd

Even this takes a while to succeed.

Once this is done, you can attach the virtual disk using the following command.

attach vdisk

This is exactly like connecting an external harddisk except it is virtual.

Now, we need to know what disk number the VHD has been alloted.

list disk

Remeber, free here only means unallocated. Also, there is an asterisk by Disk 4 since it does not appear in Explorer. Clearly Disk 4 is the virtual hard disk I just created.

Further, most of the commands are sequential, so go only by that order.

Now, we select disk 4 using the obvious command…

select disk 4

Since I have 3 external harddisks connected I needed to make sure I don't end up ruining them. So I did a little extra detail check to make sure I chose the virtual disk

After this you can ask it to create you a primary partition. I made an error while doing it the first time, now, but make sure that when you make an error it should be something meaningless or you might end up losing your data.

create partition primary

When you do make a meaningless mistake, though, it does tell you how to correct it.

Now the next step is not necessary since there will only be one partition but here goes…

list partition

And then you see partitions listed, select the partition you’re interested in…

select partition 1

As you can see, the first partition has been created at an offest of 1 MiB, and it still gives me 29 GiB partition size. This is because the diskpart tool rounds off to the lower integer. Think of it as lowering your expectations.

Set the partition active. This is not necessary right now but it’ll sure be useful later.

active

Then you can assign it a drive letter and use it however you want.

assign letter=z

Since, the partition was created but not formatted, it gives you an option to format the virtual partition. There is a cleaner way to do this, trust me.

This is a thing I’ve tried to train into myself all my life – avoid doing anything with a GUI if it is possible to perform the same tast better using command prompt. But, I too am a human being like most of the readers, so I do make mistakes. Now before you assign a letter to the drive here is what you can do…

format fs=NTFS label=Denver unit=512 quick override

The command above formats the drive with the NTFS file format system with the unit allocation size of 512 bytes. It labels my drive ‘Denver’ and overrides any other command.

Elegant and simple, not!

And this is how my Z: virtual drive looks on explorer.

Note that the Z: drive has 29.9 GiB free and C: drive has 24.2 GiB free.

Now, I’ll add some files into the Z: drive.

Note the total file sizes.

Now, checking my VHD file itself it looks like this…

This is the size of the VHD file after formatting the drive and adding some files.

While my Virtual drive has gained weight, so has my parent partition, the C: drive.

As the free space on the drive Z: reduced an equal amount of space on drive C: is used.

If this were a fixed drive, all of the 30 GiB of space would have been taken up at once. This would actually be a good thing because you need not worry about loss of free space when the the VHD loses free space.

Moment of truth!

All of this, that you’ve seen here, is just a part of the feature that caught my eye. The sequel to this is pretty exciting too. All you need to do is wait, a while; or if you know me well, a lot. However, if you’re curious and know enough about this, there are clues in this post to guide you toward the said feature.

Well, that is it for now. Don’t expect the sequel to be the next post, but, you sure can expect something as cool as this to surface here.

As for Denver7, well, somethings you’ll never know.

Once again, I’d like to mention my Facebook page RevRYL where you’ll get regular updates about this blog and its posts. You could also discuss your issues with computers, if any, and suggest me any cool topics to cover. All suggestions, critiques and gifts are welcome.

Speaking of gifts, you can Buy me stuff by clicking on link all the way up…

Settings

Site