GRUB2 changes, introducing EFI

Jacek Konieczny jajcus at jajcus.net
Sun Oct 28 14:56:25 CET 2012


On Sun, Oct 28, 2012 at 01:39:54PM +0100, Paweł Sikora wrote:
> > Booted without problems :)
> 
> so, can you wraite a mini-howto for migrating from grub-legacy to grub2-eufi
> for machines with "/" on lvm on raid ? :)

I don't have EFI on my laptop. And no RAID, but Luks.

Migrating from grub-legacy to grub2+grub2-platform-pc for a machine
with / on LVM on Luks:

poldek> uninstall grub
poldek> install grub2 grub2-platform-pc
poldek> ^D

# vim /boot/grub/grub.cfg
:new /boot/grub/menu.lst.rpmsave
   tutaj sobie skopiować swoje ustawienia ze starego gruba do składni
   nowego
:wq

# /sbin/grub-install --no-floppy '(hd0)'

Earlier, for some experience, I have converted my HDD partitions from MBR to GPT,
but it is another story, not needed for GRUB2/PC.


Migrating a server with / on LVM on hardware RAID from GRUB-legacy/BIOS
to GRUB2/EFI was much more complicated…

– first I had to get GPT partitioning… but there was not even place for
GPT, because someone (or 'parted' rather) have put the first partition
on the first sector after MBR
– then I had to recompile kernel a few times until it worked (I don't
use PLD kernel there, most features were disabled)
– I have Xen there – it made things both easier (Xen 4.2 boots from EFI
with no problems and no extra configuration) and harder – Linux started
under Xen does not see EFI – efibootmgr won't work and grub won't
install itself as the default boot loader
('cp /boot/efi/EFI/grub/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI'
helps).


But the short tutorial would be (I have no idea if the software RAID
needs special handling here):

1. Make sure your disk has GPT and an EFI system partition.

  In the simplest case running 'gdisk' and adding the EFI system partition
  should do. But in real life things are more complicated. I managed to
  resize and move both /boot and LVM partitions with
  gdisk/e2resizefs/pvmove/etc with no data loss (by removing them,
  recreating smaller, creating temporary partitions behind them, moving
  data, removing and recreating target partitions in the right places,
  moving data gain). But it was a test system that could be destroyed. I
  would not dare that on a production system ;)

  You may also want to add a 'BIOS boot partition' somewhere at the
  beginning of the disk too, to install grub2 for BIOS booting.

2. Install grub2 and grub2-platform-efi and 'efibootmgr'

3. mount the EFI partition at /boot/efi

4. 'grub-install --target=x86_64-efi --efi-directory=/boot/efi'

4a. optionally: 'grub-install --no-floppy --target=i386-pc (hd0)' to
    have the system bootable via BIOS too.

5. 'cp /boot/efi/EFI/grub/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI'

6. edit /boot/grub/grub.cfg

it may be good idea to add (otherwise grub complains 'the OS won't have
console' or something like that):

-- cut --
insmod efi_gop
insmod efi_uga
insmod font
if loadfont dejavu
then
    insmod gfxterm
    set gfxmode=auto
    set gfxpayload=keep
    terminal_output serial gfxterm
fi
-- cut --

and:

mkdir -p /boot/grub/fonts
grub-mkfont -o /boot/grub/fonts/dejavu.pf2 /usr/share/fonts/TTF/DejaVuSans.ttf
 
7. Reboot, the system should boot via EFI/GRUB2

8. make the proper EFI boot loader entry:

- modprobe efivars
- grub-install --target=x86_64-efi --efi-directory=/boot/efi
– rm /boot/efi/EFI/BOOT/BOOTX64.EFI

9. reboot again

Greets,
        Jacek


More information about the pld-devel-en mailing list