Tuesday 25 June 2019

What are the nuisances of creating a bootable Windows 7 USB drive from linux with ms-sys or dd?

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:




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




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



  1. Install ms-sys.

  2. Check what device your usb media is assigned ( fdisk -l ) here we will assume it is /dev/sdb.


  3. Delete all partitions, create a new one taking up all the space, set type to NTFS, and set it bootable:


    cfdisk /dev/sdb




  4. Create NTFS filesystem:


    mkfs.ntfs -f /dev/sdb1




  5. Mount iso and usb media:


    mount -o loop win7.iso /mnt/iso
    mount /dev/sdb1 /mnt/usb




  6. Copy over all files:


    # cp -r /mnt/iso/* /mnt/usb/




  7. Write Windows 7 MBR on usb stick:


    # ms-sys -7 /dev/sdb




  8. Make sure the write is flushed (be patient it can take a few minutes):


    # sync




  9. 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 to chmod all files to 664 and chown 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 as root and it not affect the data.




  • Has anyone tried this method or some similar like copying the iso with dd ?



No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...