Do you dream of installing Linux but are afraid of losing Windows? Well, with this crazy trick, you’ll be able to install Linux directly from the Windows installer. Yes, it’s possible! Though, I must warn you, this is definitely not for beginners. But if you love technical challenges and aren’t afraid to tinker, you’re going to love this!
The basic idea is simple (well, almost): The goal is to prepare a Linux installation on an NTFS partition, then compress it into a WIM file, which is then integrated into the Windows ISO. During the Windows installation, you’ll select the Linux image, and voilà, job done! Well, not quite…
Step 1: Install Linux on an NTFS Partition
The first step is to install Linux on an NTFS partition. To do this, you’ll need to choose a distribution that works well with this type of partition, such as Arch Linux or Alpine Linux. Alpine’s installer is particularly handy because it doesn’t check the partition type and allows you to do what you want.
Start by creating the necessary partitions:
- A 100MB EFI partition in FAT32,
- A 16MB partition that you won’t use but is necessary so the partition numbering aligns with what the Windows installer expects,
- And finally, the NTFS partition for Linux that will take up the rest of the disk.
Mount everything, and install Alpine by following the manual installation guide. You’ll need to tweak a few details:
- In the
/etc/fstab
file, replace UUIDs with the classic/dev/sdaX
, otherwise, it won’t work on reboot as the UUIDs will have changed. - Add the
ntfs3
module in the initramfs by creating a file/etc/mkinitfs/features.d/ntfs3.modules
containing the module’s path, and regenerate the initramfs with themkinitfs
command. - In Grub’s configuration, replace the UUIDs with
/dev/sdaX
as well.
Once the Linux installation is done, compress it into a WIM file using the wimlib
tool in Linux:
wimcapture /mnt/linux linux.wim --compress=LZX
Step 2: Modify the Windows ISO
Now, onto the Windows part. Download the Windows 10 ISO, and replace the install.wim
file in the sources
folder with your linux.wim
. If you try to boot with this modified ISO, Windows will complain and refuse to install because it can’t find the expected Microsoft license terms.
The trick is to also integrate a Windows Preinstallation Environment (WinPE) into our WIM image. We’ll customize it so that it makes Linux bootable on the next reboot for us.
To do this, add the following commands to WinPE’s startnet.cmd
script:
- Mount the EFI partition with
diskpart
and a scriptmount-efi.txt
containing:
select disk 0
select partition 1
assign letter=S
exit
- Apply the contents of Alpine’s
/boot
partition (captured inefi.wim
) to the mounted EFI partitionS:
using the command:
dism /Apply-Image /ImageFile:"C:efi.wim" /Index:1 /ApplyDir:S:
- Delete the Windows boot manager with:
bcdedit /delete {bootmgr} /f
One last little detail: the Windows installer checks for a valid license in the WIM image. So, we’ll add the text of the GPLv2 license in the file E:WindowsSystem32en-USLicensesWindowsPE_Defaultlicense.rtf
.
Step 3: Recreate the ISO
Finally, recreate the ISO using oscdimg
, and attempt the installation. Oh joy, it works! The installer shows our Linux image, we click, it runs, reboots, and… Tadaaa! A lovely Tux greets us!
Of course, this method is far from perfect. The WIM capture doesn’t preserve Linux file permissions, so you’ll need to fix them. And using NTFS for your Linux root exposes you to potential major issues, like ending up with read-only access at the slightest problem. But as a hack, I think it’s quite an impressive feat!
If you want all the technical details of this accomplishment, I recommend reading the excellent article on prose.nsood.in, and a big thanks to @bearstech for the initial share!
That’s it! I hope this quirky news made you smile, but don’t try this on your work computer, okay? It’s just for fun 😉 Enjoy, and see you soon!