Install Windows from a USB disk
Procedure for creating a USB mass storage device that will install Windows Vista or Windows 7:
- Create an MS-DOS partition table
- Create a primary partition with type 0x07 and the active flag set
- Create an NTFS filesystem on the partition
I used mkntfs from NtfsProgs
- Copy the contents of the Windows DVD to the filesystem
- Install a boot loader onto the disk
I used MBR
- 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:
- The BIOS will execute the disk's boot sector
- The boot sector will execute the active partition's boot record
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:
A disk read error occurred BOOTMGR is missing BOOTMGR is compressed Press Ctrl+Alt+Del to restart
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:
A disk read error occurred. A kernel file is missing from the disk. A kernel file is too discontiguous. Insert a system diskette and restart the system. \NTLDR is compressed.