This article describes how to make a bootable Windows 10 USB drive using ms-sys program on Linux System. SLAX Linux is used here because of its small size (about 300 MB), and a user doesn't need to use sudo or su commands, the default user is always root. The program ms-sys allows to write boot records for Microsoft Operating Systems.
The order of some operations is not important. For example, partitioning and formatting operations can be done in the very beginning of the process.
SLAX Linux was used as Live CD, it can be downloaded from this site site: www.slax.org
slax-32bit-9.9.1.iso 270 MB (MD5 = 2080064cc623510e7c271971734621ae) or
slax-64bit-9.9.1.iso 264 MB (MD5 = 83530678bef78d31e62d4ff0acf17bf7)
or any other working Linux system can be used.
Download Windows 10 Disk Image (ISO File) from www.microsoft.com/en-us/software-download/windows10ISO (this site allows you to download ISO files only if you are not using Windows 10, the site identifies your Operating System by your browser's user agent information). If you are a member of Windows Insider Program, you can download an ISO File from this link: www.microsoft.com/en-us/software-download/windowsinsiderpreviewiso. Save the ISO to a hard drive or an USB device.
Now find out your USB device on Linux using this commands:
root@slax:~# fdisk -l
Or
root@slax:~# lsblk
Or
root@slax:~# blkid
See a disk in the output for fdisk command:
Disk /dev/sdb: 7.2 GiB, 7747397632 bytes, 15131636 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x12f87fba Device Boot Start End Sectors Size Id Type /dev/sdb1 * 63 15130079 15130017 7.2G b W95 FAT32
The output for lsblk command:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 85.1M 1 loop /run/initramfs/memory/bundles/01-core.sb loop1 7:1 0 36M 1 loop /run/initramfs/memory/bundles/01-firmware.sb loop2 7:2 0 28.3M 1 loop /run/initramfs/memory/bundles/02-xorg.sb loop3 7:3 0 18.8M 1 loop /run/initramfs/memory/bundles/03-desktop.sb loop4 7:4 0 16.1M 1 loop /run/initramfs/memory/bundles/04-apps.sb loop5 7:5 0 75.3M 1 loop /run/initramfs/memory/bundles/05-chromium.sb sda 8:0 0 4G 0 disk └─sda1 8:1 0 4G 0 part /media/sda1 sdb 8:16 1 7.2G 0 disk └─sdb1 8:17 1 7.2G 0 part /media/sdb1 root@slax:~#
And in the output for blkid command:
/dev/zram0: TYPE="swap" /dev/loop0: TYPE="squashfs" /dev/loop1: TYPE="squashfs" /dev/loop2: TYPE="squashfs" /dev/loop3: TYPE="squashfs" /dev/loop4: TYPE="squashfs" /dev/loop5: TYPE="squashfs" /dev/sda1: UUID="38334A56400BAC8E" TYPE="ntfs" PTTYPE="dos" PARTUUID="643e902b-01" /dev/sdb1: LABEL="KINGSTON" UUID="68A4-7FC4" TYPE="vfat" PARTUUID="12f87fba-01"
In this example the USB device is /dev/sdb, it has a primary partition /dev/sdb1.
Before using fdisk command you need to unmount the partition /dev/sdb1:
root@slax:~# umount /media/sdb1
If USB drive has no partitions then you should create a primary partition:
root@slax:~# fdisk /dev/sdb then type n (add a new partition) then type p (primary partition) then press [Enter] key 4 times then type Y (remove signature) then type t (change a partition type) then type 7 (select NTFS partition type) then type a (make sure bootable flag is "Enabled") then type w (save changes to disk and exit)
If a primary partition exists, just change the partition type into NTFS.
You can also use Gparted program, but it not installed by default. To install it, type:
root@slax:~# apt install gparted
To launch it, type:
root@slax:~# gparted
Gparted program has an intuitive interface and is easy to use.
Unmount the partition /dev/sdb1 again if it is mounted:
root@slax:~# umount /media/sdb1
The next step is formatting USB Drive into NTFS file system:
root@slax:~# mkfs.ntfs /dev/sdb1
Reboot the system.
Now is time to mount Windows 10 ISO file to the system. Create a mount point - it's a directory - let's name it "cd":
root@slax:~# mkdir /media/cd
In this example the Windows 10 ISO file is located in /media/sda1/ drive. The full path is:
/media/sda1/Windows10_InsiderPreview_Client_x32_en-us_18912.iso
root@slax:~# mount -o loop,ro /media/sda1/Windows10_InsiderPreview_Client_x32_en-us_18912.iso /media/cd
After the ISO file is mounted, all the Windows 10 installation files can be accessible in the directory /media/cd.
To copy all files and subdirectories to the USB Drive, use command rsync with parameter -r (recurse into directories).
root@slax:~# rsync -r --progress /media/cd/ /media/sdb1
Or use cp command with parameter -rva:
root@slax:~# cp -rva /media/cd/. /media/sdb1
You can also use a file manager (type in terminal pcmanfm to launch PCMan File Manager), just drag and drop all files and directories from /media/cd directory into /dev/sdb1.
Synchronize the data:
root@slax:~# sync
Copying and synchronizing may take a while.
Go to ms-sys.sourceforge.net and download a latest version of ms-sys program. Warning! Old versions of the program will not work for Windows 10! The oldest version that works with NTFS boot record is 2.3.0 (2012 year). The current version is 2.6.0 (July 2019), the archive file is ms-sys-2.6.0.tar.gz. Save the file into Download directory.
After download, unpack ms-sys-2.6.0.tar.gz file. Open terminal and type this command:
root@slax:~# tar -zxvf ms-sys-2.6.0.tar.gz
Install all necessary packages for compiling ms-sys program:
root@slax:~# apt install build-essential gettext
On the SLAX Linux you don't have to use su or sudo commands - the default user is always root as it was mentioned earlier.
Now you can install ms-sys program. Change directory to ms-sys-2.6.0, compile and install the program:
root@slax:~# cd ~/Downloads/ms-sys-2.6.0 root@slax:~# make root@slax:~# make install
To run the program, just type this:
root@slax:~# ms-sys
If ms-sys program was installed correctly, you'll see its output.
Now use ms-sys program:
root@slax:~# ms-sys -n /dev/sdb1 root@slax:~# ms-sys -7 /dev/sdb
Parameters:
-n writes NTFS partition Windows 7 boot record to device;
-7 writes a Windows 7 MBR (Master Boot Record) to device.
(Windows 7 boot parameters are compatible with Windows 10).
And at the last, synchronize cached data to USB and drives:
root@slax:~# sync
It's not necessary, but better to do so.
If Windows 10 won't boot from USB Drive, check out some important parameters. Use fdisk to see information about a partition of the USB Drive:
root@slax:~# fdisk /dev/sdb type i type q
The output:
Selected partition 1 Device: /dev/sdb1 Boot: * Type: HPFS/NTFS/exFAT
It's important that the flag Boot is set, and the file system is HPFS/NTFS/exFAT, as it shown above.
Check out the current boot record of the USB Drive using ms-sys program:
root@slax:~# ms-sys /dev/sdb
The output:
/dev/sdb has an x86 boot sector, it is a Microsoft 7 master boot record, like the one this program creates with the switch -7 on a hard disk device. It has windows disk signature 0xXXXXXXXX.
And do the same for the partition:
root@slax:~# ms-sys /dev/sdb1
The output:
/dev/sdb1 has a NTFS file system. /dev/sdb1 has an x86boot sector, it is exactly the kind of NTFS boot record this program would create with the switch -n on a NTFS partition. The OEM IS id NTFS.
If there something differ in the output, fix it using ms-sys program. And of course, make sure that all files on the USB Drive are copied correctly.
See also the video on youtube about whole process: Creating Windows 10 bootable USB drive on Linux