Yuan

Note About Dual-Booting Windows and Fedora

Dual-booting is often unavoidable for game development and graphic development. Here are some common problems and their solutions.

Regenerate Windows 10 EFI files

You accidentally removed Windows EFI files and can no longer boot into Windows anymore. This fix requires a Windows installation media. Note that Windows' command prompt is case-insensitive.

  1. Boot into your Windows installation media.

  2. Go to the command prompt (Repair your computer > Troubleshoot > Command Prompt).

  3. Find the volume number of your EFI partition:

    diskpart                <-- open DiskPart utility
    list volume             <-- list all available volumes
    

    It is generally around 600 MB. Make sure to not choose the MSR, which is way smaller.

  4. Select it and assign a letter to it (mount it):

    select volume [number]  <-- e.g. select volume 2
    assign letter [letter]  <-- choose an unused letter. e.g. assign letter f
    

    We will assume you assigned the letter F.

  5. Make sure your Windows partition is mounted too, we will assume it’s mounted at C:.

  6. Exit diskpart:

    exit
    
  7. Generate the EFI files of the Windows partition (C:) and place them on the EFI partition (F:):

    bcdboot c:\windows /s f:
    

Add Windows to Fedora’s GRUB menu (EFI)

Windows may not be in your GRUB menu if its EFI files are not present during Fedora’s installation.

First, make sure os-prober can detect Windows:

$ sudo os-prober

Then, simply regenerate your GRUB config:

$ sudo grub2-mkconfig -o "$(sudo readlink -e /etc/grub2-efi.cfg)"

Shrink Fedora’s LVM partition

You may want to shrink Fedora’s LVM partition so that you can install Windows after it. Generally, you want to shrink your home partition. A standard Fedora installation should look like this:

┌───────────┬───────┬─────────────────────────────┐
│           │       │             LVM             │
│ /boot/efi │ /boot ├──────┬───────────────┬──────┤
│    FAT    │ Ext4  │  /   │     /home     │      │
│           │       │ Ext4 │     Ext4      │ swap │
└───────────┴───────┴──────┴───────────────┴──────┘

To shrink the LVM partition, you need to perform the following steps in a Live CD. It is strongly recommended to create a backup first.

  1. Shrink your home

    ┌───────────┬───────┬─────────────────────────────┐
    │           │       │             LVM             │
    │ /boot/efi │ /boot ├──────┬───────┬───────┬──────┤
    │    FAT    │ Ext4  │  /   │ /home │       │      │
    │           │       │ Ext4 │ Ext4  │ empty │ swap │
    └───────────┴───────┴──────┴───────┴───────┴──────┘
    
  2. Move your swap

    ┌───────────┬───────┬─────────────────────────────┐
    │           │       │             LVM             │
    │ /boot/efi │ /boot ├──────┬───────┬──────┬───────┤
    │    FAT    │ Ext4  │  /   │ /home │      │       │
    │           │       │ Ext4 │ Ext4  │ swap │ empty │
    └───────────┴───────┴──────┴───────┴──────┴───────┘
    
  3. Shrink the LVM partition

    ┌───────────┬───────┬─────────────────────┬───────┐
    │           │       │         LVM         │       │
    │ /boot/efi │ /boot ├──────┬───────┬──────┤       │
    │    FAT    │ Ext4  │  /   │ /home │      │ empty │
    │           │       │ Ext4 │ Ext4  │ swap │       │
    └───────────┴───────┴──────┴───────┴──────┴───────┘
    

And Voilà! There are a lot of documentations online so we will skip the detail of each step here.

References

https://dev.to/hiro98/reinstalling-the-windows-efi-bootloader-files-i68
https://fedoraproject.org/wiki/GRUB_2#Updating_GRUB_2_configuration_on_UEFI_systems