How to install Gentoo Linux
Quickest way to install Gentoo Linux.
This guide deliberately omits certain things for the sake of speed of installation and simplicity, only proceed if you have also read the official Gentoo installation guide and are experienced enough to know what is omitted and needs to be done for your setup. This guide is not a replacement for the official Gentoo Wiki.
Boot into ISO
Set keymap
1
loadkeys uk
Configure networking
If using ethernet it should already be setup with dhcp if not, run dhcpcd.
If using wifi run net-setup <wlan interface name> and select your SSID and enter the password.
Partition the disks
First, you need to check whether the ISO is running in UEFI mode or BIOS mode, to do this, run ls /sys/firmware/efi, if anything shows up you are running in UEFI mode, if not you are running in BIOS mode.
UEFI requires a 100MB FAT filesystem at the start of the disk which will contain the ESP (EFI System Partition). This is where the bootloader will place its EFI files.
BIOS does not require this. Although if your disk is formatted as GPT, an 8mb unformatted partition with the bios-grub flag enabled is required at the start of the disk.
Swap partitions need to be the same size as the amount of RAM you have. But if hibernation is required, the swap partition needs to be twice the size of the total amount of system memory e.g:
- 8GB RAM = 16GB Swap
- 16GB RAM = 32GB Swap
Create partitions on the disk
GNU fdisk can be used to create partitions.
Make filesystems on the partitions
For ext4:
1
mkfs.ext4 <part>
Mount rootfs in /mnt/gentoo
1
mount -v <part> /mnt/gentoo
Turn swap on
1
swapon <swappart>
Change directory into /mnt/gentoo and fetch the Stage 3 tarball
Use a desktop profile if you are going to use any sort of window manager or desktop environment.
There’s also Plasma and Gnome profiles, use those when you are using Plasma or Gnome.
You can use the links web browser to download the stage3 tarball:
1
links https://www.gentoo.org
Extract the Stage 3 tarball
With:
1
tar xf stage3* --xattrs-include='*.*' --numeric-owner
Configure /etc/portage/make.conf
- Compile options, accepted licenses, CPU flags etc..
https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Stage#Configuring_compile_options
Change root into /mnt/gentoo
To make sure the chrooted system uses the correct DNS server run:
1
cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
Use arch-chroot as it automatically mounts the required partitions necessary to chroot.
Then run:
1
cd /mnt/gentoo && arch-chroot .
When inside the chroot run:
1
export PS1="(chroot) ${PS1}"
Grab a snapshot of the repository
1
emerge-webrsync
This will sync a snapshot of the Gentoo repos from 24 hours ago which is sufficient.
This MUST be done before the next step or else you will get errors about the profile not being setup correctly.
Add mirrors to make.conf
Grab mirrorselect with:
1
emerge -av1 app-portage/mirrorselect
Then select the mirrors to add to make.conf:
1
mirrorselect -i -o >> /etc/portage/make.conf
Enable binary package support
Add this to /etc/portage/make.conf:
1
2
3
4
5
# Appending getbinpkg to the list of values within the FEATURES
# variable
FEATURES="${FEATURES} getbinpkg"
# Require signatures
FEATURES="${FEATURES} binpkg-request-signature"
Then run getuto to grab signatures for binary packages.
Install a kernel
With sys-kernel/gentoo-kernel-bin you get a binary kernel without the need for any of that manual stuff, quick and simple.
If using
grubas your bootloader, first add this USE flag to/etc/portage/package.use/installkernel:
1 echo "sys-kernel/installkernel grub" | tee /etc/portage/package.use/installkernelThis causes
installkernelto rebuild the/boot/grub/grub.cfgfile when the kernel gets updated / removed.
Setup locale
Uncomment or add your locale to /etc/locale.gen:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# /etc/locale.gen: list all of the locales you want to have on your system.
# See the locale.gen(5) man page for more details.
#
# The format of each line:
# <locale name> <charset>
#
# Where <locale name> starts with a name as found in /usr/share/i18n/locales/.
# It must be unique in the file as it is used as the key to locale variables.
# For non-default encodings, the <charset> is typically appended.
#
# Where <charset> is a charset located in /usr/share/i18n/charmaps/ (sans any
# suffix like ".gz").
#
# All blank lines and lines starting with # are ignored.
#
# For the default list of supported combinations, see the file:
# /usr/share/i18n/SUPPORTED
#
# Whenever glibc is emerged, the locales listed here will be automatically
# rebuilt for you. After updating this file, you can simply run `locale-gen`
# yourself instead of re-emerging glibc.
en_GB.UTF-8 UTF-8
#en_US ISO-8859-1
#en_US.UTF-8 UTF-8
#ja_JP.EUC-JP EUC-JP
#ja_JP.UTF-8 UTF-8
#ja_JP EUC-JP
#en_HK ISO-8859-1
#en_PH ISO-8859-1
#de_DE ISO-8859-1
#de_DE@euro ISO-8859-15
#es_MX ISO-8859-1
#fa_IR UTF-8
#fr_FR ISO-8859-1
#fr_FR@euro ISO-8859-15
#it_IT ISO-8859-1
Then run locale-gen to generate locales.
Select the locale
List the locales on the system with:
eselect locale listThen, select the locale with:
eselect locale set <num>Finally to update the environment, run:
env-update && source /etc/profile && export PS1="(chroot) ${PS1}"
Setup timezone, hostname, keymap, fstab, and hosts
There are 5 files that now need to be configured:
/etc/localtimewhich will be a link to your timezone, for example:1
ln -sfv /usr/share/zoneinfo/Europe/London /etc/localtime
/etc/hostnamewhich contains the hostname:1
gentoo
/etc/vconsole.confwhich contains the keymap for the system console, e.g:1
KEYMAP=uk
/etc/fstabwhich contains filesystem information and where to mount them, type of filesystem, filesystem options, fsck options, etc..1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# /etc/fstab: static file system information. # # See the manpage fstab(5) for more information. # # NOTE: The root filesystem should have a pass number of either 0 or 1. # All other filesystems should have a pass number of 0 or greater than 1. # # NOTE: Even though we list ext4 as the type here, it will work with ext2/ext3 # filesystems. This just tells the kernel to use the ext4 driver. # # NOTE: You can use full paths to devices like /dev/sda3, but it is often # more reliable to use filesystem labels or UUIDs. See your filesystem # documentation for details on setting a label. To obtain the UUID, use # the blkid(8) command. # <fs> <mountpoint> <type> <opts> <dump> <pass> #LABEL=boot /boot ext4 defaults 1 2 #UUID=58e72203-57d1-4497-81ad-97655bd56494 / xfs defaults 0 1 #LABEL=swap none swap sw 0 0 #/dev/cdrom /mnt/cdrom auto noauto,ro 0 0
/etc/hostswhich contains your hosts:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
# The format of lines in this file is: # # IP_ADDRESS canonical_hostname [aliases...] # #The fields can be separated by any number of spaces or tabs. # # In the presence of the domain name service or NIS, this file may not be # consulted at all; see /etc/host.conf for the resolution order. # # IPv4 and IPv6 localhost aliases 127.0.0.1 localhost put-your-hostname-here ::1 localhost # # Imaginary network. #10.0.0.2 myname #10.0.0.3 myfriend # # According to RFC 1918, you can use the following IP networks for private # nets which will never be connected to the Internet: # # 10.0.0.0 - 10.255.255.255 # 172.16.0.0 - 172.31.255.255 # 192.168.0.0 - 192.168.255.255 # # In case you want to be able to connect directly to the Internet (i.e. not # behind a NAT, ADSL router, etc...), you need real official assigned # numbers. Do not try to invent your own network numbers but instead get one # from your network provider (if any) or from your regional registry (ARIN, # APNIC, LACNIC, RIPE NCC, or AfriNIC.) #
Install microcode
| Intel CPUs | AMD CPUs |
|---|---|
| emerge -av intel-microcode | (built-in to sys-kernel/linux-firmware) |
Install firmware
1
emerge -av sys-kernel/linux-firmware
Install the bootloader
Install grub with emerge -av sys-boot/grub, then run grub-install /dev/<name of disk>. Make sure you do not install grub onto a partition (e.g sda1), this command needs to run on your whole disk (e.g sda).
If you are using EFI run:
1 grub-install --efi-directory=/boot/efi /dev/<name of disk>This will install the required files for grub to boot on EFI into
/boot/efi.
Then, run grub-mkconfig -o /boot/grub/grub.cfg to generate the configuration file.
Run systemd initial setup
https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/System#systemd_2
Certain services need to be configured to startup in order to have a functional system before you reboot.
This command will setup a random machine ID for the installation.
1
systemd-machine-id-setup
This command will prompt you for a hostname, timezone, root password etc.. if not already configured. We have configured these things already so it shouldn’t prompt for anything.
1
systemd-firstboot --prompt
Then to enable services needed by the system:
1
systemctl preset-all --preset-mode=enable-only
Install networking software
Either install dhcpcd which is just a dhcp client or NetworkManager which is more full-featured.
Install either of these (not both!) before rebooting into your Gentoo system as you will not be able to get network connectivity otherwise.
NetworkManager steps
If using NetworkManager for networking, enable the systemd service before rebooting:
1
systemctl enable NetworkManager
Set the root password
Set the root password so that you can login to the system after reboot, to do this run: passwd root and enter the password.
Installation is nearly done
All that is left now is to install a display manager, text editor, and a desktop environment or window manager.