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.
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.
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.