47 - How to install Windows Vista/7/SVR2K8 onto a USB drive (or any partition)
NT6_Fast_Installer.zip History: 2011-9-10 New version of NT6_Fast_Installer.zip available (fixes 'bootsect.exe not found' error).2012-11-08 New version of NT6_Fast_Installer.zip available (bcdboot error Status = c000003a fixed if using an EFI Windows system to prepare the USB drive with - found by James Leyden - thanks James!).
2012-11-15 Revised to use either Win7 bcdboot or Win8 bcdboot.
PLEASE NOTE: I highly recommend Win8ToGo instead of running Windows 7 from a USB drive. To boot Windows 8 from USB - please see Tutorial #53. Win8ToGo is designed to run from a USB drive and supports USB 3.0 booting - it will be far more 'stable' than Win7ToGo.
Please note: This tutorial enables you to prepare a USB drive so that you can boot directly to Windows 7 from the USB drive. So now you can try Windows 7 without needing to install it onto your internal hard disk! IT WILL ONLY WORK ON A USB 2.0 PORT (see instructions at the end of this page for instructions on how to add USB 3 drivers).
NEW! You might like to try WinToUSB which make it very easy to prepare a bootable USB drive containing Win7/8/10 To Go. For 'Removable' USB flash drives, be sure to choose the VHD option (for Win8/10) or it won't boot!
This tutorial does not make a Windows installer USB drive, it actually puts a copy of Windows 7 onto a USB drive and makes it bootable. When you have made it, you can boot from it as follows:
- Connect the prepared external USB drive (hard disk or Flash drive) to the target system (use a USB 2.0 port NOT a USB 3.0 port!)
- Switch on the system
- Select the USB drive as the boot device in the BIOS boot menu
- Now allow the system to boot to Windows 7 directly from the USB drive.
- it does not matter what is on the internal hard disk of the target system, even if the internal hard disk is broken/not working.
This tutorial as based on fujianabc's Reboot.pro forum post 'NT 6.x fast installer: install Win7 directly to USB external drive' and his excellent scripts (now with reg tweak by 'cdob' from reboot.pro -USBBootWatcher is no longer required). The instructions in that forum post #1 & #2 and some of the prompts in the installer.cmd file that fujianabc provides were however confusing and potentially dangerous (you could accidentally corrupt your system drive) - so I have slightly modified his script to make it clearer and easier to use. It also now automatically finds and uses the 3 files that are needed from the MS WAIK, so you don't need to manually copy them first.
The instructions below assume that you have a USB drive (USB Hard Disk - recommended, or USB Flash drive - slow!) and you want to install Windows 7 onto it using a Windows 7 install DVD (or ISO file) as the source. You can use any 32/64-bit mix - e.g. use a Windows 7 64-bit PC to install say Vista 32-bit OS from a Vista 32-bit installation DVD onto a USB drive, or use a Windows XP system to install Windows 7 64-bit onto a USB drive using this method. Note that some CPUs' (e.g. some netbook Atom 32-bit CPUs) won't run a 64-bit OS, so a 32-bit version of Windows 7 is usually best for these.
Note that there are some pitfalls with this Windows USB drive once you have successfully made it:
- You will need to activate Windows using a valid Product Key (which will be locked to the hardware you booted it on) if you want a fully functional version of Windows for over 30 days
- You cannot just plug the USB drive into another system. If you want to move it to another system (once you have booted it on one system) then you need to sysprep it (see ADDENDUM at the end of this page). This is because on first boot, a fresh copy of Windows will detect what hardware is on the system and install the correct drivers (including the drivers for the boot drive). If you try to boot that USB drive on another system without running Sysprep, you may just get a BSOD (0x0000007B blue screen of death error).
- No drivers are included in the image if a plain Windows installation DVD is used as the source DVD. You will need to install drivers once Win7 is booting.
- A USB Flash drive will be quite slow (1-2 hours!) to install and run Windows from, unless you use a fast USB 3 Flash drive, such as BUSBI Boost USB 3 (even on a USB 2 port, USB 3 Flash drives are usually faster than USB 2 drives, but not, of course, as fast as a standard USB hard drive or USB 3 drives on USB 3 ports). I highly recommend you use a USB hard drive or a USB 3 Flash drive.
- Windows 7 does not contain many USB 3 compatible drivers - so if you try to boot from a USB 3.0 port it will probably crash!
Alternatively - using this method, you could remove an internal hard drive from a system, connect it to your main PC (either directly or using a USB drive caddy), format it and install Windows onto it using the Installer.cmd script in the tutorial, and then put the hard drive back into the original system (or a different system) and boot it.
The procedure below works and has been tested using an ISO of the RTM/Gold version of Windows 7 and the SP1 version of Windows 7.
To install a bootable Windows 7 (or Vista or Win2K8) OS onto an external USB drive.
You need to follow this tutorial using a Windows PC (or possibly by booting to WinPE v2 or v3).
The Windows files are taken from a source installation DVD or a mounted ISO file. If you do not have a Windows 7 source DVD, you can download an ISO file (see External Links page)
- A USB hard drive of at least 10GB NTFS formatted (which may be wiped during this process). A Flash drive can be used but it will be slow!
- The whole Microsoft WAIK for Windows 7 installed (or at least the files bootsect.exe, bcdboot.exe and imagex.exe) or see Tutorial #83 for a method of obtaining these files in about 30 seconds without needing to download and install the whole WAIK (Note: Download the Windows 8 WAIK files, the Win 7 WAIK download does not contain bootsect.exe).
- The NT6_Fast_Installer.zip download from the Downloads page
- A Windows 7 installation DVD (or ISO file which you can mount as a drive letter) - see here to download a copy of Windows 7.
- (optional) RMPrepUSB to partition the USB hard drive
The system you use is assumed to be a Windows 7 system, although if you install the WAIK, these instructions should work on an XP system or later OS.
1.You need to have a source DVD or a mounted ISO file (mounted as a drive letter). If you only have an ISO file, you can use SlySoft Virtual Clone Drive or ImDisk or any similar software to mount the ISO as a drive volume - e.g. O:. This allows the script to access the files within the ISO file as a drive letter.
2. You may need to partition and format the target USB disk using RMPrepUSB if it is not already formatted as NTFS. Even if it is formatted as NTFS, ensure the partition is 'Active' to make it bootable ('Mark partition as Active' in Windows Disk Manager). It is better and easier to re-format the drive using RMPrepUSB as shown below.
Note: Windows 7 MUST see an Active partition when it first boots - otherwise you will receive a "starting system services" - "Setup could not configure Windows to run on this computer's hardware" error message. Subsequent boots do not seem to need an Active partition present, but on first boot Win7 does! If you try to boot Win7 without an active partition and then reboot it after setting the partition active, it may not work (i.e. it is broken!)
IMPORTANT: The USB disk volume must be formatted as NTFS and must be allocated a drive letter by Windows.
Set RMPrepUSB settings 1 to 5, then click 6 Prepare Drive.
If it fails to format, click on 6 Prepare Drive again.
3. Download NT6_Fast_Installer.zip (works for Win7 RTM/Gold and Win 7 SP1) from the Downloads page and extract the contents to an empty folder on your PC's hard drive - let us say you cretae a new folder on the hard disk is called C:\NT6Inst for the sake of this Tutorial.
4. Download and install the Microsoft Windows 8 WAIK files.
If you don't want to install the WAIK, you will need to manually copy the correct versions of bootsect.exe, imagex.exe and bcdboot.exe (bcdboot.exe is already in Win7) to the C:\NT6Inst folder.
See Tutorial #83 for a method of obtaining these files in about 30 seconds without needing to download and install the whole WAIK. Download the files from the Windows 8 WAIK and copy them to the C:\NT6Inst folder. If you are running on a 64-bit version of Windows (not installing, but actually using a 64-bit version of Windows to prepare the drive) then use the amd64 versions, if you are using a 32-bit version of Windows then use the x86 versions of the tools.
If you are unable to use the GetWaikTools utility, you can also download the imagex/bootsect/bcdboot utilities from the MS download here.
If you already have the Windows 7 or Windows 8 WAIK installed, the 3 files needed will be found and automatically copied to your C:\NT6Inst when you run the Installer.cmd script.
5. Right-click on the file C:\NT6Inst\INSTALLER.cmd and choose Run as Administrator. If any files are missing you will be informed.
6. You should now see a green window with some text. Hit Enter and the Enter again.
7. Now find the Install.wim file on your Windows installation DVD (or mounted ISO volume) - double-click to select it:
8. You will now be presented with a list of different Editions - these were all within the Install.wim file that you selected, choose the one you want to install (remember that you will need an activation key which matches the version you choose, if you want to activate Windows).
9. Now you will be asked to select the target USB hard disk that you want to install Windows onto:
Note: If the USB disk has files on it, the script will try to format it for you, you will need to enter in the volume name to confirm this.
10. Now enter in the same USB drive letter again for the boot partition (use the same USB drive letter again):
11. You will now be asked if the disk is a USB disk - answer Y.
If however, you intend to disconnect the drive and put the drive inside another system (e.g. notebook) before you boot from it, then say No to this question.
12. Unless you have a Vista or Server 2k8 source DVD, you will be asked what drive letter you want Windows to use when it boots from the USB drive. Use the default by hitting Enter.
13. You will now be presented with a final summary screen - hit Enter to start the installation and wait a while.
Check this carefully before you hit Enter!
Note that the Target Drive letters should be the same if your USB drive only has one partition.
Installation completes in just 7 minutes for a USB 3.0 Hard Disk install
Booting the USB drive
Now use the Windows Safely Remove USB Device System Tray icon to dismount the USB drive and then try it on a system to see if it boots!
Don't forget that once you have booted the image on one system, it will probably crash if booted on a different system because the correct drivers for the first system will already be installed on the previous boot.
Once Win7 is running, you will also need to add the correct third-party drivers to get all the hardware working correctly.
To speed up the Windows installation, once booted from the USB drive and in Windows, go to Device Manager and select Disk Drive and double-click on it. Then select the Policies tab and enable the Better Performance (Enable write caching) option.
WARNING: If you have installed the 'Gold RTM' first version of Windows, do not update the version with a Service Pack update (SP1) as this could break the installation - instead re-install using the SP1 ISO/DVD. Normal hotfixes and updates will be OK though.
Pagefile relocation (virtual memory)
If Windows runs out of system memory (RAM) then it normally 'pages' chunks of unused memory to a special file called a pagefile (\pagefile.sys). This means that you can run applications that require say 6GB of memory on a 4GB system.
If you boot Windows 7 from a USB disk on a system that also has a working internal fixed hard disk, then Windows will automatically create and use a pagefile.sys file (a pagefile) on the system's internal hard drive partition. However, this will prevent you from formatting or re-partitioning the internal hard drive (if you wanted to) because the volume containing the pagefile.sys file will always be held 'open' by Windows.
If you boot from a USB Flash drive on a system that does not have an internal Hard disk, Windows will warn you that it cannot create a pagefile - Windows will not create a pagefile on a 'removable' disk.
If you wish to make Windows create the page file on your USB hard drive instead of the internal hard disk in your system, follow the instructions on reboot.pro by karyonix here (and here for the latest 32/64 bit version of diskmod and registry entries). Note that you should NOT use a pagefile on a USB Flash drive as it will be even slower and will also wear out the Flash memory.
ADDENDUM - Booting from a different system
If you want to connect the USB drive to a different system, you may need to sysprep the drive - otherwise it may crash on boot and also could prevent it from booting on the original system again too (changes/corrupts boot files and registry)!
A Sysprep cmd file should be already present on the Windows Desktop, once the system has booted from the USB drive - if you right-click on this and Run as Administrator it will reset and shutdown the system. You can then boot the USB drive on a different system that has different hardware. This sysprep command should run from an administrator command prompt and uses the command: \Windows\System32\sysprep\sysprep.exe /oobe /generalize /shutdown
Once the computer shuts down, you can boot the USB drive on a different system which has different hardware. If you want to move it to another system again or back to the first system, don't forget to run Sysprep again before you move it!
If the BCDBOOT command fails with a [0xC000003a] error Warning: Resource files missing ... then you probably are running the Installed.cmd script on a Windows system that has booted from a UEFI BIOS instead of an MBR BIOS. In this case download bcdboot.exe from the Windows 8 WAIK and replace the version in your C:\NT6Inst folder with the Windows 8 version and run Installer.cmd again.
If you are using a USB HDD drive and Windows 7 boots and shows a 'Performance Options' form, this is due to having no page file. Windows will not create a page file on a removable drive. If you have no internal disk available, you can create a page file on the USB drive using this fix - see http://reboot.pro/9461/#entry86619.
"Setup could not configure Windows to run on this computer's hardware" - Ensure on first boot, there is a partition marked as Active.
Add USB 3.0 Drivers to an Offline Image by Using DISM
I have not tetsed the following instructions and so I cannot vouch that they will work!
Note: You will need to download and install the Windows 7 or 8 WAIK onto your 'office' computer first before you can run DISM.
Before you run Installer.cmd to make the USB drive, you first need to add the USB 3 drivers to the \sources\install.wim file.
First extract the install.wim file from the Windows 7 install ISO onto your hard disk so that it can be modified.
It is suggested that you disable your antivirus software and close all Explorer windows now.
At an elevated (Run as Administrator) command prompt, navigate to the Windows OEM Preinstallation Kit (Windows OPK) servicing folder, and type the following command to retrieve the name or index number for the image you want to modify.
Dism /Get-WimInfo /WimFile:C:\test\images\install.wim
An index or name value is required for most operations that specify a WIM file.
Type the following command to mount the offline Windows image contained in the install.wim file (change the name value to exactly the name of the version you intend to use, as listed).
Dism /Mount-Wim /WimFile:K:\Sources\install.wim /Name:"Windows 7 xxxx" /MountDir:C:\test\offline
Instead of using /Name:"xxx" you can use for instance /Index:2 (for image number 2)
At a command prompt, type the following command to add a specific driver to the image. You will need to have the correct USB 3.0 Windows 7 driver files available for the intended target system(s).
Dism /Image:C:\test\offline /Add-Driver /Driver:C:\drivers\myUSB3driver.INF
Multiple drivers can be added on one command line if you specify a folder instead of an .inf file. To install all of the drivers in a folder and all its subfolders use the /recurse option. For example,
Dism /Image:C:\test\offline /Add-Driver /Driver:c:\drivers\USB3drivers /Recurse
To install an unsigned driver, use /ForceUnsigned to override the requirement that drivers installed on X64-based computers must have a digital signature. For example,
Dism /Image:C:\test\offline /Add-Driver /Driver:C:\drivers\mydriver.INF /ForceUnsigned
Review the contents of the Windows\Inf\ directory in the mounted Windows image to ensure that the .inf files were installed using Windows Explorer. Drivers added to the Windows image are named Oem*.inf. This is to ensure unique naming for new drivers added to the computer. For example, the files MyDriver1.inf and MyDriver2.inf are renamed Oem0.inf and Oem1.inf.
At a command prompt, type the following command to commit the changes and unmount the image.
Dism /Unmount-Wim /MountDir:C:\test\offline /Commit
Now run the Installer.cmd to install Windows 7 to your USB device.
Adding Intel USB 3.0 drivers
I received this email from L. Douglas:
I followed the steps at the end of your tutorial and was able to get the Intel USB 3.0 drivers added in to my install.wim image.
One word of caution: Disable antivirus during this process. It blocked Dism from making the changes it needed to do.
I then was able to install to the USB HDD and it booted fine from USB 2.0 port. Unfortunately, Trying to boot from USB 3.0 port would still bluescreen.
I went into the registry after booting from USB 2.0 and changed:
HKEY_LOCAL_MACHINE -> SYSTEM -> ControlSet001 -> services -> iusb3hub
HKEY_LOCAL_MACHINE -> SYSTEM -> ControlSet001 -> services -> iusb3xhc
for both of those entries, I changed "Start" to "0" and "Group" to "Boot Bus Extender"
This will vary based on the USB3 driver in use, but this worked for the Intel USB3 drivers.
Also see reboot.pro and here.