I have been reading some web pages and posts (here and in other forums) about how to create a Windows 7 installation USB media from linux (to install Windows 7)
I asked in TechNet about this, and I got a reply with general information on how to do it:
"I personally am not very familiar with
linux, but basicaly all that you need
to do… in whatever way you do it is
the following:
Format a usb flash drive, either fat32
or ntfs create a partition that is
large enough to host the windows
installation (give or take 3GB for
64bit, aroudn 2.5gb for 32bit) and
mark that partition as
active/bootable. Since this can be
done with windows, but just as well
with a tool like gparted, you should
be able to do the same in debian.Once you have created that partition,
mount the iso that you download, and
copy all files starting from the root,
into the root of the usb flash drive.That's all there's to it."
I found another method in various places, that is almost the same what was mentioned at TechNet. However, there seems to be a missing step in this method and/or a step that I'm not sure is necessary.
dd
doesn't always work. Basically, the missing step was to write a proper boot sector to the usb stick, which can be done from linux with ms-sys
. This works with the retail version of Windows 7
.
Here is the complete rundown, see serverfault question for more details:
- Install ms-sys.
- Check what device your usb media is assigned (
fdisk -l
) here we will assume it is/dev/sdb
. -
Delete all partitions, create a new one taking up all the space, set type to NTFS, and set it bootable:
cfdisk /dev/sdb
-
Create NTFS filesystem:
mkfs.ntfs -f /dev/sdb1
-
Mount iso and usb media:
mount -o loop win7.iso /mnt/iso
mount /dev/sdb1 /mnt/usb
-
Copy over all files:
# cp -r /mnt/iso/* /mnt/usb/
-
Write Windows 7 MBR on usb stick:
# ms-sys -7 /dev/sdb
-
Make sure the write is flushed (be patient it can take a few minutes):
# sync
-
open gparted, select the USB drive, right-click on the file system, then click on "Manage Flags". Check the 'boot' checkbox, then close
…and you're done.
Questions
-
Shouldn't the usb work without doing the last step
# ms-sys -7 /dev/sdb
? Or is it to make the usb bootable? Does it only to mark the partition as bootable? -
Wouldn't it be better use rsync instead of
cp -r
? -
Do all this steps have to be done as
root
? If not, do I need tochmod
all files to664
andchown
all the directories that are used to mount the USB device and the ISO image? I suppose that it's just easier to copy the data asroot
and it not affect the data. -
Has anyone tried this method or some similar like copying the iso with
dd
?
Best Answer
The
ms-sys
command is important. With the-7
option it creates a Windows 7 compatible boot sector on your flash drive.You can't use dd because ISO's use an ISO Filesystem such as UDF or ISO9660, where-as your USB drive only properly supports disk file systems such as ext3, FAT32, or NTFS
Not really.
cp -r
works perfectly fine. Just realize that NTFS handles permissions differently to Linux, so using rsync to keep everything intact doesn't matter too much. All that really matters is that the files from the ISO are on the USB and that the boot sector is formatted correctly usingms-sys -7
You can do all the steps as root if you want. The only 2 steps that really require root are
mkfs
and the 2mount
'sIf you're getting permission problems even as root, you may need to mount your USB using
ntfs-3g /dev/sdb1
as some Linux Distributions only supply a Read-Only driver for NTFS.