To install Windows 7, you need to create a live USB since it is very hard to find compact disc in 2018 anymore. From Debian system however, it is not a easy path. I attempted the conventional Linux way of dd command, unetbootin etc: none of them work out as expected. However, using grub as a bootloader to chain-load the installer's bootloader is definitely working without additional software installations!
The very first step is to download the Windows 7 ISO file from Microsoft. You can download it here:
It will take a very long time depending on your network connection since all OS ISO files are big!
The easiest way is to use lsblk command. This will list out all the partitions accordingly. Find and select the partition containing the root directory.
$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk ├─sda1 8:1 0 243M 0 part ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 931.3G 0 part └─sda5_crypt 254:0 0 931.3G 0 crypt ├─<lvm-name>-root │ 254:1 0 28G 0 lvm / ├─<lvm-name>-swap_1 │ 254:2 0 11.9G 0 lvm [SWAP] └─<lvm-name>-home 254:3 0 891.4G 0 lvm /homesdb 8:16 1 28.7G 0 disk └─sdb1 8:17 1 250M 0 part /mnt/bootloaderIn the example above, we can see /dev/sdb is our target device.
If you notice, the USB drive is mounted on a specified path. You'll need to un-mount all of the partitions from that device before proceeding to install. To do that, we use the umount <path> command. Based on the example above, since we got 1 partition (/dev/sdb1), it is:
$ umount <MOUNTPOINT>Based on the example above, it is:
$ umount /mnt/bootloaderYou can now reformat the USB device with gparted. First, you install gparted software:
$ sudo apt install gparted -y$ sudo gpartedThen follow the following steps:
msdos. This will erase all the contents in the stick.ntfs.Apply" button at the tool bar to start the reformat.WIN7STICK. Remember the name as we need it later.Apply" button at the tool bar to label it.boot" to make the partition bootable. Press OK to close the menu.Apply" button at the tool bar to do whatever that is leftover.gparted. You're done with the device formatting.You can now mount the USB drive back again. Either you can open your file manager to perform an auto-mount. The guide here is for those who wants to perform manual mounting instead.
$ mkdir destination$ mount /dev/<your USB device partition> ./destinationSo, following the example above, you should get:
$ mkdir destination$ mount /dev/sdb1 ./destinationNow you should mount the Installer ISO. We need to copy all the files across into the USB drive. You need root access for this to work:
$ mkdir origin$ sudo mount -o loop /path/to/your/windowInstaller.iso ./originWith everything in place, you can begin the copy process. It takes time so get a cup of coffee. The last step is optional, where I use the diff program to check the differences between the 2 directories. It should not throw any output.
$ cp -r ./origin/* ./destination/.$ sync$ diff --brief --recursive ./origin ./destination # Optional.$After a successful copying, you can unmount it. You might need root access. Just try it out.
$ sudo umount /dev/<partition name>$ rm -r ./originBased on the example, it is:
$ sudo umount /dev/sdb1$ rm -r ./originIf you receive a warning or error that the device is busy, use lsblk again to find and unmount the mount path instead of using the partition name.
With every in place, it's time to install grub bootloader. You definitely need root access for this. Be extra careful because this step can destroy a storage drive if you provide the wrong <target_device>. Use legacy boot:
$ sudo grub-install --target=i386-pc --boot-directory="./destination/boot" /dev/<target_device>Following the example above, we get:
$ sudo grub-install --target=i386-pc --boot-directory="./destination/boot" /dev/sdbNow, fire up your text editor and create a file at ./destination/boot/grub/grub.cfg with the following contents:
default=1timeout=15color_normal=light-cyan/dark-graymenu_color_normal=black/light-cyanmenu_color_highlight=white/blackmenuentry "Start Windows Installation" { insmod ntfs insmod search_label search --no-floppy --set=root --label <USB_drive_label> --hint hd0,msdos1 ntldr /bootmgr boot}menuentry "Boot from the first hard drive" { insmod ntfs insmod chain insmod part_msdos insmod part_gpt set root=(hd1) chainloader +1 boot}Replace the bolded <USB_drive_label> with the label you gave to the USB drive. If we follow the example above, it was the WIN7STICK. Once done. Save it.
With everything in place, you can now unmount the USB drive safely.
$ sync$ umount ./destination$ rm -r ./destinationYou have the USB Installer stick ready. Feel free to use it and install your Windows.
That's all about creating a USB stick for Windows 7 Installer. Keep in mind that Windows7 is a retired legacy operating system so it won't work or boot on most modern laptop, especially those from Intel i3, i5, and so on. You need to find a legacy hardware to support it.