Intelligence is simply talking to many people

How to make a Windows 7 install USB flash drive using a Linux computer

Making a USB flashdrive Windows7 installer doesn't work easily when you make it with a Linux computer. It seems like it works fine, but when you try to install it, the flash drive appears empty, and doesn't boot to it. You've already made sure BIOS has ‘both UEFI and Legacy’ and has ‘Secure Boot’ disabled, and you've tested your Windows7 iso on a VM like Qemu and it starts the install, so it should work.

The reason probably (most commonly) is that whatever you're using to try to write to your flash drive creates an ISO9660 filesystem that Windows bootloaders don't handle well for installation. It doesn't matter if you try to use Gnome Disk Writer or dd or what. It will seem to write fine, but then in the target computer it isn't detected as anything. You might try NTFS or FAT (the internet will tell you one or the other is the correct way), but it's the same result.

This means that (computer jargon here) after clearing the MBR and setting up the partition, you'll need to install a Windows-compatible MBR boot code to make the drive bootable on BIOS systems. Without it, the drive may still appear "empty" or non-bootable, as you've experienced.

This script worked. As long as your linux machine has the software installed that it depends on (all is FOSS and not compromised, it seems, because I wouldn't use it otherwise, but if you're a tech guardian please re vet it), which includes ms-sys (and I forget if there's anything else, but you'll get error messages to tell you what things if there is).

So I got ms-sys from their https://ms-sys.sourceforge.net/ as a tar.gz and installed it with their instructions (which did give an error message while opening the GUI but worked anyway so you can probably ignore the error message). Ask Grok how to install this if you don't know how. Then our script here should work.

HOW TO USE THE SCRIPT

Open a text editor (like Mousepad or any other), save it as ‘makeaWin7USB.sh’ Note that you're saving it as a .sh not as a .txt or something. That's because it's a script.

Paste our script here into that file and make the necessary changes (there are 2 things you might need to change, the path to your Windows7 iso and your flash drive mount point, and if you don't have the right drive mount point it can erase your system so double check that). Once you've saved this and closed it, Rclick it and go to Properties and checkmark Permissions > Allow this to run as a program. Then open Terminal in the same folder where you have your ‘makeaWin7USB.sh’ and do

sudo ./script.sh

The script will run then, and when it's done it will say so, and you can just pull the flash drive out and put it in your target computer and boot and it should load the Windows 7 install.

...

HERE IS THE SCRIPT

#!/bin/bash
# Script to create a bootable Windows 7 USB on Kali Linux
set -e
ISO_PATH="/path/to/win7.iso"  # REPLACE WITH YOUR ISO PATH
USB_DEV="/dev/sda"  # REPLACE IF USB IS NOT /dev/sda
echo "WARNING: This will WIPE $USB_DEV. Confirm $USB_DEV is your USB (check with lsblk)."
read -p "Type 'yes' to continue, anything else to abort: " CONFIRM
if [ "$CONFIRM" != "yes" ]; then echo "Aborted."; exit 1; fi
if ! command -v ms-sys >/dev/null || ! command -v rsync >/dev/null || ! command -v parted >/dev/null || ! command -v mkfs.ntfs >/dev/null; then
    echo "Error: Install ms-sys, rsync, parted, and ntfs-3g first."; exit 1
fi
if [ ! -f "$ISO_PATH" ]; then echo "Error: ISO file $ISO_PATH not found."; exit 1; fi
sudo umount ${USB_DEV}* 2>/dev/null || true
sudo dd if=/dev/zero of=$USB_DEV bs=446 count=1 status=progress
sudo parted -s $USB_DEV mklabel msdos
sudo parted -s $USB_DEV mkpart primary ntfs 1MiB 100%
sudo parted -s $USB_DEV set 1 boot on
sudo mkfs.ntfs -Q ${USB_DEV}1
sudo mkdir -p /mnt/iso /mnt/usb
sudo mount -o loop "$ISO_PATH" /mnt/iso
sudo mount ${USB_DEV}1 /mnt/usb
sudo rsync -av --progress /mnt/iso/ /mnt/usb/
sync
sudo umount /mnt/iso /mnt/usb
sudo ms-sys -7 $USB_DEV
sudo ms-sys -n ${USB_DEV}1
sudo eject $USB_DEV
echo "Bootable Windows 7 USB created on $USB_DEV. Insert into x230, boot via F12 (Legacy Boot)."

Comments: 0

Interested to discuss? Leave a comment.

Image




Your email will not be published nor shared with anyone. In your text you can use markdown for marking up *italic*, links <http://example.org> and other elements. These comments are moderated and published manually as soon as possible.