Install Windows from a USB disk

Procedure for creating a USB mass storage device that will install Windows Vista or Windows 7:

  1. Create an MS-DOS partition table
  2. Create a primary partition with type 0x07 and the active flag set
  3. Create an NTFS filesystem on the partition
  4. Copy the contents of the Windows DVD to the filesystem
  5. Install a boot loader onto the disk
  6. Ensure that the NTFS filesystem contains a suitable boot record
    • NtfsProgs does this automatically (you must be using version 2.0.0 or greater)

    • If you're using Windows, run bootsect /mbr X:

At boot time, tell your BIOS to boot off the USB disk as if it were a hard disk (it's also possible to boot from USB as if it were a floppy disk/zip drive/CD-ROM... these won't work with the above procedure). Assuming everything goes well:

  1. The BIOS will execute the disk's boot sector
  2. The boot sector will execute the active partition's boot record
  3. The boot record will execute the Bootmgr file copied from the Windows DVD

The Mystery of the "Suitable Boot Record"

I was quite surprised that my USB disk was bootable at all, as I did not understand where the code that read the Bootmgr file from the NTFS filesystem came from. It turns out that mkntfs creates it as part of the filesystem; it copies the contents of boot_array to the start of the partition. The structure of the first 512 bytes of this array is described in NTFS_BOOT_SECTOR. I can't find any corresponding source code for the blob, but its purpose is obvious if you look through the strings embedded within it:

You have to have version 2.0.0 of NtfsProgs for this to work, because in prior versions a different boot_array is used. This presumably is suitable for booting Windows NT/2000/XP, as its strings reference the NTLDR file present in those versions of Windows:


CategoryTechnote

robots.org.uk: WindowsInstallFromUSB (last edited 2020-01-17 09:28:45 by sam)

© Sam Morris <sam@robots.org.uk>.
Content may be distributed and modified providing this notice is preserved.