Quoted Strings

Dual Booting Arch Linux and Windows

  2023/10/29

Posted Tags: #Linux, #Windows
Other Tags: #Personal, #All

A couple or years ago I updated my everyday computer to a motherboard with two M.2 drive connectors. Having the two connectors I bought another M.2 SSD exactly like my current one and installed it in the other M.2 connector. I was thinking I could use ZFS on Arch Linux in a mirrored pool of the two SSDs. I even wrote a bash script I called strings to automate the Arch Linux installation. It worked very well and took me a relatively short time to work it all out with the ZFS monitoring, emailing of results and all. Things went great and I was using the DKMS github version of ZFS which compiles against the new Linux kernel each time you update. I used another SSD partition to boot the pool which simplified the mirrored pool as far as updates. As I said things were going well and I tested losing one SSD in the pool and found how the computer would still boot under ZFS. Add a replacement SSD and ZFS re-striped them without me operationally noticing it. I had used Linux's MDADM for a mirrored pool before and in that situation you can not boot. I was throughly amazed with ZFS. I use it with Ubuntu Server LTS with my servers. But one day DKMS ZFS lagged behind a new Linux kernel during an update and my Arch Linux installation would not boot. It upset me and my bash script strings was now useless for a ZFS mirror. I could use the script to install on a single SSD using ZFS too but now I was so disillusioned about ZFS on Arch Linux. Luckily for me I am prolific at backups and my script could be used without ZFS too so I recovered relatively quickly. I was done with Arch Linux on ZFS root. As I said I keep prolific backups so really it was an experiment that failed as far as I was concerned.

I operated like this for nearly a year with one M.2 SSD not being used. I have been using Windows 10 and now Windows 11 in virtual machines since leaving Windows for Linux some five years ago. I did so I could use Adobe Illustrator for some work with one of my brothers. I was invested in Illustrator and haven't gotten into using Inkscape yet. One day recently it occurred to me that I could dual boot Arch Linux and Windows 11 since I have the extra M.2 SSD. So here is how to do it. It would probably work on a single SSD in partitions with Arch Linux installed if it is the first boot partition on the SSD.

One thing to note here is that I am using systemd to boot Arch Linux. There are other ways to do this using Grub.

Install Windows first or second on the other SSD because it really doesn't matter. I installed Windows second since my Arch Linux installation had been here a time before doing this.

After installing Windows, using your BIOS boot into the Arch Linux installation. In terminal type the following to find your Windows boot partition.

lsblk

nvme0n1     259:0    0 232.9G  0 disk  
├─nvme0n1p1 259:2    0   512M  0 part  /boot
└─nvme0n1p2 259:3    0 232.3G  0 part  /
nvme1n1     259:1    0 232.9G  0 disk  
├─nvme1n1p1 259:4    0   100M  0 part  
├─nvme1n1p2 259:5    0    16M  0 part  
├─nvme1n1p3 259:6    0 232.1G  0 part  
└─nvme1n1p4 259:7    0   674M  0 part  

The command results are following the command here and nvme0n1p1 is the active Arch Linux boot partition. I know this due to the /boot indication and the fact that the partition size is 512M. nvme1n1p1 is the first partition on the other SSD and is 100M, which is the Windows boot partition. Below we are mounting this partition to a known directory in Linux being /mnt. We then copy the contents of the /EFI/Microsoft/ mounted directory to the /boot directory for Linux giving Microsoft its own EFI directory. I am using my SSD drives here for explanation so substitute using your own drives.

sudo mount /dev/nvme1n1p1 /mnt
sudo cp -r /mnt/EFI/Microsoft/ /boot/EFI/Microsoft/

Now all you do is reboot. Windows will show up as the second non default option at boot. The mount will self disconnect at the reboot. I was surprised at how easy this was with systemd and it is why I use it.

Wish to add a comment? Your email address will never be shared with anyone. Please specify a user name for your comment or use anonymous.

Email me a comment to post it.