Windows 10 Installation from Linux

I had to install Windows 10 on my machine in order to run some programs available only for that platform. I didn't have a fast USB stick or a big (>5.0 GB) DVD blank, so I had to do it solely from HDD. Here are the steps I followed.

First, make some directories as mount points.

root$ mkdir /mnt/iso
root$ mkdir /mnt/install_part
Now, prepare your partitions. Run gparted on the disk (mine was /dev/sdb). Make sure that the disk has an MSDOS partition table.

Create a big partition for windows. Let's call this /dev/sdb1. Make a smaller partition, around 10GB to hold the installation media (/dev/sdb2). Both should be formatted as ntfs. Give labels to both partitions.

Set the bootable flag on for windows partition and off for media partition.

Now, mount the Windows 10 ISO and the media partition as follows:

root$ mount -o loop /path/to/windows10.iso /mnt/iso
root$ mount /dev/sdb2 /mnt/install_part 
root$ cd /mnt/iso
root$ cp -v -R * /mnt/install_part
Some people directly dd the ISO to harddisk. This didn't work for me. It seems like the Windows installer has problems reading the ISO file system when running from HDD. In any case, now we have the necessary setup program and files on HDD partition. We now need to tell our system to boot from it. If we did this from Windows, it'd put a bootloader at the MBR of the disk. We don't have that so we're going to put grub there. This grub installation will boot our Windows installer disk.
root$ grub2-install --target=i386-pc \
   --boot-directory=/mnt/install_part/boot \
   /dev/sdb
root$ cat > /mnt/install_part/boot/grub2/grub.cfg
insmod part_msdos
insmod ntfs
insmod ntldr
search --no-floppy --label --set=root INSMED
chainloader +1
^D
Of course, change /dev/sdb to whatever disk you're using. INSMED is the label I chose previously for the installation partition. This grub installation at the MBR will later be overwritten by the Windows bootloader, so everything is A-OK.

Now, unmount both your directories and then shutdown your computer.

root$ cd /
root$ umount /mnt/install_part
root$ umount /mnt/iso
root$ shutdown -P now
Once shutdown, disconnect your DVD drive and other SSD/HDDs except for the Windows disk. This is necessary because Windows Installer needs to be executed from the first disk. Otherwise, it gives an error such as:
We couldn't create a new partition or locate an existing one.
Then it tells you to look at the log file, which is of course empty.

When you power-up your PC again, hopefully Windows 10 installer will run properly.

When you're done installing Windows, reconnect your Linux HDD and the DVD drive. Set boot priority to the Linux HDD and then add the following into your main grub.cfg, which lives in /boot/grub2/:

menuentry "Windows 10" --class windows --class os {
    insmod part_msdos
    insmod ntfs
    insmod ntldr
    search --no-floppy --fs-uuid --set=root 34B6E976B6E938CE
    chainloader +1
}

menuentry "Windows 10 installer" --class windows --class os {
    insmod part_msdos
    insmod ntfs
    insmod ntldr
    search --no-floppy --label --set=root INSMED
    chainloader +1
}                                     
I got the uuid in the first menu entry from the blkid command:
root$ blkid /dev/sdb1
I forgot to set a label for that partition. For the second partition, I did remember it so I search for it using the label.

The Windows 10 install media partition is no longer necessary, but it contains a command line which could be used to rescue the Windows 10 installation. Therefore, I keep it around.