Skip to content

Instantly share code, notes, and snippets.

@MoritzMaxeiner
Last active November 20, 2024 22:38

Revisions

  1. Moritz Maxeiner revised this gist Aug 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gentoo_uefi_fde.md
    Original file line number Diff line number Diff line change
    @@ -100,7 +100,7 @@ if you are connected via WLAN, call "wifi-menu" to set it up.
    6. Configure Gummiboot and your /etc/fstab like shown below:

    ```shell
    (chroot) archiso ~ # echo > /boot/loader/loader.conf <<EOF
    (chroot) archiso ~ # cat > /boot/loader/loader.conf <<EOF
    > default gentoo
    > timeout 3
    > EOF
  2. Moritz Maxeiner revised this gist Aug 8, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gentoo_uefi_fde.md
    Original file line number Diff line number Diff line change
    @@ -107,7 +107,7 @@ if you are connected via WLAN, call "wifi-menu" to set it up.
    ```

    ```
    (chroot) archiso ~ # echo > /boot/loader/entries/gentoo.conf <<EOF
    (chroot) archiso ~ # cat > /boot/loader/entries/gentoo.conf <<EOF
    > title Gentoo
    > efi \EFI\gentoo\vmlinuz-linux.efi
    > options initrd=\EFI\gentoo\initramfs-linux.img crypt_root=UUID=d580e705-e714-4af4-a48b-f5e71bb622be root=/dev/mapper/partitions-root ro dolvm
    @@ -117,7 +117,7 @@ if you are connected via WLAN, call "wifi-menu" to set it up.
    Note: If are installing Gentoo onto a USB device, add scandelay=X with X >= 1 to the kernel options line.
    ```shell
    (chroot) archiso ~ # echo >> /etc/fstab <<EOF
    (chroot) archiso ~ # cat >> /etc/fstab <<EOF
    > UUID=1A6E-374D /boot vfat defaults 0 2
    > /dev/mapper/partitions-root / ext4 defaults 0 1
    > /dev/mapper/partitions-swap none swap defaults 0 0
  3. Moritz Maxeiner revised this gist Aug 8, 2014. 1 changed file with 0 additions and 9 deletions.
    9 changes: 0 additions & 9 deletions gentoo_uefi_fde.md
    Original file line number Diff line number Diff line change
    @@ -86,15 +86,6 @@ if you are connected via WLAN, call "wifi-menu" to set it up.
    (chroot) archiso ~ # emerge gummiboot
    ```

    The third command [is expected to fail](https://bugs.gentoo.org/show_bug.cgi?id=518822) as of me writing this, so do the following to get it working (replace 45 with the proper version, should this bug happen to you on a newer version):

    ```shell
    (chroot) archiso ~ # cd /usr/portage/sys-boot/gummiboot/
    (chroot) archiso ~ # sed -i -e 's|^DIST gummiboot-.*$||g' Manifest
    (chroot) archiso ~ # ebuild gummiboot-45.ebuild digest
    (chroot) archiso ~ # emerge gummiboot
    ```

    Get Gummiboot on your /boot (replace kernel versions with yours):

    ```shell
  4. Moritz Maxeiner revised this gist Aug 6, 2014. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions gentoo_uefi_fde.md
    Original file line number Diff line number Diff line change
    @@ -44,12 +44,11 @@ if you are connected via WLAN, call "wifi-menu" to set it up.
    ```

    Note: All commands below referencing a block device do so with regards to the above example layout!

    You need to adjust any such command to your own layout!

    2. Follow chapter 5 of the Gentoo handbook.

    Note: We're using Arch Linux here, so keep "/mnt/gentoo becomes /mnt" in mind.
    Note: We're on Arch Linux here, so keep in mind that /mnt/gentoo is /mnt for us.

    3. Follow chapter 6 of the Gentoo handbook.

    @@ -136,7 +135,7 @@ if you are connected via WLAN, call "wifi-menu" to set it up.

    Note: Do not forget to clean your /etc/fstab after this step from whatever initial configuration was in there

    7. Follow the rest of the Gentoo handbook
    7. Follow the rest of the Gentoo handbook (but do not reboot yet)

    8. After leaving the chroot, do the following:
    ```shell
  5. Moritz Maxeiner revised this gist Aug 6, 2014. 1 changed file with 56 additions and 23 deletions.
    79 changes: 56 additions & 23 deletions gentoo_uefi_fde.md
    Original file line number Diff line number Diff line change
    @@ -33,82 +33,115 @@ if you are connected via WLAN, call "wifi-menu" to set it up.

    1. Prepare your disks. This is a minimal example of a layout your target block device could have:

    ```shell
    NAME TYPE FSTYPE MOUNTPOINT SIZE UUID
    sdb disk 59.6G
    ├─sdb1 part vfat /mnt/boot 500M 1A6E-374D
    └─sdb2 part crypto_LUKS 59.1G d580e705-e714-4af4-a48b-f5e71bb622be
    └─luks_container crypt LVM2_member 59.1G 8yHuxc-f6ZU-xkdU-l6dY-dVpE-50oT-2rLAzz
    ├─partitions-swap lvm swap [SWAP] 2G 81172beb-590c-411d-bd74-2bb0266544b9
    └─partitions-root lvm ext4 /mnt 57.1G 17c87950-4471-4a4c-a703-aabdf937a7e0
    ```

    Note: All commands below referencing a block device do so with regards to the above example layout!

    You need to adjust any such command to your own layout!

    2. Follow chapter 5 of the Gentoo handbook.

    Note: We're using Arch Linux here, so keep "/mnt/gentoo becomes /mnt" in mind.

    3. Follow chapter 6 of the Gentoo handbook.

    Notes:

    - There's no "mirrorselect" on Arch Linux, you will need to do its part manually

    - Do the chroot like this (Arch Linux specific):
    archiso ~ # PATH="$PATH:/bin:/sbin:/usr/sbin" arch-chroot /mnt /bin/bash

    ```shell
    archiso ~ # PATH="$PATH:/bin:/sbin:/usr/sbin" arch-chroot /mnt /bin/bash
    ```

    4. Follow chapter 7 of the Gentoo handbook

    Notes:

    - Choose to do 7.b "Manual Configuration"
    - You will need to enable the kernel options for EFI stub support, dm-crypt,
    and crypto functions (determined by how you setup your luks device)

    - You will need to enable the kernel options for EFI stub support, dm-crypt, and crypto functions (determined by how you setup your luks device)

    - Choose to do the step "(Optional) Building an Initramfs", but do it like this:
    (chroot) archiso ~ # echo "sys-kernel/genkernel cryptsetup" >> /etc/portage/package.use
    (chroot) archiso ~ # emerge genkernel
    (chroot) archiso ~ # genkernel --install initramfs --luks --lvm --disklabel

    ```shell
    (chroot) archiso ~ # echo "sys-kernel/genkernel cryptsetup" >> /etc/portage/package.use
    (chroot) archiso ~ # emerge genkernel
    (chroot) archiso ~ # genkernel --install initramfs --luks --lvm --disklabel
    ```

    5. Install Gummiboot like this:
    (chroot) archiso ~ # emerge gummiboot --autounmask-write
    (chroot) archiso ~ # dispatch-conf
    (chroot) archiso ~ # emerge gummiboot

    The third command [is expected to fail](https://bugs.gentoo.org/show_bug.cgi?id=518822) as of me
    writing this, so do the following to get it working (replace 45 with the proper version, should
    this bug happen to you on a newer version):
    (chroot) archiso ~ # cd /usr/portage/sys-boot/gummiboot/
    (chroot) archiso ~ # sed -i -e 's|^DIST gummiboot-.*$||g' Manifest
    (chroot) archiso ~ # ebuild gummiboot-45.ebuild digest
    (chroot) archiso ~ # emerge gummiboot

    ```shell
    (chroot) archiso ~ # emerge gummiboot --autounmask-write
    (chroot) archiso ~ # dispatch-conf
    (chroot) archiso ~ # emerge gummiboot
    ```

    The third command [is expected to fail](https://bugs.gentoo.org/show_bug.cgi?id=518822) as of me writing this, so do the following to get it working (replace 45 with the proper version, should this bug happen to you on a newer version):

    ```shell
    (chroot) archiso ~ # cd /usr/portage/sys-boot/gummiboot/
    (chroot) archiso ~ # sed -i -e 's|^DIST gummiboot-.*$||g' Manifest
    (chroot) archiso ~ # ebuild gummiboot-45.ebuild digest
    (chroot) archiso ~ # emerge gummiboot
    ```

    Get Gummiboot on your /boot (replace kernel versions with yours):
    (chroot) archiso ~ # mkdir -p /boot/EFI/gummiboot
    (chroot) archiso ~ # mkdir -p /boot/EFI/gentoo
    (chroot) archiso ~ # mkdir -p /boot/loader/entries
    (chroot) archiso ~ # cp /boot/vmlinuz-3.14.14-gentoo /boot/EFI/gentoo/vmlinuz-linux.efi
    (chroot) archiso ~ # cp /boot/initramfs-genkernel-x86_64-3.14.14-gentoo /boot/EFI/gentoo/initramfs-linux.img
    (chroot) archiso / # cp /usr/lib/gummiboot/gummibootx64.efi /boot/EFI/gummiboot/gummiboot.efi

    ```shell
    (chroot) archiso ~ # mkdir -p /boot/EFI/gummiboot
    (chroot) archiso ~ # mkdir -p /boot/EFI/gentoo
    (chroot) archiso ~ # mkdir -p /boot/loader/entries
    (chroot) archiso ~ # cp /boot/vmlinuz-3.14.14-gentoo /boot/EFI/gentoo/vmlinuz-linux.efi
    (chroot) archiso ~ # cp /boot/initramfs-genkernel-x86_64-3.14.14-gentoo /boot/EFI/gentoo/initramfs-linux.img
    (chroot) archiso / # cp /usr/lib/gummiboot/gummibootx64.efi /boot/EFI/gummiboot/gummiboot.efi
    ```

    6. Configure Gummiboot and your /etc/fstab like shown below:

    ```shell
    (chroot) archiso ~ # echo > /boot/loader/loader.conf <<EOF
    > default gentoo
    > timeout 3
    > EOF
    ```

    ```
    (chroot) archiso ~ # echo > /boot/loader/entries/gentoo.conf <<EOF
    > title Gentoo
    > efi \EFI\gentoo\vmlinuz-linux.efi
    > options initrd=\EFI\gentoo\initramfs-linux.img crypt_root=UUID=d580e705-e714-4af4-a48b-f5e71bb622be root=/dev/mapper/partitions-root ro dolvm
    > EOF
    ```
    Note: If are installing Gentoo onto a USB device, add scandelay=X with X >= 1 to the kernel options line.
    ```shell
    (chroot) archiso ~ # echo >> /etc/fstab <<EOF
    > UUID=1A6E-374D /boot vfat defaults 0 2
    > /dev/mapper/partitions-root / ext4 defaults 0 1
    > /dev/mapper/partitions-swap none swap defaults 0 0
    > EOF
    ```

    Note: Do not forget to clean your /etc/fstab after this step from whatever initial configuration was in there

    7. Follow the rest of the Gentoo handbook

    8. After leaving the chroot, do the following:
    ```shell
    archiso ~ # efibootmgr -c -d /dev/sdb -p 1 -w -L "Gummiboot" -l '\EFI\gummiboot\gummiboot.efi'
    ```

    9. Reboot into your new Gentoo

  6. Moritz Maxeiner created this gist Aug 6, 2014.
    121 changes: 121 additions & 0 deletions gentoo_uefi_fde.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,121 @@
    # Preface

    This is an as-short-as-sensible guide of the minimum necessary steps
    to setup Gentoo with LVM, LUKS, and UEFI booting using Gummiboot.
    It assumes you are already familiar with the subject of setting up
    GNU/Linux distributions and would like to know only what is specific
    to Gentoo for the abovementioned. This is most definitely not the only
    way, but it is the shortest I - as a current Gentoo newbie - was able
    to determine.

    # Requirements

    - target box: This is the UEFI computer where Gentoo is supposed to be installed.
    - helper box: This is some computer running some GNU/Linux distribution
    - usb stick: This is the USB stick onto which the UEFI bootable live system will go

    # Preparation

    First we shall create the usb stick running Arch Linux - it was chosen because it
    is very easy to set up and has everything required out of the box.

    The latest ISO for Arch Linux can be grabbed from [here](https://www.archlinux.org/download/);
    at the time of writing this, "archlinux-2014.08.01-dual.iso" is the latest available image
    and also what was used in the making of this guide.

    After grabbing the image, [copy it with dd onto the usb stick](https://wiki.archlinux.org/index.php/USB_Flash_Installation_Media#Using_dd) using your helper box.

    Now boot the target box from the usb stick in UEFI mode. If you have your target box
    connected via LAN, Arch Linux is likely to have set it up corretly for you already;
    if you are connected via WLAN, call "wifi-menu" to set it up.

    # Installation

    1. Prepare your disks. This is a minimal example of a layout your target block device could have:

    NAME TYPE FSTYPE MOUNTPOINT SIZE UUID
    sdb disk 59.6G
    ├─sdb1 part vfat /mnt/boot 500M 1A6E-374D
    └─sdb2 part crypto_LUKS 59.1G d580e705-e714-4af4-a48b-f5e71bb622be
    └─luks_container crypt LVM2_member 59.1G 8yHuxc-f6ZU-xkdU-l6dY-dVpE-50oT-2rLAzz
    ├─partitions-swap lvm swap [SWAP] 2G 81172beb-590c-411d-bd74-2bb0266544b9
    └─partitions-root lvm ext4 /mnt 57.1G 17c87950-4471-4a4c-a703-aabdf937a7e0

    Note: All commands below referencing a block device do so with regards to the above example layout!
    You need to adjust any such command to your own layout!

    2. Follow chapter 5 of the Gentoo handbook.
    Note: We're using Arch Linux here, so keep "/mnt/gentoo becomes /mnt" in mind.

    3. Follow chapter 6 of the Gentoo handbook.
    Notes:
    - There's no "mirrorselect" on Arch Linux, you will need to do its part manually
    - Do the chroot like this (Arch Linux specific):
    archiso ~ # PATH="$PATH:/bin:/sbin:/usr/sbin" arch-chroot /mnt /bin/bash

    4. Follow chapter 7 of the Gentoo handbook
    Notes:
    - Choose to do 7.b "Manual Configuration"
    - You will need to enable the kernel options for EFI stub support, dm-crypt,
    and crypto functions (determined by how you setup your luks device)
    - Choose to do the step "(Optional) Building an Initramfs", but do it like this:
    (chroot) archiso ~ # echo "sys-kernel/genkernel cryptsetup" >> /etc/portage/package.use
    (chroot) archiso ~ # emerge genkernel
    (chroot) archiso ~ # genkernel --install initramfs --luks --lvm --disklabel

    5. Install Gummiboot like this:
    (chroot) archiso ~ # emerge gummiboot --autounmask-write
    (chroot) archiso ~ # dispatch-conf
    (chroot) archiso ~ # emerge gummiboot

    The third command [is expected to fail](https://bugs.gentoo.org/show_bug.cgi?id=518822) as of me
    writing this, so do the following to get it working (replace 45 with the proper version, should
    this bug happen to you on a newer version):
    (chroot) archiso ~ # cd /usr/portage/sys-boot/gummiboot/
    (chroot) archiso ~ # sed -i -e 's|^DIST gummiboot-.*$||g' Manifest
    (chroot) archiso ~ # ebuild gummiboot-45.ebuild digest
    (chroot) archiso ~ # emerge gummiboot

    Get Gummiboot on your /boot (replace kernel versions with yours):
    (chroot) archiso ~ # mkdir -p /boot/EFI/gummiboot
    (chroot) archiso ~ # mkdir -p /boot/EFI/gentoo
    (chroot) archiso ~ # mkdir -p /boot/loader/entries
    (chroot) archiso ~ # cp /boot/vmlinuz-3.14.14-gentoo /boot/EFI/gentoo/vmlinuz-linux.efi
    (chroot) archiso ~ # cp /boot/initramfs-genkernel-x86_64-3.14.14-gentoo /boot/EFI/gentoo/initramfs-linux.img
    (chroot) archiso / # cp /usr/lib/gummiboot/gummibootx64.efi /boot/EFI/gummiboot/gummiboot.efi

    6. Configure Gummiboot and your /etc/fstab like shown below:

    (chroot) archiso ~ # echo > /boot/loader/loader.conf <<EOF
    > default gentoo
    > timeout 3
    > EOF
    (chroot) archiso ~ # echo > /boot/loader/entries/gentoo.conf <<EOF
    > title Gentoo
    > efi \EFI\gentoo\vmlinuz-linux.efi
    > options initrd=\EFI\gentoo\initramfs-linux.img crypt_root=UUID=d580e705-e714-4af4-a48b-f5e71bb622be root=/dev/mapper/partitions-root ro dolvm
    > EOF
    Note: If are installing Gentoo onto a USB device, add scandelay=X with X >= 1 to the kernel options line.
    (chroot) archiso ~ # echo >> /etc/fstab <<EOF
    > UUID=1A6E-374D /boot vfat defaults 0 2
    > /dev/mapper/partitions-root / ext4 defaults 0 1
    > /dev/mapper/partitions-swap none swap defaults 0 0
    > EOF
    Note: Do not forget to clean your /etc/fstab after this step from whatever initial configuration was in there

    7. Follow the rest of the Gentoo handbook

    8. After leaving the chroot, do the following:
    archiso ~ # efibootmgr -c -d /dev/sdb -p 1 -w -L "Gummiboot" -l '\EFI\gummiboot\gummiboot.efi'

    9. Reboot into your new Gentoo

    # Sources

    - Gentoo handbook
    - http://wiki.gentoo.org/wiki/EFI_Gentoo_End_to_End_Install
    - https://gist.github.com/jasonwryan/4618490
    - http://xtothei.wordpress.com/2012/05/08/gentoo-uefi/
    - Kind people on the #gentoo IRC channel on freenode.net (you know who you are)