Better Windows dual-boot with systemd-boot

If you are dual-booting Linux and Windows, but rebooting into Grub and selecting Windows manually is too much effort, then this article is for you.

Setting up quick dual-boot

  1. Let’s check if you are using systemd-boot. If you see “Yay” you can proceed, otherwise you need to install systemd-boot.
    ls /boot/efi/loader/ | grep -q loader.conf && echo "Yay" || echo "Nay"
    
  2. Check if the OS you want to boot already has a loader configuration. If so, you can proceed to 3.
    ls /boot/efi/loader/entries
    
    1. If you don’t have a loader configuration for Windows yet, try
       ls /boot/efi/EFI/
      

      check if there is a folder called “Windows” or similar and write down the *.efi file

    2. If there is no entry, you need to copy it over from the Windows drive or partition
       lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT
      
       NAME            FSTYPE        SIZE MOUNTPOINT
       nvme0n1                     476,9G 
       ├─nvme0n1p1     ntfs          450M 
       ├─nvme0n1p2     vfat          100M 
       ├─nvme0n1p3                    16M 
       ├─nvme0n1p4     ntfs        475,6G 
       └─nvme0n1p5     ntfs          850M 
      

      In the output above, the partition nvme0n1p2 is the Windows MBR. Usually, the partition is 100 MB. Let’s mount the partition and copy over the EFI file.

     sudo mount /dev/nvme0n1p2 /mnt/win-efi
     sudo cp -r /mnt/win-efi/EFI/Microsoft /boot/efi/EFI
     umount /mnt/win-efi/
    
  3. Now that you have the correct efi file, create the correct loader configuration. You need to adjust the path to the efi file path from step 2.
    echo "title Windows
    efi /EFI/Microsoft/Boot/bootmgfw.efi" > /boot/efi/loader/entries/windows-boot.conf
    

At this point you are already done and you can use systemctl to reboot into Windows.

systemctl reboot --boot-loader-entry=windows-boot

Bonus

Create a desktop entry so you can reboot via your launcher

sudo echo "#!/bin/sh
systemctl reboot --boot-loader-entry=windows-boot" > /opt/boot-into-windows
sudo chmod  +x /opt/reboot-into-windows
echo "[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
# Add your own icon
Icon=~/.local/share/applications/windows.png
Name=Boot Windows
Comment=Reboot into Windows
Exec=/opt/boot-into-windows
Categories=Utility;
" > ~/.local/share/applications/windows.desktop
chmod +x ~/.local/share/applications/windows.desktop

Now you can type Windows in your launcher, press enter and directly boot into Windows.