Preface
Setting up a dual-boot system on a PC typically requires installing Windows first and then Linux. This sequence is recommended because Windows tends to overwrite the bootloader (like GRUB) during its installation, which can complicate a pre-existing Linux setup. However, I successfully reversed the process—installing Windows after Linux—by employing a series of workarounds. In this post, I’ll document the method, explaining the technical challenges and how I addressed them so others can replicate them.
To summarize the tutorial: You will Install Windows on top of the old Linux, Install the new linux, and clone data from the old linux to a new one.
Step 1 – Existing Linux
I assume you have installed Linux; otherwise, do not bother and install it in the usual order.
Use the following commands to identify your disk’s EFI, swap, and root partitions, and write them somewhere.
lsblk -l sudo blkid
Step 2 – Install Windows
- Prepare Windows Installer onto USB; use Rufus if you have other Windows; otherwise, use Ventoy or WoeUSBng.
- Do not use BalenaEtcher; it is not designed to flash Windows on USB.
- Boot to Windows Installer
- Delete EFI and swap all other partitions, except for one partition with the root file system of the existing Linux.
- Resize existing OS and create new space for Windows
- Create a new partition for “Step 3” more than 20GB of space. At least the size of the original OS used space.
- Install Windows
Now, you cannot boot into the original Linux, but you should be able to boot into Windows.
Step 3 – New Linux 2
We will install a second linux to have a functional bootloader and restore data from the original OS.
- Flash USB with Linux image, use the same distro as the original OS.
- Install it on the partition from “Step 2”.
- Ensure the Linux bootloader is above the Windows boot manager in the BIOS/UEFI boot order.
- Now, the following commands will clone data from old Linux and move it to the new one.
sudo su
# if original disk encrypted, decrypt it.
cryptsetup luksOpen /dev/<ORIGINAL-OS-DISK> cryptdisk
mount /dev/mapper/cryptdisk /mnt
#If disk is not encrypted, just mount it directly
for i in /opt /usr /home /.config /.local /bin /root ; do rsync -avz /mnt$i $i ;done
Well, this means the disk is not cloned; only data are.
This command is safe. You also can mount the whole “/” root system. However, you will encounter errors, which you will have to resolve.
To give an example: /etc/fstab
cannot be copied because the partitions do not exist anymore.
Step 4 – Cleanup
- Boot into live USB linux
- Delete the original OS partition.
- Resize the Linux 2 partition, so it has more space.
- Boot into new linux
- Clean up with the following steps if any leftover stuff from the original OS is on the EFI partition.
- Regenerate
initramfs
file on Manjaro, usemkinitcpio
- Use
update-grub
command to regenerate GRUB config. - Reboot
Conclusion
You have successfully installed Windows on the existing Linux and restored the original data.