UEFI, GPT, and GRUB2 with Win7 and 12.3

To begin, a bit ‘o background. Just bought a new laptop, a Samsung. It had Win8 pre-installed with no option for getting Win7 for free. So the plan was to backup the drive, just-in-case, install Win7 and 12.3 using GPT partitioning and UEFI. And it worked with no problems. Both OS’ boot and work well with GRUB2 being the OS selection method.

Now we come to the issue. Win7 needs to be re-installed. In the past with standard BIOS and MBR partitioning this would mean repairing the LILO or GRUB install in the MBR of the hard drive with a live CD after the Windows installation finishes hosing it. However now things are, possibly, different.

The most basic form of the question is as such. After Win7 is re-installed what needs to be done to bring GRUB2 back to the forefront for OS selection and will this have any other affect on the OpenSUSE installation?

For reference my partition table is below.


Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 26EBF845-703A-4DFA-9A21-0C1073CDDAC9
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2029 sectors (1014.5 KiB)


Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          210943   102.0 MiB   EF00  EFI system partition
   2          210944          473087   128.0 MiB   0C01  Microsoft reserved part
   3          473088       256473087   122.1 GiB   0700  Basic data partition
   4       256473088       273250303   8.0 GiB     0700  primary
   5       273250304       357140479   40.0 GiB    0700  primary
   6       357140480       976773119   295.5 GiB   0700  primary

On Tue 16 Jul 2013 12:06:01 AM CDT, cwoelkers wrote:

To begin, a bit ‘o background. Just bought a new laptop, a Samsung. It
had Win8 pre-installed with no option for getting Win7 for free. So the
plan was to backup the drive, just-in-case, install Win7 and 12.3 using
GPT partitioning and UEFI. And it worked with no problems. Both OS’ boot
and work well with GRUB2 being the OS selection method.

Now we come to the issue. Win7 needs to be re-installed. In the past
with standard BIOS and MBR partitioning this would mean repairing the
LILO or GRUB install in the MBR of the hard drive with a live CD after
the Windows installation finishes hosing it. However now things are,
possibly, different.

The most basic form of the question is as such. After Win7 is
re-installed what needs to be done to bring GRUB2 back to the forefront
for OS selection and will this have any other affect on the OpenSUSE
installation?

For reference my partition table is below.

Code:

Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 26EBF845-703A-4DFA-9A21-0C1073CDDAC9
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2029 sectors (1014.5 KiB)

Number Start (sector) End (sector) Size Code Name
1 2048 210943 102.0 MiB EF00 EFI system
partition 2 210944 473087 128.0 MiB 0C01
Microsoft reserved part 3 473088 256473087 122.1 GiB
0700 Basic data partition 4 256473088 273250303 8.0
GiB 0700 primary 5 273250304 357140479 40.0 GiB
0700 primary 6 357140480 976773119 295.5 GiB 0700
primary

Hi
Not sure if windows 7, but I would assume it does, recreate the ESP. I
would guess your backing up all your important data…yes?

I use a script to backup my ESP here using gummiboot;
http://paste.opensuse.org/96859832
You will need to modify as required.

You will also need to manually boot as I would also assume windows will
take over the primary boot, this can be reset via efibootmgr back to
openSUSE, assuming it currently is (command to see is efibootmgr -v).

I assume your installing from a windows 7 OEM dvd? If so you need to
ensure your select the partition to install windows 7 so it goes back
where is was (sda3?)

Oh don’t forget to backup your data…


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 12.3 (x86_64) Kernel 3.7.10-1.16-desktop
up 9:45, 3 users, load average: 0.25, 0.20, 0.16
CPU AMD E2-1800@1.70GHz | GPU Radeon HD 7340

It’s hard to say, until you do it and see what goes wrong.

For safefy, backup “/boot/efi/EFI/opensuse”.

Record the output of


# efibootmgr -v

While doing that, can you post that “efibootmgr -v” output here. This is mostly curiosity at this point. I know what the Windows 8 entry looks like. I’m not sure about the Windows 7 entry. It would be useful to have that info for other with Windows 7 and UEFI booting.

If problems arise after your Windows 7 reinstall, the most you should need to do would be:

  1. Restore all of the files for “/boot/efi/EFI/opensuse” (which is “/EFI/opensuse” relative to the EFI partition;
  2. Recreate the NVRAM entry using “efibootmgr -c”. The efibootmgr man pages will help for that.

You may need to have on hand a way of booting into the system in UEFI mode. I would use the 12.3 rescue CD, probably written to a USB. That will give you access to the “efibootmgr” command and to tools for restoring the backed up files.

I’m looking at your partition table. If some of those partitions are for linux, I would suggest change the partition type code from 0700 to 8300 for linux partitions (or 8200 for a swap partition).

Thanks for the quick reply Malcolm.

Just so I have everything straight.

  1. I make a backup of the contents of the EFI partition and the output of efibootmgr -v.
  2. I re-install Win7 into the same partition as the original installation, yes it is /dev/sda3.
  3. I than manually boot into OpenSUSE, via the BIOS?, and use efibootmgr, with the backup as a reference, to reset the original settings.
  4. I than restore the backup of the EFI partition, if necessary, minus Microsoft’s portions.

After a reboot all should be good. I should get GRUB2 with no changes and be able to boot into Win7.

Does that sound right?

It is uncertain as to whether you will be able to boot into opensuse via the BIOS. You won’t know until you try it.

If that does not work, then boot to a rescue system (the 12.3 64-bit rescue CD is a good choice). You need to boot into UEFI mode to be able to use the command “efibootmgr”.

If all of the files are in place for the “opensuse” directory of the EFI partition, then you might need to use something like:


# efibootmgr -c -L opensuse -l '\EFI\opensuse\bootx64.efi'

to restore the ability to access the grub menu. The output of “efibootmgr -v” will help with constructing the needed command, and the man pages for “efibootmgr” are reasonably complete.

If you can select opensuse at the BIOS, then there might be a BIOS setting to make that a default. Otherwise, you might only need to use “efibootmgr -o” to specify the desired boot order with opensuse first.

You should be able to choose the system to load via the UEFI firmware (usually pressing F 12 during the boot process).
You can modify the boot order via the UEFI firmware itself or by the efibootmgr command (as already has been said).
However, it’s not possible to boot Windows 7/8 from Grub2 (at least in my experience).

I am routinely booting Windows 8 from the grub2-efi menu on my UEFI box.

I don’t know about Windows 7. That’s part of why I would like to see the output of “efibootmgr -v” from a system with Windows 7 installed as UEFI.

Good to know. :slight_smile:
How did you do it? :stuck_out_tongue:

There’s a bunch of UEFI posts at my blog

When I first installed, there was no grub menu item for Windows 8. I think that was opensuse 12.3 Beta1. I reported that as a bug, and it was fixed by the time of the final 12.3 release.

With the grub menu entry, Windows 8 would not boot unless I disabled secure-boot. I reported that as a bug, too, and it has now been fixed (with my system doing some of the testing for the fix).

The problem that I sometimes had, though not as badly as other folk, was that after booting Windows, the Windows boot manager would take over the booting. I seem to have worked out how to solve that with my box, and I have helped some other folk here with similar problems on different hardware. But UEFI implementations vary a lot, so no guarantees.

Well I was successful in re-installing Windows 7 than getting GRUB2 back with very little effort.
I did have to be certain to select the existing Win7 data partition when choosing where to install it.
After it was installed only Windows would boot.
I entered the BIOS and found opensuse as one of my options. Selecting it brought me back to GRUB2 where I booted into OpenSUSE just like normal.
A quick change of the BootOrder with efibootmgr and GRUB2 was back to being the default. I was also still able to use the Windows option to boot Win7 with no changes to GRUBs config.
All-in-all this was **a lot **easier than with an older BIOS and MBR formatted HDs.

Here is the output from my system to sate your curiosity.


# efibootmgr -v
BootCurrent: 0001
Timeout: 1 seconds
BootOrder: 0001,0002,0009,000A
Boot0001* opensuse      HD(1,800,33000,1b61de5c-3dbb-44d0-bf3f-239d97f5e8c6)File(\EFI\opensuse\grubx64.efi)
Boot0002* Windows Boot Manager  HD(1,800,33000,1b61de5c-3dbb-44d0-bf3f-239d97f5e8c6)File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}....................
Boot0009  UEFI: IP4 Realtek PCIe GBE Family Controller  ACPI(a0341d0,0)PCI(4,0)PCI(0,0)MAC(208984a5cd9b,0)IPv4(0.0.0.0:0<->0.0.0.0:0,0, 0AMBO
Boot000A  UEFI: IP6 Realtek PCIe GBE Family Controller  ACPI(a0341d0,0)PCI(4,0)PCI(0,0)MAC(208984a5cd9b,0)030d3c000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000AMBO

Excellent. Thank you.

Then it seems that Windows 7 is using the same path/filename “\EFI\Microsoft\Boot\bootmgfw.efi” as Windows 8.

I’m glad things worked out for you.

Yes, UEFI should be easier to deal with than the older MBR stuff. Unfortunately, some manufacturers are providing incomplete firmware implementations.

From your experience, it looks as if the Samsung implementation is good – that is, apart from the problem that installing UEFI based linux bricked some of the earlier Samsungs.