System Rescue with and of Linux - Notes


  1. Restore UEFI System Partition

Restore UEFI System Partition

  1. Create GPT partition table with parted or gdisk
  1. Mark first partition type EF00
  1. Format Fat32 file system:
    # mkdosfs -F 32 /dev/sda1
  1. Copy EFI shell from Shell_Full.efi to the root directory of your EFI system partition and name it shellx64.efi
  1. Reboot and start the EFI shell from the system EFI (Press F2 or DEL at startup)
  1. Create basic directory structure:
    shell> fs0:
    fs0:\> mkdir EFI
    fs0:\> cd EFI
    fs0:\EFI> mkdir grub2
  1. Back in the live CD again, install the grub2 modules to the EFI system partition:
    # mount /dev/vg_foobar/boot /mnt/gentoo/boot
    # mount /dev/sda1 /mnt/gentoo/boot/efi
  1. Create Grub 2 EFI image:
    # grub2-mkimage -p /efi/grub2 -o /boot/grub2/grubx64.efi -O x86_64-efi part_msdos part_gpt fat
    or create standalone image which includes all modules:
    # grub2-mkstandalone -o /boot/grub2/grubx64_standalone.efi -O x86_64-efi
  1. Copy to EFI partition:
    # cp /boot/grub2/grubx64.efi /boot/efi/EFI/grub2/grubx64.efi
    # cp -a /usr/lib64/grub/x86_64-efi /boot/efi/EFI/grub2/
  1. Generate Grub configuration file:
    # grub2-mkconfig -o /boot/efi/EFI/grub2/grub.cfg
  1. Reboot into the EFI shell again. This time the still needs to be started manually:
    shell> fs0:
    fs0:\> cd EFI\grub2\
    fs0:\EFI\grub2> grubx64.efi
    • If for some reason grub cannot find its configuration file, it can be loaded manually:
      grub> configfile efi/grub2/grub.cfg
      If it still doesn't work, the kernel has to be booted manually (here an example with a /boot partition on LVM and a dracut initramfs):
      grub> insmod ext2
      grub> insmod lvm2
      grub> set root=(lvm/vg_foobar-boot)
      grub> kernel /bzImage-3.3.0-gentoo root=/dev/vg_foobar/slash
      grub> initrd /initramfs-3.3.0-gentoo.img
      grub> boot
  1. When finally having EFI-booted into the Linux, the EFI boot menu can be configured with help of efibootmgr:
    • Show entries:
      # efibootmgr -v
      Timeout: 3 seconds
      BootOrder: 0004,0005,0006
      Boot0004* Hard Drive    BIOS(2,0,00)SATA: OCZ-AGILITY3
      Boot0005* CD/DVD Drive  BIOS(3,0,00)PATA: TOSHIBA DVD-ROM SD-M1612.
      Boot0006* Removable Drive       BIOS(1,0,00)
    • Delete entry:
      merkur grub2 # efibootmgr -B -b 0004
      Timeout: 3 seconds
      BootOrder: 0005,0006
      Boot0005* CD/DVD Drive
      Boot0006* Removable Drive
    • Add grub entry:
      # efibootmgr --create --gpt --disk /dev/sda --part 1 --write-signature --label "Grub 2" --loader '\EFI\grub2\grubx64.efi'
      Timeout: 3 seconds
      BootOrder: 0000,0005,0006
      Boot0005* CD/DVD Drive
      Boot0006* Removable Drive
      Boot0000* Grub 2
    • Add EFI shell entry:
      # efibootmgr --create --gpt --disk /dev/sda --part 1 --label "EFI Shell" --loader '\shellx86.efi'
      Timeout: 3 seconds
      BootOrder: 0001,0000,0005,0006
      Boot0000* Grub 2
      Boot0005* CD/DVD Drive
      Boot0006* Removable Drive
      Boot0001* EFI Shell
    • Change boot order:
      # efibootmgr --bootorder 0000,0005,0006,0001
      Timeout: 3 seconds
      BootOrder: 0000,0005,0006,0001
      Boot0000* Grub 2
      Boot0001* EFI Shell
      Boot0005* CD/DVD Drive
      Boot0006* Removable Drive
  1. Now the machine can be rebootet again. When pressing F11 (for ASrock board) after system post, the EFI boot menu as configured before will appear. By default the first boot entry will be started, in this case Grub 2 :-)
Last modified 6 years ago Last modified on 05/13/2012 01:58:51 AM