Making a bootable USB for Windows

Posted on

Problem :

I can’t make a bootable USB for a Windows distribution (XP, 7 8) with a iso image from Linux terminal. I tries with dd but it worked only for Linux distributions. I also tried to make the flash drive bootable by setting the bootable flag with fdisk, mounting the .iso and flash drive, and then copying the files with cp. Is there a difference between these iso images > And if so, how do I determine if the image can be used to make a bootable usb or not ?

Solution :

If you want to only use the terminal, i would rather stick to the manual way. Let’s use Windows 7 as an example:

Note: before starting, please become root by running sudo su

Let’s prepare the USB drive for our purpose:

mkfs.vfat /dev/sdXY

If you encounter -bash: mkfs.vfat: command not found , just issue apt-get -y install dosfstools and repeat the last step.

Next, the ISO image should be mounted, in order to copy the necessary files:

mkdir /mnt/iso

mount -o loop -t udf /path_to_your_image.iso /mnt/iso

Mount the newly formatted USB stick:

mkdir /mnt/stick

mount -t auto /dev/sdXY /mnt/stick

Start copying:

cp -Rv /mnt/iso/* /mnt/stick/

(this will take a while if the image is large and the USB stick is rather slow)

Now, let’s unmount the ISO image:

umount /mnt/iso

To help the boot-loader find the disk, a dummy file should be created:

touch /mnt/stick/roxboot.tag

Now, install a multipurpose boot-loader (GRUB4DOS):

cd ~
unzip ./
cd grub4dos-0.4.4
./ --no-backup-mbr --mbr-disable-floppy /dev/sdX

Note: GRUB4DOS needs a special loader file called GRLDR in order to boot successfully, so let’s copy it:

cp ~/grub4dos-0.4.4/grldr /mnt/stick/

GRUB4DOS uses a configuration file called menu.lst in order to create a boot menu and to present it to the user, so let’s create the file and a menu entry for Windows 7 installation:

touch /mnt/stick/menu.lst
echo "title Windows7 Install" > /mnt/stick/menu.lst
echo "find --set-root --ignore-floppies --ignore-cd /roxboot.tag" >> /mnt/stick/menu.lst
echo "chainloader /bootmgr" >> /mnt/stick/menu.lst

Unmount the USB stick:

umount /dev/sdXY

Now if you want to test it, reboot and instruct your BIOS to boot from USB by altering the boot order or by selecting your stick from the “One-time boot menu”

Note: in /dev/sdXY: X represents a letter assigned by udev when the stick is plugged, and Y a number (usually 1) since your stick has a single partition. If you have a single harddisk, then your stick should be /dev/sdb and the partition we are working on should be /dev/sdb1

P.S.: Greetings from Romania!

Leave a Reply

Your email address will not be published. Required fields are marked *