Saturday, 20 August 2011

How to instal and run windows from a USB Hard disk

This is plain copy paste from the original source so all credits go to person name Vlad0 in the source link (posted at the bottom)



It took me almost 1 month to google out all the necessary info
permitting one to install Windows 7 onto external USB drive.
Two days ago I've succeeded at last in this enterprise.
The key ingredients of procedure permitting to do this
turned out to be:
a) The new MS technology, permitting one
to install Windows 7 on a Virtual Hard Drive (VHD). With no
virtual machine, as a real OS operating on the real hardware.
This technology is described in many sites in internet
(just google "Windows 7 boot VHD" or something of the sort)
b) Tricks found in 2006 by Dietmar from
 http://www.911cd.net/forums//index.php?showtopic=14181
to overcome obstructions to booting of XP from USB devices.
Marv from http://www.911cd.net/forums//index.php?showtopic=22473&st=0
has created a great program, based on Dietmar's ideas, which permits one
booting of both XP and Vista from USB disks. And it turned out,
that the same program (which is indeed a service) works as well
on Windows 7 inside the VHD.
My idea was the following.
a) Free enough space on a partition of an internal hdd
permitting one to create VHD on the free space and
install Windows 7 on it;
b) Boot from Windows 7 on internal hdd and
run the Marv's prog "UsbBootWatcher.exe /install" (freely downloadable
from the link above);
c) Boot from Vista and copy VHD file from internal hdd
to some partition on USB hdd.
d) Add the entry to the boot menu for booting from USB disk.
Now the detailed description of this procedure.
1) I've freed 20G on internal hdd and defragmented the partition.
In fact, it is enough to free 15G only and even less (the whole
Windows 7 64 occupies about 10--11G after installation).

2) Boot from Windows 7 installation DVD;

3) When the menu "Install Windows" appears, press Shift+F10
to switch the command prompt window on;

4) Determine the letter assigned by Windows 7 Preinstallation Environment (WinPE) to the
partition, where You wish to create the VHD file. This step is necessary,
because this letter may be different from the letter assigned by OS
(Vista or XP) to the same partition. For example, if You have a notebook
with a hidden "recovery partition" with no letters assigned to it,
and 2 visible partitions with letters,
then You will see (say) partitions C: and D: under Vista and C:, D:, E:
under Windows 7 installer. And it may turn out that D: under Vista becomes E:
under Windows WinPE. One of the ways to determine the letter
is to run from the command line the commands "C:", "dir", "D:", "dir:" until
You will see the the root directory of the desired partition.
Suppose further that the letter assigned to the partition is E.

5) Run "Diskpart" from the command line;

6) From within Diskpart command prompt run:
"create vdisk file=E:\Win7.vhd type=FIXED maximum=20480".
This will create the VHD file "Win7.vhd" with the fixed size 20M
on the partition D: (as seen on Vista).

7) Run:
select vdisk file=E:\Win7.vhd
attach vdisk
exit
exit
(to close both Diskpart and cmd windows).

8) Now install Windows 7 as usual, by choosing for installation the newly created
virual partition with size 20M of "unallocated space".

9) If the installation succeeds, boot into newly created default "Windows 7" entry
in the boot menu. Download the file UsbBootWatcher.zip from the link:
http://www.911cd.net/forums//index.php?act=attach&type=post&id=1147
and unzip it somewhere (the preferred place for it is C:\Windows\system32,
but You can create a separate folder for the purpose and unpack it there).
Then run "UsbBootWatcher.exe /install" from inside the folder, where
UsbBootWatcher.zip was unzipped.
This operations made the current Windows 7 installation transferrable
to both real partition on a USB hard drive or to VHD partition on that drive.
I've decided to copy the installation to VHD instead of on the real partition.
For the purpose:

10) Boot into Your original Vista/XP and copy the file D:\Win7.vhd to the partition
on USB disk (say H: for definiteness, as it was in my case). We could as well copy
this file from within Windows 7 (placed inside the VHD file itself!), but it is a bit dangerous,
because the VHD file itself would change many times during the copy operation, just because
say, some of the programs would write something to the registry, etc.

The last thing remaining to do is to add the VHD on the USB drive to the boot menu.
The simplest way to do this is, imo, the next one:

11) Boot again from the Windows 7 installation DVD and switch on the command line prompt
as in step 3 (Shift+F10). Determine the letter assigned by WinRe to the USB drive partition H:
(as in step 4). Suppose it is I:.

12) Run from the command prompt:
diskpart
select vdisk file=I:\Win7.vhd
attach vdisk
exit
In the MS guide
http://technet.microsoft.com/en-us/library/dd638420.aspx
(at the end of which is described, by the way, an alternative method
to add VHD to the boot menu) it is recommended to run,
after "attach vdisk", the command like
"assign letter=v" to assign letter to the attached vdisk.
But I discovered that this command does not work
for some reasons. Nevertheless, some letter is already assigned
to this vdisk by the operation "attach vdisk".
To determine this letter experimentaly go again to step 4 or use a simple
arithmetic (it will be the next letter after assigned to all other drives).

13) Suppose that the letter assigned to the attached vdisk is J:
Run the commands:
J:
cd Windows\System32
bcdboot J:\Windows
exit
Now the Windows 7 on the USB VHD drive is added as the default entry
with name "Windows 7" to the boot menu.

14) Cancel the installation of Windows 7 and reboot.
That's all.
Now You will have 2 "Windows 7" entries in the boot menu, both named
"Windows 7". One (default one) is on the USB VHD, another one -- on internal VHD.
You can (with BCDEDIT tool of Windows 7) delete, if You wish, the internal VHD
from the boot menu or just rename it. You can as well to extend the VHD file
on the USB drive with DISKPART in case, where it will become too small after
installation of some "heavy" programs, occupying several G of space.
But You can as well install such programs outside the VHD, on real partitions.
And the good thing is that many 3D games (like HL2, Fear, Doom3) installed under
Vista or XP need no reinstallation at all under Windows 7: they will run OK
from where they are.



Source : http://social.technet.microsoft.com/Forums/en-US/w7itproinstall/thread/8f381e7f-77d2-4739-a072-7e1becfca506/