This week a friend of mine had a problem with his laptop, Windows 7 was caught in a boot loop. I wasn't able to fix the bootloop so I decided I was going to format her PC and reinstall Windows on it. She hadn't got a Windows 7 disk with her, so I had to download an ISO. The problem is I only had my netbook with me that, of course, doesn't have a DVD-drive and only has Ubuntu installed. So I needed to create a bootable Windows 7 USB stick from my Ubuntu machine.
Getting Windows 7
She already had an official W7 key but no disk, you can find Windows 7 ISO's through torrent sites, but you never know if they bundle it with "complimentary" software (spyware). So I started looking around for an official download site. Lots of companies apparently let you download the ISO's freely. Remember you can always test Windows legally for while (trial) after that you need to purchase a key. I already had that so I just downloaded the ISO. You can find the ISO's here (the links point to an official MS partner's download links):
Windows 7 x86 English
Mirror 1: http://msft-dnl.digitalrivercontent.net/msvista/pub/X15-65732/X15-65732.iso
Mirror 2: http://msft-dnl.digitalrivercontent.net/msvista/pub/X15-65804/X15-65804.iso
Windows 7 x64 English
Mirror 1: http://msft-dnl.digitalrivercontent.net/msvista/pub/X15-65733/X15-65733.iso
Mirror 2: http://msft-dnl.digitalrivercontent.net/msvista/pub/X15-65805/X15-65805.iso
The ISO's come with every possible Windows 7 installation (home premium,professional,ultimate,...), it just depends on the key you have which features will get unlocked. Choose your appropriate version (32 bit = x86) and download it.
Extracting the ISO to USB
The first things we need to do is download a few packages:
apt-get install ntfs-3g gparted
We need ntfs-3g to be able to make an ntfs USB stick. I also downloaded gparted, because it is a great tool to check these things with. Plug in your USB stick (minimun 4 GB) and open gparted from the menu (or just open a terminal and type "gparted"). Now select your USB drive from the gparted menu and remember your USB name the name /dev/sdX (x can be a different letter):
Then select all the space, right click, select format and then click ntfs. After it finishes we mount our Windows 7 ISO:
mkdir w7 mount yourwindows7.iso w7
It will be mounted as read only, but that's not a problem. Your USB drive should be mounted in /media by default. Copy all the files from w7 to your pendrive (note that you need to close gparted before you can access your USB drive again):
cp -r w7/* /media/someverylonghash/
Now go grab yourself a coffee and a biscuit.
After the download this finishes we need to look for ms-sys, download the tool from scourgeforge. After you downloaded the package untar it:
tar xvf ms-sys-2.2.0.tar.gz #or whatever the latest version may be cd ms-sys make make install
if you get an error, you might be missing either of these three packages, so just run this command:
apt-get install gettext make gcc
After this rerun make and make install and you should have these tools available now. Now we use ms-sys to write a Windows 7 master boot record to our USB drive:
ms-sys -7 /dev/sdX
Replace the X with your usb drive letter you had to remember from gparted.
Congratulations, you have a bootable Windows 7 usb drive. Just plug it in your computer, select boot from usb and install your Windows 7.
If people of MS or digitalrivercontent come along here and want me to take down the links, please send me an email and I will kindly take them down for you. See the about page for contact details.