Windows 10 dual boot with UEFI

  • Hi,

    NUC NUC7i5BNH, Windows 10, LibreELEC, Dual boot, UEFI, Grub2

    I just want to share the steps I used to set up dual boot. All you need is Ubuntu Live on bootable USB, no need to use any extra tools on windows or hack the EFI stuff.

    Next step would be to create

    • a simple win10 app and
    • a simple LibreElec plugin

    to set next-time-default-boot-entry, but if your (remote) keyboard works at boot time, you can easily select which OS to boot...

    R, Janos


    Note: all these are typed in w/o copy&pasting so expect typos!

    1. Install Win10 in UEFI mode

    First install Windows 10. Make sure you boot in UEFI mode to do the install. Let windows create all the extra partitions but make sure you leave enough space behind for LibreELEC:

    Code
    Partitions created:
    /dev/sda1 NTFS      Recovery      500MB hidden,diag
    /dev/sda2 FAT32     EFI system    100MB boot,esp
    /dev/sda3 unknown   MS Reserved    16MB msftres
    /dev/sda4 NTFS      Windows       120GB msftdata
    
    <leave enough unused space behind for LibreElec: ~8-16G>


    2. Boot Ubuntu 18.04 Live in UEFI mode

    Everything you have to do in a terminal must be with root! - so always start with:

    Code
    sudo su

    2.a. Use GParted and create extra partitions for LibreELEC

    Code
    /dev/sda5   FAT32   Grub Boot Manager       100MB   Label=GRUB
    /dev/sda6   EXT3    LibreElec Boot         1024MB   Label=BOOT
    /dev/sda7   EXT4    LibreElec Storage        16GB   Label=STORAGE

    Note: set the LibreElec Storage size to what fits for you


    3. Copy LibreElec to target file-system

    - As usual, create an USB boot drive

    - Plug-in the USB drive while still in Ubuntu Live

    - USB drive should auto-mount under /media/ubuntu/LIBREELEC

    - Copy two files to the LibreElec boot partition

    Code
    mkdir /mnt/sda6
    mount /dev/sda6 /mnt/sda6
    cp /media/ubuntu/LIBREELEC/KERNEL /mnt/sda6/
    cp /media/ubuntu/LIBREELEC/SYSTEM /mnt/sda6/
    umount /mnt/sda6


    4. Configure UEFI

    4.a. Update the live session to get latest grub2 and tools

    Code
    apt-get update
    apt-get upgrade
    apt-get install grub-efi-amd64


    4.b. Install Grub2

    Code
    # mount the target partition
    sudo su
    mkdir /mnt/sda5
    mount /dev/sda5 /mnt/sda5
    
    # install grub2 to EFI
    grub-install --target=x86_64-efi --bootloader-id=LibreElec --boot-directory=/mnt/sda5 --efi-directory=/mnt/sda5
    
    # check that libreElec is the new default
    efibootmgr -v


    4.c. Create grub config files

    The grub-efi configuration

    Code
    cat << EOF > /mnt/sda5/EFI/LibreElec/grub.cfg
    configfile /grub/grub.cfg
    EOF


    The grub-menu configuration:


    4.d. Clean up and reboot

    Code
    umount /mnt/sda5
    reboot


    Optional steps:

    - if you want to use UUID instead of fixed partitions:

    2.b. Record what UUIDs are there for the following partitions (e.g. from GParted, using information on the partitions):

    - /dev/sda2 - the EFI partition

    - /dev/sda6 - the LibreElec boot partition

    - /dev/sda7 - the LibreElec storage partition

    4.c. Use the below menu-entries in the grub/grub.cfg:

    Edited 2 times, last by jkovacs: Separate Win-EFI partition from Grub as LibreElec doesn't have grub* but has efibootmgr and next-boot-only has to be on EFI level. (October 19, 2018 at 9:24 PM).

  • Thanks camyoung11 !

    That's super helpful - although I'll have to extend a bit with explicitly mounting the boot partition as

    - I prefer to hide all the non-content partitions from LibreElec

    - As shown above, I have grub on the EFI partition which is hidden by default on LibreElec.

    Janos

  • That old plugin is not available for download anymore...

    ...so started to create my own addon. I was about to test when realized that even with the extra tools there is no grub-* in libreelec :(

    ...but the good thing is that there is efibootmgr which also supports one-time-only boot changes!

    The only drawback is that it can boot partition that is know by EFI.

  • Thanks a lot, jkovacs ! It works perfectly!

    Could you please say if there is a way to disable displaying of Windows and Grub partitions in Kodi UI? I can remove them from the UI, but after reboot they are there again.

    And one more thing. Is this command correct:

    Code
    grub-install --target=x86_64-efi --bootloader-id=LibreElec --boot-directory=/mnt/sda5 --efi-directory=/mnt/sda5

    I mean, isn't the `boot-directory` has to be `/mnt/sda6` instead of `/mnt/sda5`? (though `/dev/sda6` is unmounted already)

    I used exactly your command while setting up my system, and it's working fine, but I'm still in a doubt.

  • quicktrick if you followed the above steps all you need to do is to

    - set the extra partition labels (only need to add GRUB and Windows as other are already there) to ignore under .config/udev.rules.d/95-udevil-mount.rules, e.g.:

    Code
    ENV{ID_FS_LABEL}=="EFI|BOOT|Recovery|RECOVERY|SETTINGS|boot|root0|share0|GRUB|Windows", GOTO="exit"

    - double check if the partition labels are correct, e.g.:

    Code
            /dev/sda1 Recovery
            /dev/sda2 EFI
            /dev/sda3 
            /dev/sda4 Windows
            /dev/sda5 GRUB
            /dev/sda6 BOOT
            /dev/sda7 STORAGE

    Note: I had issues adding the label to the EFI (/dev/sda2) partition with GParted, but worked with mlabel from the terminal under Ubuntu Live:

    Code
    mlabel -i /dev/sda2 ::EFI

    Regarding the 'grub-install' command: yes, for Grub, both the boot and efi are the same /dev/sda5 (decoupled from both windows and libreelec). /dev/sda6 is only a boot for libreelec.

    R, Janos

  • Thank you, jkovacs !

    I was unable to add the label EFI too, it said "Long file EFI already exists". So I added the label ESP instead (EFI System Partition). And I had to set `mtools_skip_check=1`:

    Code
    export MTOOLS_SKIP_CHECK=1
    mlabel -i /dev/sda2 ::ESP

    and my `/storage/.config/udev.rules.d/95-udevil-mount.rules` is:

    Code
    ENV{ID_FS_LABEL}=="EFI|BOOT|Recovery|RECOVERY|SETTINGS|boot|root0|share0|ESP|GRUB|Windows", GOTO="exit"

    After reboot:

    So, everything is fine now! Thanks again!

    BTW, how do I upgrade LibreElec? Just copy new images of KERNEL and SYSTEM to `/dev/sda6`?

    Edited once, last by quicktrick (October 24, 2018 at 12:02 PM).

  • After removing the USB Sticks it mounted to Windows without any problems, but when trying to mount LibreElec it wasn't able to mount sda7.

    Did I do something wrong?

    Edited once, last by Morktral (November 4, 2018 at 6:45 PM).

  • efibootmgr works great for me. It is available in the "System Tools" addon.

    On an Intel NUC I can use from within LibreElec it to alter the OS boot order and also the 'nextboot' feature can do just a 'one time' boot into Windows 10.

  • Thanks for the guide😁. I have zero knowledge on Linux and somehow with this guide I managed to dual boot windows 10/librrelec.

    Got question, can I just install ubuntu on the last partition I have reserved earlier? Will the OS automatically insert itself in the grub2 menu?

  • The best sequence is to install Windows - Ubuntu - LibreELEC.

    Use manually created partition with both Windows and Ubuntu.

    Partitions for LibreELEC can be created manually via Gparted in Ubuntu (or Gparted via a Live ISO).

  • I am trying to create this dual boot but I have no knowledge of Ubuntu and I am stuck with this step already:

    I am unable to Copy LibreElec to target file-system when using this code:

    cp /media/ubuntu/LIBREELEC/KERNEL /mnt/sda6/

    I got:

    cp: cannot stat '/media/ubuntu/LIBREELEC/KERNEL no such file or directory

    I am still in Ubuntu and also the Libreelec media usb is connected and mounted to sda6

  • Quote

    am unable to Copy LibreElec to target file-system when using this code:

    cp /media/ubuntu/LIBREELEC/KERNEL /mnt/sda6/

    I got:

    cp: cannot stat '/media/ubuntu/LIBREELEC/KERNEL no such file or directory

    Any update on the way to dual boot? I mean, a more simple way... I struggle a lot right now...

  • I don't want to bother anyone, but honestly i'm lost. I've tried several way to create a dual boot. First, I've installed Win 10. Then, used Gparted live usb stick to create partition, then, install LibreElec... and my boot disappear. No more Windows.

    Is there a easier way to proceed? Is there any update on this? My ultmate goal is to use my Intel Nuc with Windows 10, LibreElec, then Steam OS.

    Thanks for your help.

  • Is there a easier way to proceed? Is there any update on this? My ultmate goal is to use my Intel Nuc with Windows 10, LibreElec, then Steam OS.

    You will have those problems with any other multi-boot Linux OS, too. That is no special LE question.

    However, I had dual boot Win 10 / Ubuntu for a long time. This year Win 10 updates sucked so much, that I've been deleted Win 10.

    My multi-boot install was like this:

    1. create all partitions you need (for all OS'es, use "Gparted Live" or "Parted Magic" for instance)
    2. install Win 10 on a selected partition
    3. install the next OS on a selected partition and so on

    If you have trouble to find any OS after reboot, use Super Grub2 Disk to boot into Linux, and reinstall the boot loader (EFI partition).

    The problem is that LE don't have the capability to do this. So, I suggest to have one Linux OS installed (Ubuntu etc.), which let you reinstall the boot loader. This means, the first OS after the Win 10 installation should be such a complete Linux. Maybe Steam OS has such capability, too, but I don't know.

    Sometimes, if you can't reboot into an OS, you have to re-select the first bootable partition at the EFI settings (usually the Linux partition, which leads to the GRUB boot selection screen).

  • Thanks for your reply. I won't install a full Linux distribution cause I will never use it (for now, but if it's the only solution, I will, of course).

    So, bascially:

    1.I install Windows 10 in legacy mode, not UEFI (and UEFI disabled in my BIOS, and Secure boot too). It will be NTFS.

    2.I launch GParted Live from an USB stick, then Reduce my Windows 10 partition to the size I want.

    3.I convert the remaining space into EXT4 only (and only 1 partition)

    4.I install LibreElec on the EXT4 partition.

    5. I light some candles and do some voodoo prayers

    6.I reboot, and...

    ...and what will happen normally?

    I will try tomorow following the step I wrote. If it's not working, I will probably do what you advice to me: use Kodibuntu for example, as a dedicated linux OS.