reversed(top()) code tags rss about

How to make bootable win7 installation USB stick in GNU/Linux

September 18, 2014
[howto] [gnu/linux] [hardware] [boot] [windows]

For most bootable ISO images one of two approaches works:

  1. dd if=image.iso of=/dev/sdx if image is a hybrid CD-ROM/HD image.
  2. Extracting image via UNetbootin.

However, none of this works for Windows setup disks, even if you do this on Windows. Usually I go with UltraISO’s “Write hard drive image”, which works fine. But there is no UltraISO for GNU/Linux and one has to go another road.

The most useful information I found was in this thread on LinuxQuestions, but everything worked for me only on the third try, so I though of archiving working sequence of steps and a way to test them without rebooting machine here.

The main problem with Windows installation is absence of boot loaders in correct places, for this there is trully nice ms-sys utility out there. It’s capable of installing various Windows boot loaders on your request, so be sure to have that installed.

Boot loaders need to be installed on partitions of supported type, so USB stick should be properly partitioned. Simply formatting whole USB stick as VFAT partition or making separate partition and formatting it as VFAT didn’t worked for me, so I did the following:

  1. Removed partition table (I used fdisk to remove all for primary partitions by pressing d<enter>1<enter>d<enter>2<enter>d<enter>3<enter>d<enter>4<enter>, but there are other ways, e.g. using dd).
  2. Created new partition (using fdisk).
  3. Marked it as bootable (used cfdisk if that matters).
  4. Formatted partition as NTFS (# mkfs.ntfs /dev/sdx1).
  5. Installed NTFS boot loader (ms-sys -n /dev/sdx1).
  6. Installed MBR boot loader (ms-sys -7 /dev/sdx).

With this done, all that’s left is to copy files from Windows ISO image:

  1. mount win7.iso /media/cdrom -o ro,loop
  2. mount /dev/sdx1 /media/disk
  3. cp -r /media/cdrom/* /media/disk/
  4. umount /media/cdrom
  5. umount /media/disk

Not it should be ready for testing using QEMU. Install it and run:

qemu-system-x86_64 -m 1024 -hda /dev/sdx

-m 1024 is to give VM 1 GiB of RAM, because Windows installation fails to start with default amount of memory (128 MiB). It’s not really important, if you see an error saying something like Not enough memory, then USB stick works.