5.7 KiB
About gentoo-install
This script performs a reasonably minimal installation of gentoo. An EFI system is highly recommended, but legacy BIOS boot is also supported. The script supports both systemd (default) and OpenRC as the init system. The main performed steps are:
- Partitioning
- Download & cryptographically verify stage3 tarball
- Extract stage3
- Initialize portage
- Install kernel
- Install additional software
The system will use sys-kernel/gentoo-kernel-bin
, which should be suitable
to boot most systems out of the box. It is strongly recommend to replace this kernel
with a custom built one, when the system is functional. If you are looking for a way
to detect and manage your kernel configuration, have a look at autokernel.
Quick start
Edit gentoo.conf
and execute ./install -i
in any live system.
You can review the partitioning that will be applied before anything critical is done.
Afterwards, this will apply the partitioning scheme and properly
install the selected stage3 gentoo system. By default, the new system will use
sys-kernel/gentoo-kernel-bin
as the kernel, and an initramfs generated by gentoo's genkernel to provide
a bootable environment. The script can optionally install sshd
to
allow for a convenient setup of the new system afterwards.
Overview
Here is a more complete overview of what this script does:
- Partition disks (supports gpt, raid, luks)
- Download and cryptographically verify the newest stage3 tarball
- Extract the stage3 tarball
- Sync portage tree
- Configure portage (create zz-autounmask files, configure MAKEOPTS, EMERGE_DEFAULT_OPTS)
- Select the fastest gentoo mirrors
- Configure the base system
- Install git (so you can add your portage overlays later)
- Install
sys-kernel/gentoo-kernel-bin
(until you replace it) - Create efibootmgr entry or install syslinux depending on whether your system uses EFI
- Generate a basic fstab
- Ask for a root password
Also, optionally the following will be done:
- Install sshd with secure config
- Install dhcpcd (only for OpenRC)
- Install additional packages provided in config
Anything else is probably out of scope for this script, but you can obviously do anything later on when the system is booted. I highly recommend building a custom kernel. Have a look at the Recommendations section.
Install
Installing gentoo with this script is simple.
- Boot into the live system of your choice. As the script requires some utilities, I recommend using a live system where you can quickly install new software. Any Arch Linux live iso works fine.
- Clone this repository
- Edit
gentoo.conf
, and particularily pay attention to the device which will be partitioned. The script will ask for confirmation before doing any partitioning - but better be safe there. - Execute
./install -i
. The script will tell you if your live system is missing any required software.
The script should be able to run without any user supervision after partitioning, but depending on the current state of the gentoo repository you might need to intervene in case a package fails to emerge. The critical commands will ask you what to do in case of a failure.
Config
The config file gentoo.conf
allows you to adjust some parameters of the installation.
The most important ones will probably be the device to partition, and the stage3 tarball name
to install. By default you will get the hardened nomultilib profile without systemd.
(Optional) sshd
The script can provide a fully configured ssh daemon with reasonably good security settings. It will by default only allow ed25519 keys, restrict key exchange algorithms to a reasonable subset, disable any password based authentication, and only allow root to login.
You can provide keys that will be written to root's .ssh/authorized_keys
file. This will allow
you to directly continue your setup with infrastructure management software such as ansible or simple_automation.
(Optional) Additional packages
You can add any amount of additional packages to be installed on the target system.
These will simply be passed to a final emerge
call before the script is done, and autounmasking will also be done automatically.
It is recommended to keep this to a minimum, because of the heavily "interactive" nature of gentoo package management ;)
Troubleshooting
In theory, after the initial sanity check, the script should be able to finish unattendedly. But given the unpredictability of future gentoo versions, you might still run into an issue.
The script checks every command for success, so if anything fails during installation, you will be given a proper message of what went wrong. Inside the chroot, most commands will be executed in a checked loop, and allow you to interactively fix problems with a shell, to retry, or to skip the command.
Recommendations
There are some things that you probably want to do after installing the base system, or should consider:
- Read the news with
eselect news read
. - Use a custom kernel (config and hardening, see autokernel), and remove
gentoo-kernel-bin
- Adjust
/etc/portage/make.conf
- Set
CFLAGS
to-O2 -pipe -march=native
for native builds - Set
CPU_FLAGS_X86
using thecpuid2cpuflags
tool - Set
FEATURES="buildpkg"
if you want to build binary packages
- Set
- Use a safe umask like
umask 0077
Acknowledgements
This installer bundles a statically linked copy of newt