Linux

Booting Gentoo 2.1 with GRUB2 under EFI

Partition preparation Use or to create a partition marked as EFI, sized 200-500MB, formatted as fat32: Format /dev/sda1: Write the mount info to fstab: Install

1. Partition preparation

# mkdir /boot/efi

Use parted or gdisk to create a partition marked as EFI, sized 200-500MB, formatted as fat32:

# parted /dev/sda
# mkpart EFI fat32 0mb 500mb
# set 1 boot on

Format /dev/sda1:

mkfs.vfat -F 32 /dev/sda1

Write the mount info to fstab:

echo "/dev/sda1    /boot/efi    vfat    noauto,noatime  1 2" >> /etc/fstab

2. Install grub2

Add the grub2 keyword:

# echo "sys-boot/grub ~amd64" >> /etc/portage/package.keywords

Compile grub2:

# emerge -avt grub

3. Create the EFI bootable USB drive

Use gdisk or parted to create a partition larger than 200MB and smaller than 500MB, marked as EFI; assume it's /dev/sdb1:

# parted /dev/sdb >> mkpart EFI fat32 0mb 500mb >> set 1 boot on

Format the USB partition as fat32:

# mkfs.vfat -F 32 /dev/sdb1

(The tool is in sys-fs/dosfstools)

Mount the USB drive to /mnt:

# mount /dev/sdb1 /mnt

Install grub2 to the USB drive:

# grub2-install --target=x86\_64-efi --grub-setup=/bin/true --efi-directory=/mnt --removable --modules=part\_gpt

Copy the kernel:

# cp /usr/src/linux/arch/x86\_64/boot/bzImage /boot/kernel-3.8.13-gentoo

Generate the grub2 menu:

# grub2-mkconfig -o /boot/grub2/grub.cfg

4. Configure and compile kernel options

Processor type and features  --->
    -*- EFI runtime service support  [\*]
    EFI stub support
Firmware Drivers  --->
    {M} EFI Variable Support via sysfs  [\*]
Google Firmware Drivers
    Google Firmware Drivers  --->
        <M> SMI interface for Google platforms

5. Reboot

# shutdown -r now

6. Install grub2 to the hard drive

Mount /boot/efi:

# mount /boot/efi

Load the required modules:

# modprobe efivars
# grub2-install --target=x86\_64-efi --efi-directory=/boot/efi --boot-directory=/boot/efi /dev/sda

Generate the grub2 menu:

# grub2-mkconfig -o /boot/efi/grub2/grub.cfg

7. Installation complete. Reboot and boot from the local hard drive.

N
norvyn

独立 iOS 开发者,写字的人。在一座有海的城市,慢慢地做一些小而确定的东西。An independent iOS developer and writer — slowly making small, certain things in a city by the sea.

评论Comments

加载中…Loading…

留下评论Leave a comment