Although Windows 7 is long out of support, a friend asked me to assist in recovering his laptop OS, so I put aside my preferences and prejudices to see what I could do to help.
I found many sets of instructions about how to make a bootable USB after copying across the contents of the ISO. However, even the tools that were Linux based were not readily installed on a modern distribution.
I finally realised that Grub was all I required, and the following is a walk-through of the steps taken.
USB Drive Configuration
The drive needs to have sufficient capacity to hold the contents of the Windows 7 ISO (about 8 GiB).
sdX below with the device associated with the USB drive.
The first step is to format the USB drive. The drive is formatted with an
MSDOS partition table, with a single NTFS formatted partition. The label for
the NTFS partition is
W7SP1PRO64 (this will be used later).
$ sudo sfdisk -d /dev/sdX <<EOF label: dos size=7.5GiB, type=7 EOF
$ sudo mkfs.ntfs --fast -L W7SP1PRO64 /dev/sdX1
Copy ISO Content
Mount the ISO image to copy from (replace
win7.iso with the name of your ISO file):
$ sudo mount -r -o X-mount.mkdir win7.iso /tmp/win7-iso
Mount the USB partition to copy to:
$ sudo mount -o X-mount.mkdir /dev/sdX1 /tmp/win7-usb
Copy ISO contents to USB:
$ sudo cp -v -r /tmp/win7-iso/* /tmp/win7-usb $ sync
sync may take a long time, dependent on the speed of your USB port and driver.
Make USB Bootable
Install Grub onto the USB drive:
sudo grub-install \ --target=i386-pc \ --install-modules="normal search ntfs ntldr" \ --locales=uk \ --boot-directory=/tmp/win7-usb \ /dev/sdX
Create the file
/tmp/win7-usb/grub/grub.cfg (the label must match the label
of the NTFS filesystem created above):
insmod ntfs search --no-floppy --label W7SP1PRO64 --set root ntldr /bootmgr boot
Unmount all of the drives, and arrange to boot from the USB drive. If all has gone well, you’ll see the Windows 7 installer.