Trouble dual booting 12.2 and Windows 7 on EFI enabled system

This is wrong.

  1. You don’t need a separate /boot partition.
  2. It can not be fat32.

Donc confuse /boot with the EFI system partition (which gets mounted in /boot/efi)

Absolutely. UEFI has a boot manager ‘embedded’ (and it can read boot loaders from more than one ESP). You can perfectly use the UEFI interface to multi boot. Under Linux, you can also use the command efibootmgr to set the next OS to boot (once). Thus you don’t even need a WIndows boot entry in Grub menu to reboot Windows (But don’t worry you’ll get one).

Yes, please do!

That’s correct. But the problem is having a second ESP since - according to @arvidjaar again, it’s going to bother Windows if you need to repare it.

Yes it works, but don’t do that with Windows. Windows is the one being the problem, as always.

Correct. AFAIK that’s what WIndows requires (but it is not out-of-spec). Linux doesn’t care.

Looking at updateGrub2, it should create a Windows boot entry - I’m sure I did something like that, but I wrote this script a while ago and haven’t tested it under 12.2 (UEFI).

Here’s the function which creates chainloader entries (if they don’t already exist):

function efi_chainload {
# look for Linux bootloaders in the ESP on UEFI systems
for GREFI in $(find /boot/efi/EFI -name "$GRID" -o -name "$W7ID" 2>/dev/null | sed "/$BLID/d;s|Microsoft/Boot|windows|") ; do
	UUID=$($gprobe --target=fs_uuid $GREFI)
	t=$(echo ${GREFI%/*} | sed 's|.*/\(.\)\(.*\)|\U\1\E\2|')
	 "$t" == "Windows" ] && T="$t x86_64 UEFI-GPT" || T="$t Grub"
	grep -q "$T" /etc/grub.d/40_custom && continue
	echo "chainloading $t ..."
	printf "
menuentry \"%s\" {
    insmod part_gpt
    insmod fat
    insmod search_fs_uuid
    insmod chain
    search --fs-uuid --no-floppy --set=root %s
    chainloader (\${root})%s
}
" "$T" "$UUID" "${GREFI/\/boot\/efi/}" >> $custom
done
}

Give it a try! (updategrub is in my repo).

You understand that it can only work if the Windows boot loader is in the mounted ESP (meaning you’re using the same ESP for Windows an Linux). Otherwise we’d need to get os-prober looking for other ESPs - which wouldn’t be difficult actually.

Well, as I’m sure you expected, I have dual booting working fine with the simple procedure of shrinking win7, booting live cd to then use gparted to make the linux partitions I would need for opensuse (which gparted automatically corrected the protective mbr to be correct and accurate), and then installing opensuse12.2 into those new partitions. I mounted the win7 esp into /boot/efi without allowing a reformat, and 12.2 came up fine. I then hand-added the correct win7 bootentry into 40_custom, remade grub.cfg and it all just works. I am embarrassed to say that the above sentence is a poorly worded summary of your well-written docs on dual-booting uefi/gpt.

All of my problems came from the original bogus win7 protective mbr, which cascaded when I used the opensuse12.2 installer to create my partitions (as I’ve done for years) and it made a hybrid mbr from the bogus mbr. Simply using gparted to partition first, which automatically made a correct protective mbr, made everything work nicely. I was just used to always partitioning in the installer, and just could not understand what went wrong, not sticking exactly to your good docs about dual booting uefi.

I will load up your repo and try out your updater to get an automatic correct win7 bootentry. I first have to get the eth0 going since 12.2 doesn’t have a driver. I had to do this on 12.1 on this machine, but that driver doesn’t work with this 12.2, so I’ll need to get another later version, then I’ll try it out.

Thanks for your help and patience and good docs, and also arvidjaar and all the others who responded.

Good news! So you confirm that the following method works:

  1. shrinking the Windows partition under Windows (if needed)
  2. Booting a Linux live system with gparted and creating Linux partitions (if it fixes the protective MBR)
  3. Installing openSUSE (from DVD) in expert mode (“Create partition setup”) and selecting the partitions (don’t forget to mount the ESP in /boot/efi!)

Which live CD and gparted version did you use?
Did openSUSE 12.2 setup offer a multiple choice of boot managers, i.e lilo, elilo, grub, grub2 grub2-efi? Was “grub2” greyed out? IMO, it should be disabled to avoid confusion (and problems). I forgot to add in the few steps above that you have to install grub2-efi of course and not grub2.

You don’t need it anymore, because what it would have done is create the win7 boot entry that you already have in 40_custom. If this entry exists, it would not write it again, unless it doesn’t understand the one you created, in this case it would just add a second one. But you’re welcome to test it. In this case:

  • Make sure updategrub is a symlink pointing to updateGrub2. It seems to be wrong on UEFI systems and points to updateLegacyGrub. If so, overwrite the symlink:

$ su -l
# cd /usr/bin
# ln -sf updateGrub2 updategrub

  • Run updategrub with the -d
    option to display the menu on standard output instead of writing grub.cfg

# updategrub -d

**And please, be aware that I have NOT tested this script myself under 12.2. **

Actually, for years - and even years and years - I never used openSUSE installer - nor any other Linux distro setup - to create partitions (which means writing the partition table), on BIOS systems as well. I always suggest to create the partitions first and select/format them during setup - under openSUSE, in “expert mode”, after selecting “Create partition setup” - which doesn’t necessarily implies creating partitions but (optionally) formating the ones you select. When you format a partition, you just change its content (put a new file system in it) but not its geometry (start sector and size). So no change is written to partition tables. The problem here was similar.

Yes, you can thank @arvidjaar. He’s the guy who discovered what the problem was. The rest was easy. :wink:

I would still say that it’s a bug because, although WIndows protective MBR is not UEFI compliant, what sense does it make to change it into a hybrid MBR? You only need a hybrid MBR if you want to add non GPT aware OSes on an EFI booting machine (such as Windows XP or Legacy Grub based Linux on Apple hardware) , which is not the case here. IMO the openSUSE partitioner should just fix the protective MBR instead.

Actually it became easy after @wkolar](http://forums.opensuse.org/members/wkolar.html) mentioned that partition table was changed :slight_smile:

Bug report is filed, but my understanding is, media images are not updated, so people will be hit by this issue at least during 12.2 lifetime.

A clean-up post to answer some last questions.

Yes, that worked fine.

gparted created new partitions and automatically fixed the protective mbr.

During the install, I only needed to “Edit Partition Setup” (instead of “Create”) to select the desired install partitions and swap partition, and turn off the reformat of the win7 ESP partition. It was already picked to mount correctly in /boot/efi.

As noted before, after the install I needed to hand-edit add the win7 boot entry to 40_custom and remake grub.cfg in order to boot win7.

Overall the opensuse 12.2 install is clean, powerful and easy. It’s easy to see the quality work that went into it.

The linux live cd I used was “parted magic”, version 2012_09_12. This is a quick boot-up with lots of tools, very well done.

The gparted “About” says it is version 0.13.1-git. At command line startup it lists “libparted: 3.1”. This version automatically corrected the bogus protective mbr partition table to the correct sectors for the disk when I created new partitions.

The gdisk (gpt fdisk) was version 0.8.5. I added new partitions fine, but gdisk did not touch the bogus protective mbr.

The opensuse 12.2 setup-install defaulted to pre-select the GRUB2-EFI bootloader type. It was changeable to all the other bootloader types, but this is what it sets up to do, which was correct and needed for this system. Remember that this was a uefi boot of the opensuse 12.2 install dvd, so it picked grub2-efi and was correct. It correctly wanted to mount the win7 ESP at /boot/efi, but it also wanted to reformat that win7 partition, which must not be allowed. It was straightforward to turn off the reformat of that existing partition, and then confirm you want to not reformat when warned later. I thought the warning was a nice touch, just to be sure.

Lastly, some hardware info that these tests were run on…

From hwinfo, smbios

type 0 (bios), “AMI”, “7.15”, “07/02/2012”
type 1 (system), “Hewlett-Packard”, “h8-1360t”, “1.00”
type 2 (board), “PEGATRON CORPORATION”, “2AD5”, “1.03”

@wkolar, this is a great post! I’m not sure how to sort several excellent posts in this thread to make a tutorial out of them. But the whole thread answered a lot of questions.

Yes, but see, it wanted to reformat the ESP. That’s why I never trust “Edit Partition Setup”. “Create Partition Setup” is the safest when you know what you are doing, because it is just empty by default. “Edit Partition Setup” is extremely dangerous. You’re assuming that the setup is clever and will do what you expect. Be careful with this option! It might work … or mess up everything. Glad it worked though (but you were careful).

Not a big deal. To complete this tutorial, a Windows chainloader entry looks like this:

menuentry "Microsoft Windows x86_64 UEFI-GPT" {
    insmod part_gpt
    insmod fat
    insmod search_fs_uuid
    insmod chain
    search --fs-uuid --no-floppy --set=root **5E17-7059**
    chainloader (${root})/efi/Microsoft/Boot/bootmgfw.efi
}

What you need to change from this example is the UUID (don’t confuse with the GUID) of the ESP partition.
The command blkid will tell you:

# **blkid**
/dev/sda1: UUID="**5E17-7059**" TYPE="vfat" 
/dev/sda3: UUID="74F618A1F61865A0" TYPE="ntfs" 
/dev/sdb1: UUID="622E-560E" TYPE="vfat" 
/dev/sdb2: UUID="60a1d899-b301-4ce6-86aa-a70885b616bb" TYPE="swap" 
/dev/sdb3: LABEL="SUSE_ROOT" UUID="2e544d67-fed0-4c94-b056-311ea6d1b585" TYPE="ext4" 
/dev/sdb4: LABEL="HOME" UUID="22a02611-fdef-48ea-8b44-d77ae09d46a7" TYPE="ext4" 

So does the script lspart (in my repo) with the option -U:

# **lspart -U
**Dev  Boot Maj Min  Bsize/Start         Size    Fs                                    ID    Ver                                  Uuid   Model/Mount

sda         8   0        512 B       111.79 GiB                                     gpt    ata                                     -   ADATA_SSD_S510_120GB
sda1        8   1         2048       204800  vfat  **C12A7328**-F81F-11D2-BA4B-00A0C93EC93B  FAT32                             **5E17-7059 **
sda2        8   2       206848       262144     -  E3C9E316-0B5C-4DB8-817D-F92DF00215AE      -                                     - 
sda3        8   3       468992    233971712  ntfs  EBD0A0A2-B9E5-4433-87C0-68B6B72699C7      -                      74F618A1F61865A0 

sdb         8  16        512 B       111.79 GiB                                     gpt    ata                                     -   ADATA_SSD_S510_120GB
sdb1        8  17         2048       319488  vfat  **C12A7328**-F81F-11D2-BA4B-00A0C93EC93B  FAT32                             622E-560E   /boot/efi
sdb2        8  18       321536      4208640  swap  0657FD6D-A4AB-43C4-84E5-0933C84B4F4F      2  60a1d899-b301-4ce6-86aa-a70885b616bb 
sdb3        8  19      4530176     83892224  ext4  EBD0A0A2-B9E5-4433-87C0-68B6B72699C7    1.0  2e544d67-fed0-4c94-b056-311ea6d1b585   /export/nfs4, /
sdb4        8  20     88422400    146018304  ext4  EBD0A0A2-B9E5-4433-87C0-68B6B72699C7    1.0  22a02611-fdef-48ea-8b44-d77ae09d46a7   /home, /export/nfs4/home

Also notice from the example above that the GUID of the EFI system always starts with C12A7328. If you mount this partition, the Linux setup will identify it as ESP. But if you create ‘any’ fate32 partition, it won’t work. You would have to explicitely specify that it is a EFI partition somewhere … unless the setup decide that it is a ESP if you mount it in /boot/efi … but I don’t trust too clever setups. This example has Windows and Linux on separate disks (hence the two ESPs.) and as you can see, Grub doesn’t care.

And the quality of the help you receive in the forum. :wink:

OK.

It should have worked though. Did you try this:

That was what I wondered. Thank you.

Definitely. But remember that “Create Partition Setup” doesn’t mount nor format anything by default. IMO no suggestions is better than wrong suggestions. Again use “Edit Partition Setup” with care or don’t use it at all!

Good work, @wkolar, and thank you for taking the time to test this method!

@arvidjaar … thank you, thank you very much for this real simple solution!!! It work fine, also for a Dual boot with Windows 8! But if i type fdisk -l /dev/sda , fdisk found 3 partition and gdisk tells me that had a hybrid mbr! So i think Suse installer destroyed the protected mbr!!!
Thank all for their commitment in this thread lol!

So… How about going the other way, adding a windows drive to the Opensuse 12.2 system.

A couple weeks ago the hardware in my old system decided to melt down and needed to be replaced. So I bought a new HP. First thing I did was to remove the hard drive that came with the system. Then I installed my 12.1 drives in. I ran into some problems and decided to do a reinstall and when I formatted the system, Grub2 & EFI was installed on /dev/sda. Everything works the way I want and upgrades (e.g. KDE 4.9.2) have gone great. So now I want to install the windows drive and dual boot.

I installed the drive and the system saw it as /dev/sdc and allowed me to mount it. I can’t figure out how to dual boot it. The drive still has the gpt partition on it:
Since /dev/sda1/bootefi/EFI did not have a microsoft entry I copied it from /dev/sdc1

parted -l

Model: ATA Hitachi HDS72101 (scsi)
Disk /dev/sdc: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name                          Flags
 1      1049kB  106MB   105MB   fat32        EFI system partition          boot
 2      106MB   240MB   134MB                Microsoft reserved partition  msftres
 3      240MB   982GB   982GB   ntfs         Basic data partition
 4      982GB   1000GB  18.1GB  ntfs         Basic data partition

grub.cfg has:

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows 7 (loader) (on /dev/sdc3)' --class windows --class os $menuentry_id_option 'osprober-chain-5C287B0F287AE782' {
        insmod part_gpt
        insmod ntfs
        set root='hd2,gpt3'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt3 --hint-efi=hd2,gpt3 --hint-baremetal=ahci2,gpt3  5C287B0F287AE782
        else
          search --no-floppy --fs-uuid --set=root 5C287B0F287AE782
        fi
        chainloader +1
}
### END /etc/grub.d/30_os-prober ###


the error I get when I boot to windows relates to hd2 and gpt3 and then returns to the grub menu.

When I run updategrub2:

grub2-efi-probe: error: failed to get canonical path of /boot/efi/EFI/windows/bootmgfw.efi.
chainloading Windows ...
Generating grub.cfg ...
Found theme: /boot/grub2/themes/openSUSE/theme.txt
Found background: /boot/grub2/themes/openSUSE/background.png
Found linux image: /boot/vmlinuz-3.4.6-2.10-desktop
Found initrd image: /boot/initrd-3.4.6-2.10-desktop
  No volume groups found
Found Windows 7 (loader) on /dev/sdc3
done


After deleting the microsoft folder in EFI the error line goes away.

Everything I have read assumes that you have windows installed first. I would really hate to re-install everything.

BTW /dev/sda is:

Model: ATA WDC WD6400AAKS-6 (scsi)
Disk /dev/sda: 640GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End    Size    File system     Name     Flags
 1      1049kB  115MB  114MB   fat16           primary
 2      115MB   107GB  107GB   ext4            primary
 3      107GB   110GB  2146MB  linux-swap(v1)  primary
 4      110GB   238GB  129GB   ext4            primary
 5      238GB   249GB  10.7GB  fat32           primary
 6      249GB   640GB  391GB   ext4            primary


I doubt very much it will work

Model: ATA Hitachi HDS72101 (scsi)
Disk /dev/sdc: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

OK so if you indeed have Windows installation in UEFI mode the very first test is to try to boot it directly using UEFI firmware boot manager. All systems I have seen offered possibility to “boot from file” where you can select partition on drive and later traverse down to individual files. You will have to guess which partition it is, but as long as only one has bootmgfw.efi it is OK. Try start this file directly. If this does not work, there is no point in adding it to GRUB2 menu either and you will have to use Windows repair mode to try to repair bootloader.

grub.cfg has:


        chainloader +1

That won’t work, it is for legacy Windows boot manager.

When I run updategrub2:

grub2-efi-probe: error: failed to get canonical path of /boot/efi/EFI/windows/bootmgfw.efi.

You have to ask updategrub2 author.

Everything I have read assumes that you have windows installed first. I would really hate to re-install everything.

Then you should first ask on Windows forums how to make Windows bootable again after reshuffling your drives. If your Windows boots, it is trivial to add it to GRUB2.

Hi there!

This thread is VERY useful!
I want to thank to all participated to figure out what was causing the issues, i.e. to arvidjaar, please_try_again and wkolar, among others.

I want to install Windows 8 and OpenSUSE 12.2 , both in UEFI mode.
I have an Asus P8H77M-PRO motherboard, which is UEFI compatible, and I’ll install everything from stratch to an older SATA 300 GB HDD. Including from first step to format the hdd to GPT partition.

I have read the complete topic and it’s very useful.

I plan to do whole thing on tomorrow, and wanted to ask whether is there anything that should be tested?

I’ll test of course the followings:

  • Test whether Win8 still writes Protective MBR with 0xFFFFFFFF sector size.
  • Test whether gdisk can write back correct Protective MBR or not. Here wkolar stated that gdisk did not correct the PMBR, and then he used gparted. Maybe it’s related to gdisk version or I don’t know. But I have both SystemrescueCD and Parted Magic, and I’ll see. gdisk with “n” option.
  • Test which boot manager will be offered by OpenSUSE installer.
  • It’s not clear to me yet whether Win8 entry should be still added to OpenSUSE boot manager, or it’s all handled by the internal UEFI itself? I.e. UEFI doesn’t offer a selection screen when booting?
  • Also is not fully clear whether Win8 requires 2 or 3 special partition. This link says that ESP and MSR partitions are enough, but that link deals Win7. This another link shows that Win8 installer creates 3 special partition, first is Recovery Partition, then ESP and MSR. So I’ll see with the Win8 installer.

So the planned steps are following:

  1. Optional: Hard Disk cleaning, deleting MBR, somewhere in this topic I read it:
dd if=/dev/zero of=/dev/sda count=10
  1. Since only Windows can create MSR partition, the GPT format must be done from Windows anyway. This will be done from the Win8 installation disk in next step.

  2. Install Win8 in UEFI mode.

  3. Check Protective MBR and backup it:

fdisk -l /dev/sda
parted -l
gdisk -l /dev/sda

Backup PMBR:

dd if=/dev/sda of=/somewhere/mbr.win bs=512 count=1

Backup first 1 MB just in case:

dd if=/dev/sda of=/somewhere/dd_sda_2048.bin bs=512 count=2048

Save GPT layout:

gdisk /dev/sda
p
b
--> /somewhere/gdisk_gptbackup.gpt
  1. Write new and correct Protective MBR.
gdisk /dev/sda
x
o
n
w

Checking with fdisk -l.
If doesn’t work then from gparted.

  1. Reboot into Win8 , but DO NOT into Recovery Mode. Also to check whether Win8 boots at all.

  2. Create new Linux partitions for OpenSUSE install, from SystemRescueCD or Parted Magic.

  3. Install OpenSUSE 12.2 in UEFI mode. Here we should take care that OpenSUSE installer do not create 2nd ESP partition. So existing ESP should be mounted to /boot/efi, and not allowing to format it.

Also, to check which is the default boot manager, it should be grub2-efi.

  1. Boot into Win8 again whether it still works or not.

  2. At this point is not clear to me whether Win8 entry should be added to OpenSUSE boot manager? Or is it automatical or not needed at all?

Regards
batagy

os-prober that comes with openSUSE 12.2 does not support ESP and will not add Windows to grub2 menu. Sometimes both UEFI and legacy bootloaders are present on Windows partition. In this case os-prober will find legacy Windows bootloader and adds it to menu, but it will (of course) fail to boot.

IIRC PTA provided patched os-prober in his repository. It may handle ESP better. I tried to submit patches upstream but got zero feedback.
Whether to use native UEFI menu (assuming your system does offer one :P) or grub2 is entirely up to you. As far as I can tell functionality should be the same.

Thanks for the info.

Yeah!
I have done the whole thing, I agree with you and it’s tested!
As you say, the default OpenSUSE 12.2 installer did not add the Win8 entry into the GRUB2 menu by itself.
Adding it into the OpenSUSE Grub2 menu is not necessary, as long as someone can choose the boot from UEFI.

My Mobo is Asus P8H77M-PRO, I have disabled the Legacy BIOS, enabled only UEFI.
I didn’t add the Win8 into GRUB2.
What the system is doing, if I don’t press any key, then it boots the OS what is the default UEFI boot entry. In UEFI, I can set either Windows Boot Manager or OpenSUSE to boot from.
If Win8 is set as first boot priority, then it boots Win8 directly, no GRUB2 comes up.
If OpenSUSE is set as first boot priority, then it boots OpenSUSE GRUB2 (menu not containing Win8 in my case).

If I want to boot the other OS what is set, then at start, I can just press “DEL”, then it goes into UEFI basic mode. Then I can choose the OS what I want, without overwrite the UEFI setting!

So either adding Win8 to GRUB2, or boot with inbuilt UEFI, both works, both has some advantage.
The inbuilt UEFI boot selection method’s advantage that I don’t need to select the OS and it’s faster.

PS: I documented everything, and I’ll post it here.

That’s for sure. The UEFI shell has its own ‘boot manager’ embedded. If it’s just about booting a system, you don’t need to add any boot entry anywhere. We don’t use Grub because we need it - on UEFI systems - but because we like it. It’s like art. :slight_smile:

I don’t know exactly what os-prober says in case of WIndows8, but having updateGrub2 adding a boot entry - if it doesn’t do it already - would be easy to implement. As far as I remember, it already did it (at least fro Windows7) before we - @arvidjaar and I - added EFI support to os-prober.

Yes. Another option is to use Linux interface to the UEFI shell: efibootmgr. It let you set the system to boot next, without changing the boot order permanently. But it let you rewrite the boot order too.

I agree. That’s an excellent thread. Thank you for bringing it back to the top.

When you uninstall the Linux OS from a dual boot machine, do you have to manually delete the files stored in the ESP? :\

What do you mean? I am not aware of any tool to “uninstall Linux OS”.

I meant when I delete the Linux partitions (for instance, to install a new Distro or repartitioning the hard disk) …

In this case you will be left with UEFI menu entry pointing to bootloader which won’t boot anymore. It does not do any harm as long as you do not select it; I would still clean it up. And of course you will need to do it manually (both remove files in ESP and remove UEFI menu entry).

I am also getting the same problem. The file is not present here /boot/efi/EFI/windows/bootmgfw.efi
Is there any way to create this file, how can I add windows to bootloader?

Thanks in Advance,

Ashish.