HowTo Dual Boot NST With Windows 8.1

From NST Wiki
Jump to: navigation, search

The following information was graciously provided by Roger Baran as he went through the painful process of figuring out a method to dual boot NST and Window 8.1. This procedure would most likely work on any Fedora based distribution (NST 20 which is based off Fedora 20 was used for the purpose of this article).

Initial Install Attempt Issues

I installed NST-20 on my Dell Laptop as a dual-boot alongside Windows 8.1 Since I am using the x86-64 ISO, I was able to boot EFI and install without any difficulties at all.

When I rebooted, I used F12 to look at my EFI boot options: There was Fedora at the top of the list. I booted into it and Grub came up just fine. I was laughing and saying: 'Now, how hard is that!' because I have been so frustrated with other distros not being able to simply install EFI and make everything work.

Ok. So, I select Windows Boot Manager from the GRUB menu to make sure that I can still boot into Windows 8.1. The laptop booted into Windows 8.1 without any issues. I was still laughing with joy!

THEN, I shutdown to go into my new NST-20 install. I noticed that it took a very long time to shutdown. Pressing F12 to see the EFI boot options menu I saw that the FEDORA entry was GONE from the EFI boot selections and my laptop has no way of booting back into NST!


I tried dredging my way through the forums but failed to find a solution for what exactly matches my situation.


I have been working though this issue all day and I have come up with the following observations:

  1. After a fresh install, grub needs to be updated after all of the initial updates are applied (I think it is because the kernel is upgraded to 3.15 from 3.13)
  2. Grub cannot be updated if you have LVM with encryption for the install selected (if someone can tell me how to mount an encrypted volume from a live usb in NST -- 'cryptsetup openLUKS' is not an option -- then another approach (the 'create a dev environment from the installed system and chroot' option) might be possible).
  3. Although there is a separate boot partition created for an LVM encrypted install, and an entry is made into efivars, that entry points to the EFI partition that houses the Microsoft bootloader (it should point to the boot partition that was newly created during the install -- and I don't believe that all the shim components are being properly installed either).
  4. When powering on, you can see and select the 'fedora' entry repeatedly -- as long as you do not boot into Windows. The first boot into windows will trash the /dev/sda1/efi/EFI/fedora directory and from then on, the 'fedora' entry will not be displayed as an option during boot.
  5. Using BCDEdit is useless to restore it - unless there is a way to specify an alternate location for /EFI/fedora.
  6. Using EasyBCD is useless for the same reason.
  7. You can fix the corrupted directory structure on /dev/sda1 (my EFI Boot partition) using the procedures shown below. That will remove the 'fedora' directory from the EFI partiton - so that doesn't really solve the ssue; but it does need to be done before re-installing because on the second install, grub will attempt to make the same entries at the same location and since the directory is there, and hosed up, the install will fail.
  8. Using efibootmgr to remove all install entries except the Windows Boot Manager, will return your system to pre-install boot condition (as far as Windows is concerned. Windows seems to rebuild BCD at each boot)
  9. Using dd to back up the EFI partition and then restoring it after Windows trashes it won't work either.
  10. It seems that the /dev/sda1/efi/EFI/fedora directory can co-exist in the partition with Microsoft, but if you try to boot from it, Microsoft will trash it on the next boot.

Procedure to fix the corrupted directory structure on /dev/sda1:

[root@localhost nst]# cd /mnt
[root@localhost mnt]# ls 
btrfs  ext2    flash1  flash6   iso   ram1   ram14  ram5  ramfs     vfat
cifs   ext3    flash2  flash7   nfs   ram10  ram15  ram6  smb
davfs  ext4    flash3  fs       nst   ram11  ram2   ram7  squashfs
disk   file    flash4  initrd   ntfs  ram12  ram3   ram8  sysimage
dvd    flash0  flash5  install  ram0  ram13  ram4   ram9  tmpfs
[root@localhost mnt]# mkdir efi
[root@localhost mnt]# mount /dev/sda1 efi
[root@localhost mnt]# cd efi
[root@localhost efi]# ls
ls: cannot access System: Input/output error 
Boot          bootmgr.efi  en-us        sources
bootmgfw.efi  DELL         mach_kernel  System
bootmgr       EFI          NTLDR        System Volume Information
[root@localhost efi]# cd EFI
[root@localhost EFI]# ls
ls: cannot access fedora: Input/output error
Boot  fedora  Microsoft
[  418.698553] FAT-fs (sda1): error, fat_get_cluster: invalid cluster chain (i_pos 0) 
[  418.698557] FAT-fs (sda1): Filesystem has been set read-only
[  424.216291] FAT-fs (sda1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[  738.484056] FAT-fs (sda1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[  759.824280] FAT-fs (sda1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[ 3782.285477] FAT-fs (sda1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[root@localhost EFI]# dosfsck -r /dev/sda1


[root@localhost EFI]# dosfsck -r /dev/sda1
fsck.fat 3.0.24 (2013-11-23)
0x41: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
1) Remove dirty bit
2) No action
? 1
There are differences between boot sector and its backup.
This is mostly harmless. Differences: (offset:original/backup)
  67:be/67, 68:e0/1b, 69:81/0d, 70:64/2a
1) Copy original to backup
2) Copy backup to original
3) No action
? 1
  Contains a free cluster (55). Assuming EOF.
  Contains a free cluster (60). Assuming EOF.
  File size is 34 bytes, cluster chain length is 0 bytes.
  Truncating file to 0 bytes.
  Contains a free cluster (56). Assuming EOF.
  Contains a free cluster (61). Assuming EOF.
  File size is 1390152 bytes, cluster chain length is 0 bytes.
  Truncating file to 0 bytes.
Reclaimed 1175 unused clusters (4812800 bytes).
Free cluster summary wrong (113223 vs. really 115571)
1) Correct
2) Don't correct
? 1
Perform changes ? (y/n) y
/dev/sda1: 209 files, 11405/126976 clusters
[root@localhost EFI]# dosfsck -r /dev/sda1
fsck.fat 3.0.24 (2013-11-23)
Start does point to root directory. Deleting dir. 
Start does point to root directory. Deleting dir. 
Reclaimed 1173 unused clusters (4804608 bytes).
Perform changes ? (y/n) y
/dev/sda1: 209 files, 11405/126976 clusters
[root@localhost EFI]# dosfsck -r /dev/sda1
fsck.fat 3.0.24 (2013-11-23)
Orphaned long file name part "System"
1: Delete.
2: Leave it.
? 2
/dev/sda1: 207 files, 11405/126976 clusters
[root@localhost EFI]#
[root@localhost EFI]# ls
Boot  Microsoft
[root@localhost EFI]# 

After re-install:

[root@localhost nst]# cd /mnt
[root@localhost mnt]# ls
btrfs  dvd   ext4    flash2  flash6  install  ntfs   ram11  ram15  ram5  ram9      sysimage
cifs   efi   file    flash3  flash7  iso      ram0   ram12  ram2   ram6  ramfs     tmpfs
davfs  ext2  flash0  flash4  fs      nfs      ram1   ram13  ram3   ram7  smb       vfat
disk   ext3  flash1  flash5  initrd  nst      ram10  ram14  ram4   ram8  squashfs
[root@localhost mnt]# mkdir esp
[root@localhost mnt]# cd esp
[root@localhost esp]# ls
Boot          bootmgr      DELL  en-us        NTLDR    System
bootmgfw.efi  bootmgr.efi  EFI   mach_kernel  sources  System Volume Information
[root@localhost esp]# cd EFI
[root@localhost EFI]# ls 
Boot  fedora  Microsoft
[root@localhost EFI]# cd fedora
[root@localhost fedora]# ls
BOOT.CSV  fonts  gcdx64.efi  grub.cfg  grubx64.efi  MokManager.efi  shim.efi  shim-fedora.efi
[root@localhost fedora]# 

A Working Solution

  • Install without using LVM and encryption; use standard partitioning.
  • Prior to first reboot after the install is complete, use efibootmgr -v to look at the entry for 'Network Security Toolkit' (which will be changed to fedora on the EFI boot options screen after the first boot).
  • Ensure that it points to the EFI partition created during the install (mine was /dev/sda7)

NOTE: Do not try to boot into Windows until you are completely finished with all of these steps!

  • Reboot, come back in and do all of the updates
  • Prior to reboot, run '~#yum reinstall grub2-efi shim'
  • Use efibootmgr -v again to look at the location for 'fedora' (should still be pointing to your newly created EFI partition)
  • Reboot, come back in and, as root, edit your grub.cfg custom section:
menuentry 'Windows 8.1 Boot Manager' {
          insmod part_gpt
          insmod msdos
          set root='hd0,gpt1'
          chainloader /EFI/Microsoft/Boot/bootmgfw.efi
  • Remove the entry from the os_prober section.
  • Change the root values to whatever works for your install
  • Save grub.cfg
  • Reboot
  • Test the menu selection for Windows 8.1 Boot Manager

Further Investigation

I would still like to investigate a simpler solution: The possibility of just using efibootmgr prior to the first boot after install to either create or modify the 'fedora' entry in the efivars...

The files and information that gets installed in the /dev/sda1/efi/EFI/fedora location only work until the first time you boot into Windows -- which then trashes that directory. If we could get the efivar for the new installation (using LVM and encryption) to point to the new boot partition, we might just get it to work...

Anyway, installing without LVM and encryption works for now; somehow, grub2 does a better job with standard partitions and its own efi partition. :)