Jump to content











Photo
- - - - -

install win7 from vhd - only idea! - not tested!


  • Please log in to reply
7 replies to this topic

#1 sara - pmedia

sara - pmedia

    Frequent Member

  • Lady
  • 174 posts
  • Location:tel aviv
  •  
    Israel

Posted 17 June 2011 - 01:24 PM

I thought of an idea that can allow installation of multiple versions of Windows7/vista/2008 from a same removable disk without the need for pressing commands to load drivers (firadsk/winvblk)...

Have not yet tried ... So if it is impossible please spare me the useless work :dubbio:


my idea its simple.

ufd > bootmgr > boot\bcd > list of multiple vhd'S contains win7 setup
i want use easybcd/bootice to edit bcd and start the setup from the vhd'S....

is this poseble??

my multiboot usb So perfect but lacked one thing, I have to create a separate partition for each version of windows 7 setup and I'd like to make it run all from one partition without typing commands

#2 cdob

cdob

    Gold Member

  • Expert
  • 1438 posts

Posted 17 June 2011 - 03:37 PM

ufd > bootmgr > boot\bcd > list of multiple vhd'S contains win7 setup

Yes, that's possible.
Thanks for the reminder. I prepared a example, but forgot this already.

Drawback: flat boot files are inside VHD file.
You need OS USB boot environment.
To clarify:
Default installtation loads boot.wim t RAM.
Booting dosn't use USB boot environment.
A loaded PE may read USB flash after boot finished.

Enable Windows 7 native USB/VHD boot registry settings.
http://reboot.pro/14...post__p__127772

Use a NTFS partiton inside VHD image and imagex to extract files.
This preservers hardlinks and saves space.
In addition you may use NTFS compression.

As for booting: a fast USB flash is recommended.
That's fast access to single files, max speed is less importand.
I'm using a USB SSD drive.


Step 1: Create a VHD

diskpart

create vdisk file=C:\Boot\w7.vhd maximum=3600 type=fixed

select vdisk file=C:\Boot\w7.vhd

attach vdisk

create partition primary

assign letter=v

format quick label=VHD

exit


Step 2: Apply a Windows 7 boot image
Use ImageX to apply the boot.wim file to the primary partition of the VHD.

imagex /apply \sources\boot.wim 2 v:\

space requirements, approximately double boot.wim at NTFS:
duplicate files are restored as hard links
delete *.log*

finddupe -hardlink v:\
http://www.sentex.ne...andel/finddupe/

NTFS compress files in addition.

Example: boot.wim 140MB
imagex: 620MB, hard links 440MB, NTFS compressed 280MB


Step 3: Copy install.wim to VHD image
copy \sources\install.wim v:\sources

Step 4: Copy bootmgr to hard disk and add bcd file

Step 5 at USB:
Enable Windows 7 native USB/VHD boot environment.
http://reboot.pro/14...post__p__127772

Resulting layout, U: USB drive

U:\bootmgr
U:\Boot\BCD
U:\Boot\w7.vhd


w7.vhd contents

boot.wim Index 2 expanded
x:\Program Files
x:\ProgramData
x:\sources
x:\Users
x:\Windows

x:\sources\install.wim


Launch add_vdh_entry.cmd at directory U:\Boot\
@ECHO OFF



Rem Set BCD (boot configuration data) for VHD install



path ..;%path%

set BCD="BCD"





call :add_RE \Boot\W7.vhd "Windows 7 VHD Install x86/x64"



BCDedit.exe /store %BCD% /enum all /v



goto :eof





:add_RE

 for /f "tokens=1-3" %%a in ('BCDedit.exe /store %BCD% /create /application OSLOADER') do set guid=%%c

 BCDedit.exe /store %BCD% /set %guid% description "%~2"



 BCDedit.exe /store %BCD% /set %guid% device vhd=[locate]%1

 BCDedit.exe /store %BCD% /set %guid% osdevice vhd=[locate]%1

 

 BCDedit.exe /store %BCD% /set %guid% systemroot \windows

 BCDedit.exe /store %BCD% /set %guid% path \windows\system32\boot\winload.exe

 BCDedit.exe /store %BCD% /set %guid% detecthal Yes

 BCDedit.exe /store %BCD% /set %guid% winpe Yes

 BCDedit.exe /store %BCD% /displayorder %guid% /addlast

goto :eof


Vista dosn't support VHD boot.
But you may use a extracted Windows 7 boot.wim and add Vista installation files.
Include Vista setup files and install.wim.


@all
How to use boot.wim inside VHD file?

#3 cdob

cdob

    Gold Member

  • Expert
  • 1438 posts

Posted 19 June 2011 - 09:17 PM

VHD files allows differential images.

A base VHD file does contain windows 7 boot environment.
A differential image does contain installation files.
You may use one base VHD file and several different installation VHD files.


create base VHD file
diskpart

create vdisk file=H:\boot\Inst_Base.vhd maximum=3800 type=EXPANDABLE

select vdisk file=H:\boot\Inst_Base.vhd

attach vdisk

create partition primary

assign letter=B

format fs=ntfs quick compress label=Inst_Base

Apply Windows 7 boot.wim index 2.
imagex /apply \sources\boot.wim 2 B:\
Next delete directory B:\sources.
Set Windows 7 native USB/VHD boot environment.

Inst_Base.vhd contents

Program Files
ProgramData
Users
Windows
setup.exe


Create a differential VHD file
create vdisk file=H:\boot\Inst_W7.vhd parent=H:\boot\Inst_Base.vhd

select vdisk file=H:\boot\Inst_W7.vhd

attach vdisk
Copy Windows 7 <DVD>\sources folder to VHD image.

Add Inst_W7.vhd to bcd configuration file.

Create more installation VHD file. Recognice the same file Inst_Base.vhd is used.
create vdisk file=H:\boot\Inst_Vista.vhd parent=H:\boot\Inst_Base.vhd

create vdisk file=H:\boot\Inst_2008.vhd parent=H:\boot\Inst_Base.vhd

create vdisk file=H:\boot\Inst_2008R2.vhd parent=H:\boot\Inst_Base.vhd
And copy relating <DVD>\sources folder to VHD image.

That way you configure boot VHD once and use different instllation VHD files.

#4 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 12 November 2011 - 03:42 PM

cdob

I wonder, if a single universal Win7 installation VHD can be made to offer installing any Win version based on user's choice similar to installing ANY Win version from a single DVD or ISO?

OR, making a combo of Base and several Dif VHDs is the only choice to install various Win 7 versions - why exactly? Is it mandatory to specify a volume number within the .wim file in ImageX?

Also, you linked a file to Enable Windows 7 native USB/VHD boot environment, but it seems to work if Windows is directly installed on a USB Thumb, and then a VHD is copied to that Thumb. What if one copies a Win 7 VHD to an empty Thumb? Is it possible to use the same file to mod the Registry and Win install inside VHD instead of on the host drive? OR, can you mod your file, so that it can be used inside the VHD, thus allowing Bare Metal Native VHD Boot from USB?

#5 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 13 November 2011 - 01:38 PM

Another question is, how to add only Win7PE to a native boot VHD, but nothing else (to minimize VHD size), when there is no need to later install Win 7 from that VHD, but only use it for service tasks?

#6 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 15 November 2011 - 12:11 AM

I tested linked above cdob's cmd file that enables Windows 7 native USB/VHD boot environment, and it works well for Win7 VHD placed on an empty USB HDD drive with Win 7 boot environment added to the drive. One must run the file after booting from a different Win7 install and attaching the Win7 VHD you want to modify. It also works well for Win Server 2008R2 - its VHD boots natively from an empty USB drive after the same mod (but not without it). :clap:

I didn't try it on a USB Thumb though, but the result should be similar. Also tested a standalone Win7PE.vhd, and it doesn't boot without boot.wim present in the VHD. :cold:

#7 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 16 November 2011 - 12:36 PM

space requirements, approximately double boot.wim at NTFS:
duplicate files are restored as hard links

delete *.log*

finddupe -hardlink v:
http://www.sentex.ne...andel/finddupe/

NTFS compress files in addition.

Example: boot.wim 140MB
imagex: 620MB, hard links 440MB, NTFS compressed 280MB


Windows files are protected by Trusted Installer service. No way to use finddupe to remove duplicates, when I tried it. Also compressing NTFS doesn't give such a huge size difference, if any notable, and such compression must be done selectively as some OS files are not recommended to compress. Not sure, if NTFS does it selectively on its own, if the whole attached VHD drive is compressed, but it may slow down OS running from VHD.

"Compression is not recommended by Microsoft for files exceeding 30MB because of the performance hit.
The best use of compression is for files which are repetitive, written seldom, usually accessed sequentially, and not themselves compressed. LOG files are an ideal example. Compressing files which are less than 4kB or already compressed (like .zip or .jpg or .avi) may make them bigger as well as slower. Avoid compressing executables like .exe and .dll (they may be paged in and out in 4kB pages). Never compress system files used at bootup like drivers or NTLDR or winload.exe or BOOTMGR.
"

#8 cdob

cdob

    Gold Member

  • Expert
  • 1438 posts

Posted 16 November 2011 - 04:57 PM

Windows files are protected by Trusted Installer service. No way to use finddupe to remove duplicates, when I tried it.

Then use a system without Trusted Installer service: XP or a PE.
And grant yourself permission to access files, e.g. takeown.exe, iacls.exe, subinacl.exe

Also compressing NTFS doesn't give such a huge size difference

That's a personal choice. This depends at available storage space, RAM usage and




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users