When Microsoft launched first beta for Windows 7 I had a laptop with Vista installed on a single partition on entire hardisk. I did not want to give up Vista - a lot of data and important files were on that partition - and after all, 7 was only a beta version...
I thought that I could shrink the old partition, make a new one for Windows 7, and finally end up with a new dual boot system. In Vista there is an option called Volume Shrink
that theoretically would help me to shrink the actual partition and make room for another. So, right click My Computer -> Manage
, then in the new window Storage -> Disk Management
. Then right click on the only one existent partition, then Shrink Volume
Unfortunately, it did not work. There was a persistent error message, even after disk defragmentation and it seems that there's a Vista problem with shrink option.
I was ready to give up when I remembered a new Windows 7 facility - native support for VHD files. A VHD file is a file used to store a virtual machine, and Windows 7 can boot not only from a partition, but from a VHD file also.
That means that you can use a VHD file to install Windows 7 within. Cool, isn't it ?
But first I had to know how to do this. It proved to be more simple that expected.
First you need to boot from windows installation disk, select Windows Repair, enter the command line mode, and start partition manager diskpart
. Then you must create the VHD file:
Create vdisk file=c:\.vhd maximum=<size>
One of the interesting features of the VHD files is that they expand dynamically, so
they use space only when is needed, for example you can set maximum size to, say
50000MB, but in the beginning only 7-8GB will be used, that much is occupied by SO, the rest will be incrementally used within the 50GB limit.
After creating the file this should be selected and attached. That means that within VHD file you should see a virtual disk (say C:) where you can install Windows 7. Use diskpart
with these commands:
select vdisk file=c:\w7.vhd
is the file already created.
Ok, from now on installation process will run as usual. In the end the boot manager will be rewritten in order to support VHD boot facility. It's nice to know that VHD file can be used with any virtual machine Hyper-V based, or other virtualization solution that recognize VHD format, which by the way is open source, you may even write your own interpreter, if you dare !:-).
And yes, as long as entire Windows 7 is now on a single file, I can copy that file on another computer with a capable boot loader, and voila, I've just "reinstalled" my system on another computer !