Tuesday, September 4, 2012

Making a Universal Windows 7 SP1 USB Installer

I used a usb stick to install Windows 7 64 bit Home Premium and Professional on my new sony laptops.  It works on both bios and uefi machines.  You'll need a couple things in order to do this.
  1.  A 4gb or larger usb stick
  2. A Windows 7 Ultimate x64 iso (download is provided later)
  3. A bootmgfw.efi file from a working windows installation or from online
I followed two different guides to get it to work on both bios and uefi machines.
I tried the Microsoft USB/DVD download tool, which I don't recommend using.  I also used an ei.cfg iso removal tool from http://code.kliu.org/misc/winisoutils/.  This is also unnecessary.  

First, here are some things that did not work.
  1. I've used the ei.cfg removal tool in the past.  It is supposed to set a flag so that the ei.cfg file does not get written when burning a dvd.  It worked before.  Now that I was extracting the files to usb, the flag was not honored.
  2. The MS USB/DVD download tool will burn the iso file to a usb drive or dvd.  I used it to write the iso to my usb stick.  It wrote the files just fine, but it formats the drive to NTFS.  This will not work with uefi machines.  I tried to format the usb stick to fat32 and then run the MS tool, but it reformatted to NTFS.
Here are the steps I used to get a univeral (any version of Windows 7 x64) usb installer that works with bios or uefi machines.
  1. The first step is to download the Windows 7 Ultimate x64 iso from http://msft.digitalrivercontent.net/win/X17-24395.iso
  2. I prepped the usb drive following the guide at Maximum PC.
    1. Format to fat32
    2. Open admin cmd prompt
    3. Run diskpart
    4. Type "listdisk" and find the usb stick
    5. Select the disk with "select disk X" where X is the disk number from listdisk
    6. "clean" - removes all partitions
    7. "create partition primary" - creates a new primary partition
    8. "select partition 1" - selects the new partition
    9. "active" - makes partition 1 active
    10. "format fs=fat32" - this is different from the guide, which uses ntfs
    11. "assign" - to give the usb stick a drive letter.  It might get one automatically after formatting.
    12. "exit" - exits diskpart
  3. I extracted the files from the iso to a folder on my computer.
  4. There is a great utility in the Windows 7 installer to create a bootable usb drive.  In the boot directory, there is a utility called bootsect.exe.  In the command prompt, cd to the boot directory and type the following, where x is the drive letter of the usb stick:
    c:\temp\win7\boot>bootsect /nt60 x:
    This will create a bootable fat32 usb stick.
  5. Copy the extracted files to the usb drive.  This will give a usb stick that will install Windows 7 Ultimate x64 on bios machines.
  6. Remove the ei.cfg file from the usb stick.  It will be in the sources folder.  The ei.cfg file tells the installer which version of Windows 7 to install.  Without it, it will ask the user during install.  Now you have a usb stick that will install any version of Windows 7 x64 on bios machines.
  7. Two more things need to be done to get this to boot on an uefi machine.
    1. Copy the "boot" folder under efi\microsoft to the efi directory so that it is efi\boot.
    2. From a working Windows 7 machine, copy c:\windows\boot\efi\bootmgfw.efi to usb stick\efi\boot.  If you don't have a working Windows 7 machine, you can find the file online.
Now, the usb stick should boot on any machine and install any version of Windows 7 x64.  You'll have to provide your own valid key.  I was able to install Windows in under 10 minutes using an old usb stick.

No comments:

Post a Comment