I have an existing Windows 7 GPT installation, which already has a EFI System partition.
I am now trying to install a Linux on a separate harddisk, which is also GPT formatted. I did not find any working way to get grub booting without EFI system partition, so my question is:
Is it possible for grub2 to use the same EFI System partition as windows? How do I tell grub2 to use it?
To clarify my setup:
gpt /dev/sda:
1 EFI System partition created by windows (100MB)
2 "Microsoft reserved partition" (200MB)
3 Windows root (rest of disk)
gpt /dev/sdb:
# After answering my own question: this partition is not needed
1 boot partition containing grub, kernels etc.(32MB)
2 crypto LVM partition (rest of disk)
I want grub2 to use the existing /dev/sda1
EFI partition.
PS: My mainboard is EFI capable.
Best Answer
After a day of research, I can now answer my own Question: yes it is possible, and you can even use that partition as /boot and store your kernels/initramfs/etc. there.
Requirements:
CONFIG_EFI_VARS
compiled in or as moduleefivars
)efibootmgr
Setup:
First mount your EFI partition to /boot
If you look at the mount entry, you will see, that it is simply a FAT(32) partition. Under
/boot
you should find a directoryefi
.As grub will call
efibootmgr
, you should loadevivars
, if it is not compiled into the kernel:Now you can install grub:
Grub installs its files as usual to
/boot/grub2
. If everything worked correctly, you should now also have a folder/boot/efi/grub2
or/boot/efi/<name_of_your_distro>
. With--bootloader-id=insert_name_here
you can also specify the name for the folder yourself.Grub calls
efibootmgr
automatically and creates a boot entry with that name in the EFI boot menu (in my case, that means it shows up as a bootable device in the EFI menu, not sure if this is the case on every EFI board)Further setup does not differ from usual grub2 setup,
grub2-mkconfig
will add the appropriate modules for EFI to yourgrub.cfg
.Chainloading Windows:
As I asked for a dual boot with Windows, I will include the grub configuration for chainloading it:
Chainloading a Windows installation on EFI is slightly different from one on a MBR disk. You won't need the
ntfs
orpart_mbr
modules, insteadfat
andpart_gpt
are needed.Also, setting root is not required, this information is stored by Windows' own boot manager. Instead specify the
search
command. The parameters needed for it can be determined byThis will give you the parameters for search specifying the location of the EFI partition, it should look something like:
Instead of telling
chainloader
the number of sectors to read, you will need to set the path to Windows' EFI loader in the EFI partition. This is the same for all Windows EFI installations. The resulting entry should look like this:Sources: These cover some more cases, if you want to boot from EFI, they are worth reading: