Here we are going to show the minimum steps to install a base Gentoo Linux on your computer – server or desktop using “Minimal Installation CD”.
The installation ISO CD is generated on 11.09.2018, but you can use an older or newer one, this guide uses commands, which are available in really old ISOs (10 years ago) and probably will be available in the future, too! The idea is not to change this ISO a lot and to have only the basic tools for installation, which should be the same for a really long time! If you need more tools there two other options: Hybrid IS0, which is a LiveDVD – a system with GUI and Admin CD, which is an extended version of the minimal installation CD (no GUI).
Our base Gentoo system will use:
- OpenRC, which is based on init to boot the server. This is the default in Gentoo, but you might have problems using Gnome
- GRUB 2 UEFI enabled and the server will be booted in UEFI mode. Recently most of the desktop machine and server support it and in many cases it is mandatory to use a new hardware.
- No GUI will be installed (KDE, Gnome, Xfce and so on), there are other tutorials for this, you can check here (coming soon)
Our system is equipped with a pretty new hardware:
- Asus ROG Zenith Extreme motherboard using X399 chipset https://www.asus.com/th/Motherboards/ROG-ZENITH-EXTREME/
- Asus ROG Poseidon GeForceĀ® GTX 1080 TI video card https://www.asus.com/us/Graphics-Cards/ROG-POSEIDON-GTX1080TI-P11G-GAMING/
- AMD Threadripper 1950X – 16 cores and 32 logical units
- 32G RAM in 4 channel mode
STEP 1) Download the “Minimal Installation CD”
You can download the ISO from: https://www.gentoo.org/downloads/ Here is the ISO file: http://distfiles.gentoo.org/releases/amd64/autobuilds/20180911T214502Z/install-amd64-minimal-20180911T214502Z.iso or you can check it in some mirror like leaseweb – http://mirror.leaseweb.com/gentoo/releases/amd64/autobuilds/current-install-amd64-minimal/install-amd64-minimal-20180911T214502Z.iso. After you download the ISO file, burn it and load it in the CD/DVD device.
STEP 2) Boot from the installation CD
Recent motherboards have ability to boot one time from a device you select. Just start your machine and go to BIOS->Boot sub-menu and there find your CD/DVD from the list to boot. You can see how it looks like in our motherboard (most servers have F11 during server start-up to choose from a menu which device you want to boot from):
It is important to look for “UEFI:
We have all the process of booting in screenshots, but here will include only two, because this is not the main purpose of the article, but you can check this howto for details: Gentoo Minimal Installation CD (amd64 aka x86_64) – booting (in UEFI mode)
After successful boot you’ll end up in the following screen:
STEP 3) Setup network
The first step is to set the networking because we are going to need more installation files in the process. You can do it with “net-setup” or manually with iproute2 or ifconfig (check for details the tutorial mentioned in STEP2)). Here are what we did:
livecd ~ # #check if we have an IP, in our case we do not have, if you have do not execute any command from here! livecd ~ # ip a #it's good idea to kill the DHCP client because it will continue to probe for a server even you set up the network manually livecd ~ # killall dhcpcd livecd ~ # ip a add 192.168.0.200/24 dev enp5s0 livecd ~ # ip link set enp5s0 up livecd ~ # ip ro add default via 192.168.0.1 #check Internet connection pinging Google DNS livecd ~ # ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=123 time=5.67 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=123 time=3.99 ms^C livecd ~ # echo "nameserver 8.8.8.8" > /etc/resolv.conf
The last step is really important, because we set the DNS server to be able to resolve Internet hostnames from our system.
STEP 4) Prepare the disk(s)
First partition them.
livecd ~ # parted /dev/sda GNU Parted 3.2 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel gpt Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? Yes (parted) mkpart primary 0% 3M (parted) p Model: ATA KINGSTON SNV425S (scsi) Disk /dev/sda: 128GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 3146kB 2097kB primary (parted) set 1 bios_grub on (parted) mkpart primary 3M 8G (parted) mkpart primary 8G 100% (parted) set 1 boot on (parted) name 1 grub (parted) name 2 swap (parted) name 2 rootfs (parted) p Model: ATA KINGSTON SNV425S (scsi) Disk /dev/sda: 128GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 3146kB 2097kB grub boot, esp 2 3146kB 8000MB 7996MB swap 3 8000MB 128GB 120GB rootfs (parted) q Information: You may need to update /etc/fstab.
Put filesystem on the partitions and mount. Swap and ext4 is used. The first partition is for the UEFI grub boot and it must be formatted with fat filesystem.
livecd ~ # mkswap /dev/sda2 Setting up swapspace version 1, size = 7.5 GiB (7996436480 bytes) no label, UUID=03a3437e-6142-43f3-9ac5-240101a651b1 livecd ~ # mkfs.ext4 /dev/sda3 mke2fs 1.43.9 (8-Feb-2018) Discarding device blocks: done Creating filesystem with 29305600 4k blocks and 7331840 inodes Filesystem UUID: 40a3fec6-9ecd-4ccd-8194-efac10ca11a3 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Allocating group tables: done Writing inode tables: done Creating journal (131072 blocks): done Writing superblocks and filesystem accounting information: done livecd ~ # mkfs.vfat /dev/sda1 mkfs.fat 4.0 (2016-05-06) livecd ~ # mount /dev/sda3 /mnt/gentoo livecd ~ # df -h Filesystem Size Used Avail Use% Mounted on udev 10M 4.0K 10M 1% /dev tmpfs 16G 59M 16G 1% / /dev/sr0 235M 235M 0 100% /mnt/cdrom /dev/loop0 213M 213M 0 100% /mnt/livecd tmpfs 3.2G 1.2M 3.2G 1% /run shm 16G 0 16G 0% /dev/shm cgroup_root 10M 0 10M 0% /sys/fs/cgroup /dev/sda3 110G 61M 104G 1% /mnt/gentoo
STEP 5) Download and unpack the Gentoo base system
The disk is ready and mounted in /mnt/gentoo, so now we install the base Gentoo system, which is packed in a file starting with named “stage3-*”. stage3 is a file with the minimum Linux files needed to boot your system, here is a quote from the Gentoo site, which describes best what is the stage3 file:
A stage3 tarball is an archive containing a minimal Gentoo environment, suitable to continue the Gentoo installation using the instructions in this manual.
It consists of multiple Linux libraries, utilities, and Gentoo team-specific files to boot Linux system (these tools help you to build a kernel, too).
Downloading the files from a mirror (as we did) or from the official page: https://www.gentoo.org/downloads/
livecd ~ # cd /mnt/gentoo/ livecd /mnt/gentoo # wget http://mirror.leaseweb.com/gentoo/releases/amd64/autobuilds/current-install-amd64-minimal/stage3-amd64-20180909T214503Z.tar.xz livecd /mnt/gentoo # wget http://mirror.leaseweb.com/gentoo/releases/snapshots/current/portage-20180910.tar.xz livecd /mnt/gentoo # tar xJpf stage3-amd64-20180909T214503Z.tar.xz --xattrs-include='*.*' --numeric-owner -C ./ livecd /mnt/gentoo # ls -al total 237388 drwxr-xr-x 20 root root 4096 Sep 10 00:23 . drwxr-xr-x 6 root root 120 Sep 11 14:57 .. drwxr-xr-x 2 root root 4096 Sep 10 00:12 bin drwxr-xr-x 2 root root 4096 Sep 9 21:54 boot drwxr-xr-x 3 root root 4096 Sep 9 21:55 dev drwxr-xr-x 32 root root 4096 Sep 10 01:29 etc drwxr-xr-x 2 root root 4096 Sep 9 21:54 home lrwxrwxrwx 1 root root 5 Sep 10 00:23 lib -> lib64 drwxr-xr-x 2 root root 4096 Sep 10 00:23 lib32 drwxr-xr-x 10 root root 4096 Sep 10 01:29 lib64 drwxr-xr-x 2 root root 4096 Sep 9 21:54 media drwxr-xr-x 2 root root 4096 Sep 9 21:54 mnt drwxr-xr-x 2 root root 4096 Sep 9 21:54 opt -rw-r--r-- 1 root root 45504348 Sep 11 00:51 portage-20180910.tar.xz drwxr-xr-x 2 root root 4096 Sep 9 21:48 proc drwx------ 2 root root 4096 Sep 9 21:54 root drwxr-xr-x 2 root root 4096 Sep 10 00:08 run drwxr-xr-x 2 root root 4096 Sep 10 01:29 sbin -rw-r--r-- 1 root root 197491672 Sep 10 01:31 stage3-amd64-20180909T214503Z.tar.xz drwxr-xr-x 2 root root 4096 Sep 9 21:54 sys drwxrwxrwt 2 root root 4096 Sep 10 01:29 tmp drwxr-xr-x 13 root root 4096 Sep 11 15:38 usr drwxr-xr-x 9 root root 4096 Sep 9 21:54 var livecd /mnt/gentoo # tar xJpf portage-20180910.tar.xz --xattrs-include='*.*' --numeric-owner -C usr/ livecd /mnt/gentoo # mv stage3-amd64-20180909T214503Z.tar.xz root/ livecd /mnt/gentoo # mv portage-20180910.tar.xz root/ livecd /mnt/gentoo # df -h Filesystem Size Used Avail Use% Mounted on udev 10M 4.0K 10M 1% /dev tmpfs 16G 59M 16G 1% / /dev/sr0 235M 235M 0 100% /mnt/cdrom /dev/loop0 213M 213M 0 100% /mnt/livecd tmpfs 3.2G 1.2M 3.2G 1% /run shm 16G 0 16G 0% /dev/shm cgroup_root 10M 0 10M 0% /sys/fs/cgroup /dev/sda3 110G 2.0G 102G 2% /mnt/gentoo
Download, unpack and see what’s in “/mnt/gentoo”, the root mount of your future Linux system.
“portage-20180910.tar.xz” file is part of the heart of Gentoo system, it includes metadata information for all packages available for the Gentoo system. Unpacking the “portage-” is done only in the initial installation after that there is a tool for this to update these files and to receive package updates for your system.
STEP 6) Prepare your new system – the Gentoo base system
Minimal base configuration
First we need to made a “jail”, it’s like using our system without rebooting using the currently booted kernel.
livecd /mnt/gentoo # cp /etc/resolv.conf /mnt/gentoo/etc/ livecd /mnt/gentoo # mount --types proc /proc /mnt/gentoo/proc livecd /mnt/gentoo # mount --rbind /sys /mnt/gentoo/sys livecd /mnt/gentoo # mount --make-rslave /mnt/gentoo/sys livecd /mnt/gentoo # mount --rbind /dev /mnt/gentoo/dev livecd /mnt/gentoo # mount --make-rslave /mnt/gentoo/dev
The –make-rslave operations are needed for systemd support in our case we do not need them.
It’s time to configure our system: Add these 4 lines to the file /etc/portage/make.conf We are going to use the default:
First you must chroot in your new Gentoo system:
livecd /mnt/gentoo # chroot /mnt/gentoo /bin/bash
livecd / # source /etc/profile
livecd / # export PS1="(chroot) ${PS1}"
(chroot) livecd / #
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
ACCEPT_KEYWORDS="~amd64"
GRUB_PLATFORMS="efi-64"
Because we do not plan to copy this system anywhere we use flag “-march=native” to let GNU GCC determine the best optimizations for the current system. The problem with “native” is that you would have problems if you move your hard drives to other processor model like from Intel to AMD or from new to older processor – use other flags like those, which represent generation of processors or architecture of processors to be more portable your system. Here is the right place to check for other safe flags: https://wiki.gentoo.org/wiki/Safe_CFLAGS
ACCEPT_KEYWORDS=”~amd64″ means you would like to install testing packages not only the stable one. It’s OK to use testing ones in fact they are stable according to the developer released them.
(chroot) livecd / # eselect profile list
Available profile symlink targets:
[1] default/linux/amd64/13.0 (stable)
[2] default/linux/amd64/13.0/selinux (dev)
[3] default/linux/amd64/13.0/desktop (stable)
[4] default/linux/amd64/13.0/desktop/gnome (stable)
[5] default/linux/amd64/13.0/desktop/gnome/systemd (stable)
[6] default/linux/amd64/13.0/desktop/plasma (stable)
[7] default/linux/amd64/13.0/desktop/plasma/systemd (stable)
[8] default/linux/amd64/13.0/developer (stable)
[9] default/linux/amd64/13.0/no-multilib (stable)
[10] default/linux/amd64/13.0/systemd (stable)
[11] default/linux/amd64/13.0/x32 (dev)
[12] default/linux/amd64/17.0 (stable) *
[13] default/linux/amd64/17.0/selinux (stable)
[14] default/linux/amd64/17.0/hardened (stable)
[15] default/linux/amd64/17.0/hardened/selinux (stable)
[16] default/linux/amd64/17.0/desktop (stable)
[17] default/linux/amd64/17.0/desktop/gnome (stable)
[18] default/linux/amd64/17.0/desktop/gnome/systemd (stable)
[19] default/linux/amd64/17.0/desktop/plasma (stable)
[20] default/linux/amd64/17.0/desktop/plasma/systemd (stable)
[21] default/linux/amd64/17.0/developer (stable)
[22] default/linux/amd64/17.0/no-multilib (stable)
[23] default/linux/amd64/17.0/no-multilib/hardened (stable)
[24] default/linux/amd64/17.0/no-multilib/hardened/selinux (stable)
[25] default/linux/amd64/17.0/systemd (stable)
[26] default/linux/amd64/17.0/x32 (dev)
[27] default/linux/amd64/17.1 (exp)
[28] default/linux/amd64/17.1/selinux (exp)
[29] default/linux/amd64/17.1/hardened (exp)
[30] default/linux/amd64/17.1/hardened/selinux (exp)
[31] default/linux/amd64/17.1/desktop (exp)
[32] default/linux/amd64/17.1/desktop/gnome (exp)
[33] default/linux/amd64/17.1/desktop/gnome/systemd (exp)
[34] default/linux/amd64/17.1/desktop/plasma (exp)
[35] default/linux/amd64/17.1/desktop/plasma/systemd (exp)
[36] default/linux/amd64/17.1/developer (exp)
[37] default/linux/amd64/17.1/no-multilib (exp)
[38] default/linux/amd64/17.1/no-multilib/hardened (exp)
[39] default/linux/amd64/17.1/no-multilib/hardened/selinux (exp)
[40] default/linux/amd64/17.1/systemd (exp)
[41] hardened/linux/amd64 (stable)
[42] hardened/linux/amd64/selinux (stable)
[43] hardened/linux/amd64/no-multilib (stable)
[44] hardened/linux/amd64/no-multilib/selinux (stable)
[45] hardened/linux/amd64/x32 (dev)
[46] default/linux/musl/amd64 (exp)
[47] hardened/linux/musl/amd64 (exp)
[48] default/linux/musl/amd64/x32 (exp)
[49] hardened/linux/musl/amd64/x32 (exp)
[50] default/linux/amd64/17.0/musl (exp)
[51] default/linux/amd64/17.0/musl/hardened (exp)
[52] default/linux/amd64/17.0/musl/hardened/selinux (exp)
[53] default/linux/uclibc/amd64 (exp)
[54] hardened/linux/uclibc/amd64 (exp)
[12] default/linux/amd64/17.0 (stable) *
If you want to install KDE or GNOME or systemd just select proper one, for example (KDE and OpenRC):
eselect profile set 19
(chroot) livecd / # echo "UTC" > /etc/timezone
(chroot) livecd / # emerge --config sys-libs/timezone-data
Configuring pkg...
* Updating /etc/localtime with /usr/share/zoneinfo/UTC
Set (or uncomment) the following two lines in /etc/locale.gen:
en_US ISO-8859-1 en_US.UTF-8 UTF-8
Anf execute the following commands:
(chroot) livecd / # locale-gen * Generating 2 locales (this might take a while) with 32 jobs * (1/2) Generating en_US.ISO-8859-1 ... [ ok ] * (2/2) Generating en_US.UTF-8 ... [ ok ] * Generation complete * Adding locales to archive ... [ ok ] (chroot) livecd / # eselect locale list Available targets for the LANG variable: [1] C [2] en_US [3] en_US.iso88591 [4] en_US.utf8 [5] POSIX [ ] (free form) (chroot) livecd / # eselect locale set 4 Setting LANG to en_US.utf8 ... Run ". /etc/profile" to update the variable in your shell. (chroot) livecd / # . /etc/profile livecd / # export PS1="(chroot) ${PS1}"
The file “/etc/fstab” must look like this (the IDs you must replace with the one in your system – look below):
UUID=03a3437e-6142-43f3-9ac5-240101a651b1 none swap sw,discard 0 0 UUID=40a3fec6-9ecd-4ccd-8194-efac10ca11a3 / ext4 defaults,noatime,discard 0 1
How to see the ID of the filesystems:
(chroot) livecd / # blkid |grep sda2 /dev/sda2: UUID="03a3437e-6142-43f3-9ac5-240101a651b1" TYPE="swap" PARTUUID="80d05cc1-2ddb-3f30-a29b-2701dc35fbcd" (chroot) livecd / # blkid |grep sda3 /dev/sda3: UUID="40a3fec6-9ecd-4ccd-8194-efac10ca11a3" TYPE="ext4" PARTUUID="fc44c6f5-06d6-3e42-cc95-c28e16446515"
(chroot) livecd / # echo "8.8.8.8" > /etc/resolv.conf (chroot) livecd / # echo 'HOSTNAME="srv"' > /etc/conf.d/hostname (chroot) livecd / # cd /etc/init.d/ (chroot) livecd /etc/init.d # ln -s net.lo net.enp5s0 (chroot) livecd /etc/init.d # rc-update add net.enp5s0 default * service net.enp5s0 added to runlevel default (chroot) livecd /etc/init.d # cd /
Resolving, hostname and TCP/IP settings are the most important.
Our LAN interface is with name “enp5so”, that’s why we use this name for the init file to set the IP to this interface, when the network is started. Here is our simple network configuration file – “/etc/conf.d/net”:
config_enp5s0="dhcp"
Or if you like manual IP set:
config_enp5s0="192.168.0.200 netmask 255.255.255.0 brd 192.168.0.255" routes_enp5s0="default gw 192.168.0.1"
Or the iproute2 syntax:
config_enp5s0="192.168.0.200/24" routes_enp5s0="default via 192.168.0.1"
STEP 8) Install couple of important packages and build the kernel
First, you should use “–sync” to synchronize your package metafiles with the latest. Then install important packages for the kernel build and booting process – the GRUB 2. Check the output of the commands below, there is a detailed explanation of the packages installation. There is a simple and automatic tool to build the kernel. This tool (genkernel) could be used to change the default Gentoo kernel build settings, but this is beyond the scope of this article (just add “–menuconfig” to the genkernel command).
(chroot) livecd / # emerge --sync (chroot) livecd / # echo -e "sys-boot/grub mount\nsys-apps/util-linux static-libs" > /etc/portage/package.use/myuse (chroot) livecd / # emerge -v sys-kernel/genkernel sys-kernel/linux-firmware sys-boot/os-prober dev-libs/libisoburn sys-fs/mdadm grub gentoo-sources net-misc/dhcpcd app-admin/syslog-ng vixie-cron sys-fs/e2fsprogs (chroot) livecd / # rc-update add mdraid boot (chroot) livecd / # genkernel all * Gentoo Linux Genkernel; Version 3.5.3.3 * Running with options: all * Using genkernel.conf from /etc/genkernel.conf * Sourcing arch-specific config.sh from /usr/share/genkernel/arch/x86_64/config.sh .. * Sourcing arch-specific modules_load from /usr/share/genkernel/arch/x86_64/modules_load .. * Linux Kernel 4.18.7-gentoo for x86_64... * .. with config file /usr/share/genkernel/arch/x86_64/generated-config * kernel: Using config from /usr/share/genkernel/arch/x86_64/generated-config * kernel: >> Running mrproper... * >> Running oldconfig... * kernel: >> Cleaning... * >> Compiling 4.18.7-gentoo bzImage... * >> Not installing firmware as requested by configuration FIRMWARE_INSTALL=no... * >> Compiling 4.18.7-gentoo modules... * >> Installing 4.18.7-gentoo modules (and stripping) * >> Generating module dependency data... * Copying config for successful build to /etc/kernels/kernel-config-x86_64-4.18.7-gentoo * busybox: >> Applying patches... patching file console-tools/openvt.c Hunk #1 succeeded at 147 (offset 23 lines). * - 1.18.1-openvt.diff patching file modutils/modprobe.c Hunk #1 succeeded at 444 (offset 31 lines). Hunk #2 succeeded at 492 (offset 32 lines). * - busybox-1.20.2-modprobe.patch patching file util-linux/mdStart.c * - busybox-1.26.0-mdstart.patch patching file libbb/u_signal_names.c Hunk #1 succeeded at 76 (offset 10 lines). Hunk #2 succeeded at 100 (offset 10 lines). * - busybox-1.7.4-signal-hack.patch * busybox: >> Configuring... * busybox: >> Compiling... * busybox: >> Copying to cache... * initramfs: >> Initializing... * >> Appending devices cpio data... * >> Appending base_layout cpio data... * >> Appending auxilary cpio data... * >> Copying keymaps * >> Appending busybox cpio data... * >> Appending modules cpio data... * >> Appending blkid cpio data... * >> Appending modprobed cpio data... * >> Appending linker cpio data... * >> Deduping cpio... * >> Compressing cpio data (.xz)... * * Kernel compiled successfully! * * Required Kernel Parameters: * root=/dev/$ROOT * * Where $ROOT is the device node for your root partition as the * one specified in /etc/fstab * * If you require Genkernel's hardware detection features; you MUST * tell your bootloader to use the provided INITRAMFS file. * WARNING... WARNING... WARNING... * Additional kernel cmdline arguments that *may* be required to boot properly... * With support for several ext* filesystems available, it may be needed to * add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters. * Do NOT report kernel bugs as genkernel bugs unless your bug * is about the default genkernel configuration... * * Make sure you have the latest ~arch genkernel before reporting bugs. (chroot) livecd / # ls -altr /boot/ total 17136 -rw-r--r-- 1 root root 0 Sep 9 21:54 .keep drwxr-xr-x 20 root root 4096 Sep 11 15:39 .. -rw-r--r-- 1 root root 6464144 Sep 11 16:20 kernel-genkernel-x86_64-4.18.7-gentoo -rw-r--r-- 1 root root 3218876 Sep 11 16:20 System.map-genkernel-x86_64-4.18.7-gentoo drwxr-xr-x 2 root root 4096 Sep 11 16:24 . -rw-r--r-- 1 root root 7850988 Sep 11 16:24 initramfs-genkernel-x86_64-4.18.7-gentoo (chroot) livecd / #
STEP 9) Install GRUB 2 and make a boot entry in the UEFI BIOS of your motherboard
(chroot) livecd / # mkdir /boot/efi/ (chroot) livecd / # mount /dev/sda1 /boot/efi/ (chroot) livecd / # grub-install --efi-directory=/boot/efi/ --target=x86_64-efi /dev/sda Installing for x86_64-efi platform. Could not prepare Boot variable: Read-only file system Installation finished. No error reported. (chroot) livecd / # mount -o remount,rw /sys/firmware/efi/efivars (chroot) livecd / # grub-install --efi-directory=/boot/efi/ --target=x86_64-efi /dev/sda Installing for x86_64-efi platform. Installation finished. No error reported. (chroot) livecd /etc/init.d # grub-mkconfig -o /boot/grub/grub.cfg Generating grub configuration file ... Found linux image: /boot/kernel-genkernel-x86_64-4.18.7-gentoo Found initrd image: /boot/initramfs-genkernel-x86_64-4.18.7-gentoo done
Install GRUB 2 in our sda device and make a boot entry in our UEFI BIOS. As you can see if you encounter like us the error: “Could not prepare Boot variable: Read-only file system” you should remount “/sys/firmware/efi/efivars” as shown, if there is no error only the first 3 lines of commands are enough. And then generate the GRUB configuration file.
STEP 10) Last touches to the configuration and reboot
Do not forget to add openssh to start at start up:
(chroot) livecd / # rc-update add sshd default * service sshd added to runlevel default (chroot) livecd / # rc-update add syslog-ng * service syslog-ng added to runlevel default (chroot) livecd / # rc-update add vixie-cron * service vixie-cron added to runlevel default (chroot) livecd / # passwd New password: Retype new password: passwd: password updated successfully (chroot) livecd / # exit livecd /mnt/gentoo # cd livecd ~ # umount /mnt/gentoo/boot/efi/ livecd ~ # umount -l /mnt/gentoo/dev{/shm,/pts,} livecd ~ # umount -R /mnt/gentoo
Because we did not create any user and if you plan to log in the system with the root user using ssh you must enable “PermitRootLogin yes” to your /etc/ssh/sshd_config (in /mnt/gentoo/etc/ssh/sshd_config if you left the chroot). The default option is commented so the default value is taken into account, but it forbids the root login, so you must uncomment and change to “PermitRootLogin yes”.
Successfully installed UEFI boot option in your UEFI BIOS
Here we include a screenshot of our UEFI BIOS and the Boot menu, which has a “gentoo” boot option and is the first in the Boot option priorities. This is what it looks like to install GRUB 2 with EFI support successfully.
The installation output of the emerge commands above
We have trimmed the “emerge –sync” output and the build output of the emerge. It is interesting if you check the log here you’ll find that we were forced to set a special USE flag for one of the packages grub with “mount” USE flag. This means that we must explicitly set the flag to be used when the system builds the grub package. Lately, the emerge includes it automatically you should just accept the changes starting “etc-update” tool as shown below.
Here we first installed grub and then the additional packages, which requested a rebuild to grub – you can just build everything in one step it will be the same!
(chroot) livecd / # emerge --sync >>> Syncing repository 'gentoo' into '/usr/portage'... * Using keys from /usr/share/openpgp-keys/gentoo-release.asc * Refreshing keys from keyserver ... [ ok ] >>> Starting rsync with rsync://91.186.30.235/gentoo-portage... Welcome to boobie.gentoo.org / rsync.gentoo.org Server Address : 91.186.30.235 Contact Name : mirror-admin@gentoo.org Hardware : 2 x Intel(R) Xeon(R) CPU 3050 @ 2.13GHz, 3947MB RAM Sponsor : EUKhost, Maidenhead, England Please note: common gentoo-netiquette says you should not sync more than once a day. Users who abuse the rsync.gentoo.org rotation may be added to a temporary ban list. MOTD autogenerated by update-rsync-motd on Tue Jan 2 08:01:07 UTC 2018 receiving incremental file list timestamp.chk Number of files: 1 (reg: 1) Number of created files: 0 Number of deleted files: 0 Number of regular files transferred: 1 Total file size: 32 bytes Total transferred file size: 32 bytes Literal data: 32 bytes Matched data: 0 bytes File list size: 41 File list generation time: 0.001 seconds File list transfer time: 0.000 seconds Total bytes sent: 104 Total bytes received: 132 sent 104 bytes received 132 bytes 472.00 bytes/sec total size is 32 speedup is 0.14 Welcome to boobie.gentoo.org / rsync.gentoo.org Server Address : 91.186.30.235 Contact Name : mirror-admin@gentoo.org Hardware : 2 x Intel(R) Xeon(R) CPU 3050 @ 2.13GHz, 3947MB RAM Sponsor : EUKhost, Maidenhead, England Please note: common gentoo-netiquette says you should not sync more than once a day. Users who abuse the rsync.gentoo.org rotation may be added to a temporary ban list. MOTD autogenerated by update-rsync-motd on Tue Jan 2 08:01:07 UTC 2018 receiving incremental file list Manifest Manifest.files.gz app-admin/Manifest.gz app-admin/ansible-cmdb/Manifest app-admin/ansible-cmdb/metadata.xml deleting app-crypt/glep63-check/glep63-check-5.ebuild deleting app-crypt/glep63-check/glep63-check-4.ebuild app-crypt/Manifest.gz app-crypt/glep63-check/Manifest deleting app-eselect/eselect-repository/eselect-repository-3.ebuild app-eselect/Manifest.gz .... .... (chroot) livecd / # emerge -va grub These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild N ] virtual/libudev-232:0/1::gentoo USE="-static-libs -systemd" ABI_X86="(64) -32 (-x32)" 0 KiB [ebuild N ] media-libs/freetype-2.9.1-r4:2::gentoo USE="adobe-cff bzip2 cleartype_hinting -X -bindist -debug -doc -fontforge -harfbuzz -infinality -png -static-libs -utils" ABI_X86="(64) -32 (-x32)" 1882 KiB [ebuild N ] sys-apps/pciutils-3.6.2::gentoo USE="kmod udev zlib -dns -static-libs" ABI_X86="(64) -32 (-x32)" 463 KiB [ebuild N ] sys-libs/efivar-36:0/1::gentoo 104 KiB [ebuild N ] sys-boot/efibootmgr-16::gentoo 36 KiB [ebuild N ] sys-boot/grub-2.02-r3:2/2.02-r3::gentoo USE="fonts nls themes -debug -device-mapper -doc -efiemu -libzfs -mount -multislot -sdl -static {-test} -truetype" GRUB_PLATFORMS="efi-64 pc -coreboot -efi-32 -emu -ieee1275 -loongson -multiboot -qemu -qemu-mips -uboot -xen -xen-32" 7707 KiB Total: 6 packages (6 new), Size of downloads: 10190 KiB Would you like to merge these packages? [Yes/No] yes >>> Verifying ebuild manifests >>> Emerging (1 of 6) virtual/libudev-232::gentoo * Fetching files in the background. * To view fetch progress, run in another terminal: * tail -f /var/log/emerge-fetch.log >>> Unpacking source... >>> Source unpacked in /var/tmp/portage/virtual/libudev-232/work >>> Preparing source in /var/tmp/portage/virtual/libudev-232/work ... >>> Source prepared. >>> Configuring source in /var/tmp/portage/virtual/libudev-232/work ... >>> Source configured. .... .... * Messages for package sys-boot/grub-2.02-r3: * For information on how to configure GRUB2 please refer to the guide: * https://wiki.gentoo.org/wiki/GRUB2_Quick_Start * * You may consider installing the following optional packages: * sys-boot/os-prober for Detect other operating systems (grub-mkconfig) * dev-libs/libisoburn for Create rescue media (grub-mkrescue) * sys-fs/mdadm for Enable RAID device detection >>> Auto-cleaning packages... >>> No outdated packages were found on your system. * Regenerating GNU info directory index... * Processed 84 info files. (chroot) livecd / # emerge -va sys-boot/os-prober dev-libs/libisoburn sys-fs/mdadm These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild N ] dev-util/re2c-1.1.1::gentoo 5769 KiB [ebuild N ] dev-util/ninja-1.8.2-r1::gentoo USE="-doc -emacs {-test} -vim-syntax -zsh-completion" 200 KiB [ebuild N ] dev-util/meson-0.47.1::gentoo PYTHON_TARGETS="python3_6 -python3_5" 1221 KiB [ebuild N ] dev-libs/libburn-1.4.8-r2::gentoo USE="-debug -static-libs" 955 KiB [ebuild N ] dev-libs/libisofs-1.4.8::gentoo USE="acl xattr zlib -debug -static-libs -verbose-debug" 811 KiB [ebuild N ] sys-fs/fuse-common-3.2.2::gentoo 1160 KiB [ebuild N ] sys-fs/mdadm-4.0::gentoo USE="-static" 80 KiB [ebuild N ] sys-fs/fuse-2.9.7-r1::gentoo USE="-examples -static-libs" 646 KiB [ebuild N ] dev-libs/libisoburn-1.4.8-r1::gentoo USE="acl readline xattr zlib -debug -external-filters -external-filters-setuid -frontend-optional -launch-frontend -launch-frontend-setuid -libedit -static-libs" 1502 KiB [ebuild R ] sys-boot/grub-2.02-r3:2/2.02-r3::gentoo USE="fonts mount* nls themes -debug -device-mapper -doc -efiemu -libzfs -multislot -sdl -static {-test} -truetype" GRUB_PLATFORMS="efi-64 pc -coreboot -efi-32 -emu -ieee1275 -loongson -multiboot -qemu -qemu-mips -uboot -xen -xen-32" 0 KiB [ebuild N ] sys-boot/os-prober-1.76-r1::gentoo 26 KiB Total: 11 packages (10 new, 1 reinstall), Size of downloads: 12367 KiB The following USE changes are necessary to proceed: (see "package.use" in the portage(5) man page for more details) # required by sys-boot/os-prober-1.76-r1::gentoo # required by sys-boot/os-prober (argument) >=sys-boot/grub-2.02-r3 mount Would you like to add these changes to your config files? [Yes/No] yes Autounmask changes successfully written. * IMPORTANT: config file '/etc/portage/package.use/zz-autounmask' needs updating. * See the CONFIGURATION FILES and CONFIGURATION FILES UPDATE TOOLS * sections of the emerge man page to learn how to update config files. (chroot) livecd / # etc-update Scanning Configuration files... The following is the list of files which need updating, each configuration file is followed by a list of possible replacement files. 1) /etc/portage/package.use/zz-autounmask (1) Please select a file to edit by entering the corresponding number. (don't use -3, -5, -7 or -9 if you're unsure what to do) (-1 to exit) (-3 to auto merge all files) (-5 to auto-merge AND not use 'mv -i') (-7 to discard all updates) (-9 to discard all updates AND not use 'rm -i'): -3 Replacing /etc/portage/package.use/zz-autounmask with /etc/portage/package.use/._cfg0000_zz-autounmask mv: overwrite '/etc/portage/package.use/zz-autounmask'? y Exiting: Nothing left to do; exiting. :) (chroot) livecd / # emerge -va sys-boot/os-prober dev-libs/libisoburn sys-fs/mdadm * IMPORTANT: 14 news items need reading for repository 'gentoo'. * Use eselect news read to view new items. These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild N ] dev-util/re2c-1.1.1::gentoo 5769 KiB [ebuild N ] dev-util/ninja-1.8.2-r1::gentoo USE="-doc -emacs {-test} -vim-syntax -zsh-completion" 200 KiB [ebuild N ] dev-util/meson-0.47.1::gentoo PYTHON_TARGETS="python3_6 -python3_5" 1221 KiB [ebuild N ] dev-libs/libburn-1.4.8-r2::gentoo USE="-debug -static-libs" 955 KiB [ebuild N ] dev-libs/libisofs-1.4.8::gentoo USE="acl xattr zlib -debug -static-libs -verbose-debug" 811 KiB [ebuild N ] sys-fs/fuse-common-3.2.2::gentoo 1160 KiB [ebuild N ] sys-fs/mdadm-4.0::gentoo USE="-static" 80 KiB [ebuild N ] sys-fs/fuse-2.9.7-r1::gentoo USE="-examples -static-libs" 646 KiB [ebuild N ] dev-libs/libisoburn-1.4.8-r1::gentoo USE="acl readline xattr zlib -debug -external-filters -external-filters-setuid -frontend-optional -launch-frontend -launch-frontend-setuid -libedit -static-libs" 1502 KiB [ebuild R ] sys-boot/grub-2.02-r3:2/2.02-r3::gentoo USE="fonts mount* nls themes -debug -device-mapper -doc -efiemu -libzfs -multislot -sdl -static {-test} -truetype" GRUB_PLATFORMS="efi-64 pc -coreboot -efi-32 -emu -ieee1275 -loongson -multiboot -qemu -qemu-mips -uboot -xen -xen-32" 0 KiB [ebuild N ] sys-boot/os-prober-1.76-r1::gentoo 26 KiB Total: 11 packages (10 new, 1 reinstall), Size of downloads: 12367 KiB Would you like to merge these packages? [Yes/No] yes >>> Verifying ebuild manifests >>> Emerging (1 of 11) dev-util/re2c-1.1.1::gentoo
Troubleshooting – partition troubles
If you encounter an error with parted, which cannot save your new layout it’s probably because the disks you use might be a part of a RAID or LVM group or similar:
Error: Partition(s) 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.
So you should stop the relative services:
livecd ~ # parted /dev/sda GNU Parted 3.2 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel gpt Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? Yes Error: Partition(s) 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? Cancel (parted) q livecd ~ # ls -al /dev/mapper/ total 0 drwxr-xr-x 2 root root 120 Sep 11 14:57 . drwxr-xr-x 14 root root 3860 Sep 11 15:12 .. crw------- 1 root root 10, 236 Sep 11 14:57 control lrwxrwxrwx 1 root root 7 Sep 11 14:57 fedora_localhost--live-home -> ../dm-1 lrwxrwxrwx 1 root root 7 Sep 11 14:57 fedora_localhost--live-root -> ../dm-2 lrwxrwxrwx 1 root root 7 Sep 11 14:57 fedora_localhost--live-swap -> ../dm-0 livecd ~ # cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] [raid0] [raid1] [raid10] [linear] [multipath] unused devices: <none> livecd ~ # rc-service lvm stop * WARNING: you are stopping a boot service * Shutting down the Logical Volume Manager * Shutting Down LVs & VGs ... [ ok ] * Finished shutting down the Logical Volume Manager livecd ~ # ls -al /dev/mapper/ total 0 drwxr-xr-x 2 root root 60 Sep 11 15:14 . drwxr-xr-x 13 root root 3780 Sep 11 15:14 .. crw------- 1 root root 10, 236 Sep 11 14:57 control
As you can see here we had an old Fedora installation with LVM groups on the disk, the easiest way is just to stop the lvm service!
dammn!!! … thanks, its the only tut. that works for me. 3 time trying to install gentoo. nicely done!.
(parted) name 2 rootfs ? ))