Presently native boot from VHD is supported by MS only in Windows 7 Enterprise, Ultimate, Windows Server 2008 R2, and Windows 7 Embedded Standard. Any other Win7 version by default has deactivated VHD drivers, while older OSs don't have any, and would require a 3-rd party virtual disk driver installed on it, and boot via a 3-rd party bootloader like Grub4DOS or Vboot to run from VHD. MS also provides deployment tools like DISM for driver injection to an offline OS and other tasks, which might not always work as expected. As well, Windows versions prior to Vista must be installed to a hard drive from a running DVD, while versions from Vista can be applied offline to a HD by restoring with ImageX a WIM image, available on Windows Setup ISO or created from a previously installed OS volume.
Booting OS from VHD has many advantages: portability, ready to use distribution requiring no user effort, agnostic to environment, and running on real hardware without performance drop - culmination of Virtual OS-in-File concept. Do you want to try running on your PC from a single file your old Windows install with all apps, or a new Windows version unsupported for native boot from VHD? No problem... There are several 3-d party Virtual Disk Drivers currently available allowing to install OS from Windows Setup ISO to VHD, like FiraDisk, ImDisk, WinVBlock and others. Some of them also allow to boot Windows from VHD, once installed. In this Tutorial we'll use WinVBlock driver for both tasks: to install and boot Win7 Professional from VHD. Instead of Win7 Pro you may want to install WinXP or another Windows version, unsupported for native boot from VHD.
1. Create a Base VHD:
If your existing OS is Win7, create on your hard drive and format a new fixed Win7Pro.vhd by running Diskpart from Console as per Create Native Boot VHDs Tutorial. In WinXP you can install and use VHDMount to create and attach a VHD, then format as usual, or create and format the VHD in Virtual PC 2007. Otherwise boot from Win7 Setup ISO or WinPE, and create the VHD of size, minimally required for a selected OS according to its spec. Make sure to select Format command options suitable for your OS version - see Diskpart Help. Pre-formatting a VHD with specific to target OS and disk type & array size format options allows to avoid "non-compatible hardware" errors, when starting OS install and later when booting OS from VHD with Grub4DOS. Read more on choosing optimal format options in Hitachi's Advanced Format Technology Brief. Once created, you can also attach, detach and mount the VHD volumes in Win7 Disk Management.
diskpart create vdisk file="C:Win7Pro.vhd" maximum=25600 type=(fixed|expandable) select vdisk file="C:Win7Pro.vhd" attach vdisk online disk noerr attributes disk clear readonly noerr create partition primary offset=(32|64|128|256|512|1024|2048) align=(2|4|8|16|32|64) online volume noerr attributes volume clear readonly noerr active assign letter=V: format quick fs=ntfs label="Win7Pro VHD" unit=(512|1024|2048|4096|8192|16K|32K|64K) exit bootsect /nt(52|60) v: /force /mbr [*]For example, you may format a small service VHD for WinXP install with Win7 or WinPE 3.0 Diskpart: diskpart create vdisk file="C:WinXP.vhd" maximum=6144 type=fixed select vdisk file="C:WinXP.vhd" attach vdisk attributes disk clear readonly create partition primary offset=32 align=4 attributes volume clear readonly active assign letter=V: format quick fs=ntfs label="WinXP VHD" unit=4096 exit bootsect /nt52 v: /force /mbr
2. Install Grub4DOS to your hard drive:
Download and install Grub4DOS to your current system drive or a new clean drive as per Diddy's Tutorial. Then add Boot Grub4DOS entry to Windows Boot Menu. Older Grub4DOS versions like 0.4.5b of Sep.17, 2011 may work better with WinVBlock - you may need to try several to find a match, if having relevant boot problems. Place Win7Pro.vhd, Windows Setup ISO and a floppy image with WinVBlock driver (test signed 64-bit / not signed 32-bit) to your HD root. Copy the floppy content to a real Floppy disk, or add mapping WinVBlock.ima in Grub4DOS Menu below, or copy the floppy content to the HD folder (for Win7 install only). You can also download WinVBlock binaries via links posted by Sha0, then install and test, which driver version will work for your OS. Grub4DOS is needed to map and mount the VHD in real mode supported by BIOS, then transfer control to BOOTMGR or NTLDR (depending on OS version) on the ISO or VHD disk that starts OS from it. WinVBlock must be installed on that OS to hot-swap in protected kernel mode the ISO or VHD disk mounted by Grub4DOS to allow complete Windows install or boot.
3. Add Windows Install and Boot from VHD sections to Grub4DOS Menu:
Add the sections, based on instructions of its developer Sha0 regarding WinVBlock use, to the Grub4DOS Menu.lst. When installing and booting WinXP, replace bootmgr in the code with ntldr. In the code below Grub4DOS is used to map contiguous files WinVBlock.ima, Win7Pro.iso and Win7Pro.vhd as sector mapped disks. It then creates a dummy RAM disk and writes the ISO and VHD file names into it, associating them with the disks. Grub4DOS then starts booting WinPE into RAM from the OS Install ISO, and WinVBlock is auto installed from IMA into WinPE at that step. WinVBlock then reads the ISO and VHD file names from the dummy disk, and replaces associated with them sector mapped disks with file-backed disks thus hot-swapping them. WinPE boot from the mounted ISO then continues, and once booted, it shows Windows Install Menu. Now the IMA, ISO and VHD files, auto mounted by WinVBlock as disks, can be used for OS install. Similar disk hot-swapping technique is used at 1st reboot to finalize OS install, and at regular OS boots to allow Windows boot from VHD.
title Start Win7 Pro install from ISO to VHD find --set-root /Win7Pro.iso # map --mem-min=2G # Sector-mapped disc map /Win7Pro.iso (0xff) find --set-root /WinVBlock.ima map /WinVBlock.ima (fd0) map /WinVBlock.ima (fd1) find --set-root /Win7Pro.vhd # Sector-mapped disk map /Win7Pro.vhd (0x80) # Dummy WinVBlock "parameter" disk map --rd-size=2048 map --mem (rd)+4 (0x55) map --hook # Tell WinVBlock to switch the sector-mapped disks to become file-backed disks write (0x55) #!GRUB4DOSx00v=1x00Win7Pro.vhdx00x80Win7Pro.isox00xFFx00 # Boot the .ISO chainloader (0xff) title Finish Win7 Pro install from ISO to VHD find --set-root /Win7Pro.iso # map --mem-min=2G find --set-root /WinVBlock.ima map /WinVBlock.ima (fd0) map /WinVBlock.ima (fd1) map /Win7Pro.iso (0xff) find --set-root /Win7Pro.vhd map /Win7Pro.vhd (0x80) map --rd-size=2048 map --mem (rd)+4 (0x55) map --hook write (0x55) #!GRUB4DOSx00v=1x00Win7Pro.vhdx00x80Win7Pro.isox00xFFx00 root (0x80,0x0) chainloader /bootmgr title Boot Win7 Pro VHD with WinVBlock find --set-root --ignore-floppies /VHD/Win7Pro.vhd map /VHD/Win7Pro.vhd (hd0) map --rd-size=2048 map --mem (rd)+4 (0x55) map --hook write (0x55) #!GRUB4DOSx00v=1x00Win7Pro.vhdx00x80x00 chainloader (hd0,0)/bootmgr rootnoverify (hd0) boot
4. Start Windows install from ISO to VHD
Using Windows deployment tools ImageX for offline Win7 install to VHD and DISM to inject WinVBlock driver to it is fast and works every time (some call it alternative method), with matching DISM version found in Win Setup ISO Sources folder, and ImageX extracted remotely from Windows WAIK ISO (or use GimageX GUI). You may want to copy ImageX to Win7 Setup ISO or PE, and inject WinVBlock driver to its Boot.wim with DISM (see example below), then proceed:
[*]Boot to Win7 HD, Setup ISO or PE, and mount with Diskpart empty Win7Pro.vhd created in Step 1 as V: drive, and Win7 Setup ISO with WinVBlock as D: [*]List offered on the Setup ISO OS image versions: Imagex /info D:SourcesInstall.wim [*]Select required OS image number and apply it from the ISO to VHD: Imagex /apply D:SourcesInstall.wim 1 V: [*]Add boot environment to the OS on VHD: bcdboot v:windows /s v: [*]Remove V: drive letter from the VHD Volume, remount it to an empty C:VHD folder, and inject the driver to OS on the VHD with DISM: open Console and change directory to Win7 Setup ISO D:sources, then run dism /image:C:VHD /add-driver /forceunsigned /driver:C:WinVBlockWinvblk.inf [*]OR boot to Win7 Setup ISO via Grub4DOS Menu (see Step 3), attach the VHD in Console, choose Repair OS --> Load Driver in Win Setup Menu, and run driver install into offline OS on the VHD: select Winvblk.inf from Winvblock folder on your HD and click OK to install
Or instead you can follow the legacy method to install Windows online to the VHD:
reboot your PC, select Boot Grub4DOS from Windows Boot Menu, then Start Win7 Pro install from ISO to VHD from Grub4DOS Menu. Once the Setup ISO starts loading, it will auto install WinVBlock from a floppy disk or image, then auto attach the pre-made VHD, and proceed with OS install to it. If auto install or hitting F6 doesn't work for you, you must install WinVBlock from a folder and start WinVBlock service manually from Command Prompt (SHIFT+10) after the Setup ISO boots, then use WinVBlock driver commands to attach ISO, IMA and VHD disks if not auto mounted, and proceed with OS installation:
[*]Copy WinVblock.ima content to a new Winvblock folder on your HD C:WinVBlock, copy sc.exe (32-or-64bit matching OS version being installed) to it from your system drive or a mounted with Imagex Install.wim from Win7 Setup ISO. If your OS is 64-bit, sc.exe 64-bit would be in WindowsSystems32 and sc.exe 32-bit in WindowsSysWOW64 folder. Boot Windows Setup ISO with Grub4DOS (using the above Menu section). Press any key to boot from CD or DVD... -> Start hitting F8 repeatedly (for Win7 64-bit only). Windows is loading files... At the F8 menu, choose Disable Driver Signature Enforcement Try hitting F6 and installing WinVBlock at this time. [*]At the first Install Windows window, select Locale settings and click Shift+F10 to open Console at x:sources> type Notepad, click File Open to check mounted drive letters, and see if the VHD, IMA and ISO disks are visible. If not: copy c:winvblocksc.exe x:windowssystem32 copy c:winvblockwvblk32.sys x:windowssystem32drivers [*]Install WinVBlock driver to the running WinPE: sc create WinVBlock binPath= x:windowssystem32driverswvblk32.sys type= kernel start= boot group= "SCSI miniport" drvload c:winvblockWinvblk.inf net start WinVBlock [*]Switch back to Notepad and reopen File Open to see, if VHD, IMA and ISO disks are now visible. If not, you could: - attach an .ISO with: winvblk -cmd attach -m c -u c:Win7Pro.iso - or a floppy disk image with: winvblk -cmd attach -m f -u c:WinVBlock.vfd - or an HDD or VHD image with: winvblk -cmd attach -m h -u c:Win7Pro.vhd You might need to repeat the attach commands a few times until successful, and wait each time for the result [*]Return to Windows Setup with the command below or just click its window. x:setup Wait for Win Setup to recognize all mounted drives, then proceed with OS setup to VHD. You might need now to install WinVBlock to OS on the VHD by clicking Load Driver in Win Setup Menu and pointing to Winvblk.inf, if OS can't auto install it from WinVBlock.ima at this time, or after 1-st reboot (with or without pressing F6) to finish setup [*]Contents of your WinVBlock floppy and folder: WinVBlk.cat WinVBlk.exe WinVBlk.Inf WVBlk32.sys sc.exe txtsetup.oem
5. Finish Windows install from ISO to VHD & Boot the VHD
Reboot the PC, start Grub4DOS again from Windows Boot Menu, and select Finish Win7 Pro install from ISO to VHD from Grub4DOS Menu. If WinVBlock was installed correctly onto OS in Step 4, the setup will continue without errors, and other required system drivers and components auto installed to the OS on VHD. Your PC may need to reboot one or more times during OS setup. Once finished, you can boot the VHD with Grub4DOS by selecting Boot Win7 Pro from VHD menu.
Depending on installed OS version, most reported success with WinVBlock loading Win Setup ISO as Filedisk, some used instead for online OS install FiraDisk loading the ISO into RAMDrive. Approach is similar for both drivers, while FiraDisk method details can be found in its section on this forum. The advantage of using WinVBlock shows up on PCs with limited RAM, since it doesn't require Setup ISO and Win7 VHD being loaded into RAM. Booting an unsupported for native boot from VHD 64-bit OS version requires Testmode activated and WinVBlock or FiraDisk signed with Test Certificate, since both drivers remain unsigned. One may digitally Test Sign a driver and activate Test Mode with Driver Signature Enforcement Overrider, or press F8 at OS boot. Booting Win7 32-bit doesn't require signed drivers and active Test Mode.
Grub4DOS currently supports mapping fixed VHDs, while Vboot supports fixed and dynamic VHD types, and has signed drivers, but its not free. Its also possible to indirectly boot via Grub4DOS dynamic VHDs with unsupported for native boot OS version and WinVBlock or similar driver installed by using VHD Loader:
- Place VHD Loader onto a DOS floppy
- Boot that floppy with Grub4DOS
- Run VHD Loader to select a dynamic VHD from your FAT32 formatted hard drive and boot OS from it.