Gentoo is a Linux distro that allows for the source files to be compiled locally on the machine running them. The process of installing packages can take a little longer, but it optimizes the packages for the local system. The package system is called Portage.
Gentoo is not a distro that is useful for all users. For those who want more control over their system and all packages, this is the one for you. Installation can take a bit of effort, but once you have an idea of what is going on, it is not impossible.
Installation Steps
To install Gentoo, there are basically ten steps to get the install done. Granted, this is just getting it installed, this is not installing a Desktop Manager.
The ten steps are:
In this article, I will cover installing Gentoo using the OpenRC 'init system'. The 'init system' is the service manager provided by the distro. Most people may be more familiar with 'systemd' using the command 'systemctl'. OpenRC is another 'init system' that uses 'rc-service' command to start, stop and pause services.
Another main point of Gentoo is having the Linux Operating System optimized for your hardware. Managment is done through compiling a kernel specific to your hardware. By optimizing the kernel, you can have a smoother running system than a general binary kernel that may run drivers that your system does not need. Compiling a specific kernel is beyond the scope of this article, but I will walk you through getting the basic system installed. After you install it, you can change the kernel as you need.
So, let's get this going and go through the ten steps to get Gentoo installed.
Step 1 - Choosing the Right Installation Medium
The hardware requirements are a system with AMD or Intel 64-bit processors. RAM should be a minimum of 2 GB. You need at least 8 GB of drive space for Gentoo and 2 GB for the swap file.
The media you can use for installation is a 'minimal installation' ISO, which boots to a Command-Line-Interface (CLI), or a LiveGUI system which has a Desktop Manager. The LiveGUI allows for easier configuration of network devices to start the installation and attach to the Internet.
If you open a browser to 'https://www.gentoo.org/downloads/' you should see something similar to Figure 1. Here, you can choose either AMD64 or ARM64. If you plan on installing Gentoo on a Raspberry PI, or similar device, use ARM64.
FIGURE 1
For our install, we will use the LiveGUI to make the network configuration a little simpler, especially for wireless connections.
So, download the LiveGUI for your CPU type. Use Balena Etcher, or a similar program, to 'burn' the ISO to a USB Flash Drive for booting.
After it is done, you can insert the Flash Drive into the system you want to install Gentoo and boot from it.
After it boots up, we can start Step 2.
Step 2 - Configuring the Network
Since we are using a LiveGUI image, Gentoo starts in a KDE environment, as shown in Figure 2.
FIGURE 2
Once the GUI starts, you can close the 'Welcome Center' information window. Behind this is a window to allow you to configure your keyboard.
Right-click on the Desktop and select 'Display Configuration'. Set your screen resolution if needed. In the left pane, select 'Wi-Fi and Internet'. Here you can set up your Wired Connection or Wireless Connection as needed. For the install, you want to be connected to the Internet.
The next thing we will do in the Graphical User Interface (GUI), is to set the date, time and time-zone. There can be a problem since it will ask for a password and there is no password, so we need to set one.
Use the following two commands in a terminal to set a Root password for the live system:
Here, we changed to root privileges and then change the password for the Root user. The system will ask you to enter in a password and then to verify the password.
Now, go back to the System Settings, in the left pane, go to 'Date & Time'. Near the top of the window, select 'Timezone'. Set your appropriate Timezone. Once you 'Apply' the change, you can go back to the 'Date and Time' tab to see that the proper date and time are set. If there is an issue, then change it manually.
You can also configure the Wi-Fi in the GUI if you do not use a wired connection.
Back in a terminal, you can check network connectivity by issuing a 'ping' command. Try to ping a server by name to test DNS as well. An example is to 'ping www.google.com'.
Hopefully, this should all be fine. If there are issues, you will need to troubleshoot and verify you have an IP Address, ping a system on the local network, ping the gateway and then ping something on the Internet.
Step 3 - Preparing the Disks
I have followed these instructions on physical hardware, both Intel and AMD, so these instructions work well for the current ISO build (May 2025).
I am setting aside 1 GB of space for the Boot partition (EFI), 4 GB for the swap file, and 40 GB for the root partition. Using physical hardware, you should have more space available, so use the same for the Boot and Swap partition while the rest goes for the root partition.
Now, keep a terminal open for the rest of the article to run necessary commands. Use 'sudo su' to get elevated privileges for the rest of the commands. We now need to set up the partitions as needed and format them.
You can run the command 'lsblk' to verify your drive name (sda) or (sdb). If you are booting from a USB Flash Drive, it should be 'sda', and the hard disk should be 'sdb'.
For my instructions, I will consider the ISO a CD and the hard disk is 'sda'. Change the commands according to your drive's name as given by 'lsblk'. Just remember, the numbering should be the same:
Whether you drive is 'sda' or 'sdb', the Boot partition is 'sda1' or 'sdb1'.
In the terminal, enter the command 'cfdisk' followed by '/dev/sd?', replacing the question mark with your drive name from 'lsblk'. The 'cfdisk' program uses 'curses', a general text-based program without writing code for a specific terminal types. So, in my case, the command is 'cfdisk /dev/sda'. Make sure you get it right, since we will erase the disk.
The first thing it should ask is what type of label type for the disk. You will want to select 'gpt'.
Figure 3 shows the initial screen after selecting the label type. All the disk space is free and has not been used. So, select 'New' to create a new partition. The partition size for the new partition should default to the full size of the disk. Change the amount to '1G'. Next, arrow down one time to highlight the 'free space', select 'New' and set this partition to '4G'. Set the remaining free space into a new partition.
FIGURE 3
Arrow up to the '1G' partition and select 'Type'. Change the type to 'EFI System'. For the '4G' partition, set the type to 'Linux swap'. Set the last partition to 'Linux filesystem'. You should have a screen similar to Figure 4. Now, just highlight 'Write' and press Enter. It should prompt you if you want to write these settings to disk. Type 'yes' and press Enter. Highlight ‘Quit’ in 'cfdisk' to quit the program.
FIGURE 4
Running 'lsblk' should show the partitions. If not, then you need to run the commands under 'cfdisk' as root.
Since the partitions exist, we can format them properly to start installation soon.
The Boot partition needs to be FAT32. Issue the command to format it as:
The Root partition needs to be EXT4, so run the command:
For the Swap partition, use the command:
The first command will format it as a Swap partition, then the second one will enable it.
Next, we need to create a folder named '/mnt/gentoo' because this is where we will mount the partitions to install the files. To create the folder, we need to use the '-p' command to create a sub-directories if they do not exist:
So, we should now have a folder in which we will mount all the partitions with:
Next, we need to create a folder for the Boot partition and mount it:
If you look, the 'boot' folder is empty and the '/mnt/gentoo' folder has folders in it which are the base of our system. Once we install all the files on these mounted partitions, we can reboot from the disk and not the LiveGUI image.
Step 4 - Installing the Gentoo Installation Files
Everything is in place to put in the basic operating system for Gentoo. The system we are running is completely in memory and booted from the ISO. We have our partitions created. We need to put our basic system in place. This step will require us to get the 'Stage 3' file for our system. If you look back at Figure 1, you can see that there is an option for 'Stage 3 openrc' for the 'AMD64' processor. So, in our LiveGUI, open Firefox and go to 'https://www.gentoo.org/downloads/'. Select the proper 'Stage 3' file (for openrc) and download it, then move it to '/mnt/gentoo'. You can do it in a terminal or through the GUI, but in the GUI you need to open the target as an administrator so you can write the file. From the terminal, we need to extract the 'Stage 3' file. Use the command:
NOTE: Use the <tab> key to auto-complete the filename. Be sure to include the parameters after pressing <tab>.
Once completed, you can run 'ls' to see that a lot of files exist in the folder, which is '/dev/sda3'.
Now we need to configure the optimization settings for the compiler. The configuration settings are in '/mnt/gentoo/etc/portage/make.conf' and we need to edit the file with 'nano':
There will be a line starting with 'COMMON_FLAGS=-02 -pipe', so change it to:
After the 'FFLAGS' line, add a new line and enter:
Change the number to the number of cores plus one. In my case I have 2 cores, so I put in a '3'. Change your number according to your system. The number must also reflect the amount of RAM. Each core you specify requires 2 GB of RAM. Set the value to the lower number of the two calculations. Save and close the file.
Step 5 - Installing the Gentoo Base System
Right now, we are running as the LiveGUI system and we need to change to the basic '/mnt/gentoo' folder by 'chroot'. In this manner, we are looking at '/mnt/gentoo' as the root of the system. We need to prepare the system to allow everything to still work after we chroot into it. We need the DNS information so we can access the Internet. We need to copy the 'resolv.conf' file to our new system:
There are quite a few of drives we need to mount to get things to work, so a shortcut here is a script:
We need to reload all the settings in '/etc/profile' into memory with the command:
If you perform 'ls', you can see that we are in the root of our partition we are building. We can have the system show we are using 'chroot' into the folder. We can change the default prompt:
The prompt should now be '(chroot) livecd / #'. If needed, anytime you lose the '(chroot)' prompt, just use the export command again. You can now try to ping a website on the Internet, and it should work just fine. Next, we need to get a snapshot of the Portage repositories. The developers update the file daily, so it may be best to run this once a day, especially before installing software. To get the snapshot, use the command:
We should now select a repository to use as our default when downloading software. Of course, you want one that is close to you, so you need to select one or more from your country. Before selecting, we need to install the mirror select program:
Once installed, we can use:
Use the spacebar to select repositories and enter to save and quit. Now we need to update the new repository we selected:
The system is set up on profiles that control the flags set in the configuration files. We now need to select a profile to use. To get a list, use the command:
The one we want is 'default/linux/amd64/23.0/desktop (stable)', which should be number 23. You can see that number 22 is a 'systemd' profile, so 23 is an 'openrc' profile. To set the profile to number 23, use the command:
We now need to update our profile with:
This will get rid of our chroot prompt, which we can export back again as before. We now need to add a binary package host to install binary packages which are pre-compiled and will install easier than compiling every package. Add the following line to '/etc/portage/make.conf':
Now to get the GPG signatures, run:
We can set a USE flag to show what we want compiled into our system or removed. The following is an example to add future support for KDE:
If you run the new command, 'cpuid2cpuflags', you'll see an output of the capabilities of the CPU. We need to add this list to a file with the command:
Now we can perform an update to allow the downloading of all packages, which is called updating the world:
This update can take a long time to finish. We need to set the time-zone in our system we are building. At the beginning, we set the time-zone for the Operating System in RAM. You need to list the files in '/usr/share/zoneinfo' and find the time zone file. Mine is '/usr/share/zoneinfo/US/East-Indiana' and I will need to create a link from this file to '/etc/localtime' with:
We now need to set the locale by editing the file:
In the file is a list of locales, uncomment the line. My locale line is 'en_US.UTF-8 UTF-8'. Save and close the file after uncommenting your locale. Next, you can list locales with:
Verify you set the locale, otherwise perform 'eselect locale set #' and specify the number of the line to set. The line with the asterisk (*) after it is the current one selected. Next, we can source the profile again followed by exporting the prompt again. We can then reload the environment and include the CPU information with:
Before continuing, we need to have the system show that we accept all licenses, just in case an add-on requires it. Open the file at '/etc/portage/make.conf' and add the line:
Save and close the editor.
Step 6 - Configuring the Linux Kernel
Now we can set up the kernel. As I said before, I will go through installing a basic kernel. We need to add some basic firmware:
If you have an Intel CPU, then you need to run:
If you had not accepted the licenses from before, you would get an error here. Also, there is the sound firmware:
We can now install the kernel bin file:
Figure 5 shows an error that occurred. I could have shown you the way around this, but you need to know how to handle these errors.
FIGURE 5
The information shows you need 'dracut' installed. The line you need is:
NOTE: Whenever you perform an install of any packages, watch for errors and know that you handle it as stated in the error message. You can
now try to ping a website on the Internet and it should work just finer this one is as follows.
So, to make this work, we can run the command:
Once you issue the command, you can reissue the command that failed, and it should work now.
NOTE: Depending on your hardware, the failure may or may not happen. It could also occur in a different area. You can issue a command to
list all available kernels:
There should be only one kernel listed and it should be the default. If you use the command 'ls /boot' it should list files now that the kernel is present.
Step 7 - Configuring the System
In this section, we will set up the 'fstab' file, install DHCP, set the system's hostname and set the Root password. We can set the 'fstab' manually, but this can cause issues if anything is wrong. So we will install a program called 'genfstab' to generate the file for us.
If you run the command 'genfsta /' you can see the output that looks like just what we need for 'fstab'. To make this work, use:
Now, when we edit '/etc/fstab' you will see something similar to Figure 6.
FIGURE 6
In the 'fstab' file, you need to uncomment the UUID lines and remove the portion of the following line that starts with the device name '/dev/sdxx'. Make it all on one line per UUID, as shown in Figure 7.
FIGURE 7
The Hostname is now ready to set. Determine what the Hostname will be and I will use a generic name like 'tester' which you can replace in the following lines of code.
Edit the file 'etc/hosts' and add the hostname after the loopback address, before 'localhost', as shown:
The lines install DHCP, adds the service to start automatically and finally to start it now. We need to get the Ethernet service started. Initially, you need to find the name of the port with the command 'ifconfig'. My system shows the name 'enp1s0'. If yours differs, use the name listed on your system. To set it up, use the following commands to create a link:
We do not need to start it yet since this is the OS we are building and it is not active yet. We are still running from the Gentoo system we booted from and are running in RAM. We have set the password for Root on the system in RAM, but to set the password for the system we are building, run 'passwd' and set the password and verify it. If you use a keyboard other than a 'qwerty' style, you can edit the file 'etc/conf.d/keymaps' to change the type you use. We should also set up a user here for after we reboot.
This will create a user named 'user1' with elevated privileges and sets a password. To make sure the user has elevated privileges, you need to edit '/etc/sudoers' and uncomment the line, giving all access to '%wheel', which is done at the end of this setup.
Step 8 - Install System Tools
We will need the command 'sudo' unless we will always log in as root.
You can install a system logger and start it with:
We can install file indexing:
This installs the indexer and updates the index. Shell completion for BASH is definitely a must:
We need support for file systems:
This will give us support for FAT32 and EXT. If you have a system with an NVME drive, you need support for it:
A time synchronization service would help:
We can also add tools necessary for wireless networking:
Step 9 - Configure the Bootloader
Now we need to set up GRUB. If you do not do this correctly, then the system will not boot properly. Let's start by setting the platform type:
If you plan on dual-booting, you need the OS-Prober too:
To finish the GRUB installation, use the following commands:
Enter 'exit' once. Here, we should still be in the elevated privilege mode. You can tell by the prompt ending in a pound sign (#). We can now open up the 'wheel' group for elevated privileges by editing the file '/etc/sudoers' and uncommenting the line for '%wheel' near the end.
Once saved, enter the command 'exit' again. The unmount the drives you mounted before using the command:
Reboot the system, but remember to remove the LiveGUI after the system shuts down and before it restarts so the system does not boot from of it again.
Conclusion
This is a long procedure to get Gentoo installed and running. Granted, it is a Command-Line Interface (CLI) only, but it gets the OS running.
Most people may be used to using 'systemd' instead of 'openrc', but this is part of the modularity of Linux.
Gentoo is not a distro that is useful for all users. For those who want more control over their system and all packages, this is the one for you. Installation can take a bit of effort, but once you have an idea of what is going on, it is not impossible.
Installation Steps
To install Gentoo, there are basically ten steps to get the install done. Granted, this is just getting it installed, this is not installing a Desktop Manager.
The ten steps are:
- Choosing the right installation medium
- Configuring the network
- Preparing the disks
- Installing the Gentoo installation files
- Installing the Gentoo base system
- Configuring the Linux kernel
- Configuring the system
- Installing system tools
- Configuring the bootloader
- Finalizing the installation
In this article, I will cover installing Gentoo using the OpenRC 'init system'. The 'init system' is the service manager provided by the distro. Most people may be more familiar with 'systemd' using the command 'systemctl'. OpenRC is another 'init system' that uses 'rc-service' command to start, stop and pause services.
Another main point of Gentoo is having the Linux Operating System optimized for your hardware. Managment is done through compiling a kernel specific to your hardware. By optimizing the kernel, you can have a smoother running system than a general binary kernel that may run drivers that your system does not need. Compiling a specific kernel is beyond the scope of this article, but I will walk you through getting the basic system installed. After you install it, you can change the kernel as you need.
So, let's get this going and go through the ten steps to get Gentoo installed.
Step 1 - Choosing the Right Installation Medium
The hardware requirements are a system with AMD or Intel 64-bit processors. RAM should be a minimum of 2 GB. You need at least 8 GB of drive space for Gentoo and 2 GB for the swap file.
The media you can use for installation is a 'minimal installation' ISO, which boots to a Command-Line-Interface (CLI), or a LiveGUI system which has a Desktop Manager. The LiveGUI allows for easier configuration of network devices to start the installation and attach to the Internet.
If you open a browser to 'https://www.gentoo.org/downloads/' you should see something similar to Figure 1. Here, you can choose either AMD64 or ARM64. If you plan on installing Gentoo on a Raspberry PI, or similar device, use ARM64.
FIGURE 1
For our install, we will use the LiveGUI to make the network configuration a little simpler, especially for wireless connections.
So, download the LiveGUI for your CPU type. Use Balena Etcher, or a similar program, to 'burn' the ISO to a USB Flash Drive for booting.
After it is done, you can insert the Flash Drive into the system you want to install Gentoo and boot from it.
After it boots up, we can start Step 2.
Step 2 - Configuring the Network
Since we are using a LiveGUI image, Gentoo starts in a KDE environment, as shown in Figure 2.
FIGURE 2
Once the GUI starts, you can close the 'Welcome Center' information window. Behind this is a window to allow you to configure your keyboard.
Right-click on the Desktop and select 'Display Configuration'. Set your screen resolution if needed. In the left pane, select 'Wi-Fi and Internet'. Here you can set up your Wired Connection or Wireless Connection as needed. For the install, you want to be connected to the Internet.
The next thing we will do in the Graphical User Interface (GUI), is to set the date, time and time-zone. There can be a problem since it will ask for a password and there is no password, so we need to set one.
Use the following two commands in a terminal to set a Root password for the live system:
Code:
sudo su
passwd
Here, we changed to root privileges and then change the password for the Root user. The system will ask you to enter in a password and then to verify the password.
Now, go back to the System Settings, in the left pane, go to 'Date & Time'. Near the top of the window, select 'Timezone'. Set your appropriate Timezone. Once you 'Apply' the change, you can go back to the 'Date and Time' tab to see that the proper date and time are set. If there is an issue, then change it manually.
You can also configure the Wi-Fi in the GUI if you do not use a wired connection.
Back in a terminal, you can check network connectivity by issuing a 'ping' command. Try to ping a server by name to test DNS as well. An example is to 'ping www.google.com'.
Hopefully, this should all be fine. If there are issues, you will need to troubleshoot and verify you have an IP Address, ping a system on the local network, ping the gateway and then ping something on the Internet.
Step 3 - Preparing the Disks
I have followed these instructions on physical hardware, both Intel and AMD, so these instructions work well for the current ISO build (May 2025).
I am setting aside 1 GB of space for the Boot partition (EFI), 4 GB for the swap file, and 40 GB for the root partition. Using physical hardware, you should have more space available, so use the same for the Boot and Swap partition while the rest goes for the root partition.
Now, keep a terminal open for the rest of the article to run necessary commands. Use 'sudo su' to get elevated privileges for the rest of the commands. We now need to set up the partitions as needed and format them.
You can run the command 'lsblk' to verify your drive name (sda) or (sdb). If you are booting from a USB Flash Drive, it should be 'sda', and the hard disk should be 'sdb'.
For my instructions, I will consider the ISO a CD and the hard disk is 'sda'. Change the commands according to your drive's name as given by 'lsblk'. Just remember, the numbering should be the same:
Code:
sd?1Boot
sd?2Swap
sd?3Root
Whether you drive is 'sda' or 'sdb', the Boot partition is 'sda1' or 'sdb1'.
In the terminal, enter the command 'cfdisk' followed by '/dev/sd?', replacing the question mark with your drive name from 'lsblk'. The 'cfdisk' program uses 'curses', a general text-based program without writing code for a specific terminal types. So, in my case, the command is 'cfdisk /dev/sda'. Make sure you get it right, since we will erase the disk.
The first thing it should ask is what type of label type for the disk. You will want to select 'gpt'.
Figure 3 shows the initial screen after selecting the label type. All the disk space is free and has not been used. So, select 'New' to create a new partition. The partition size for the new partition should default to the full size of the disk. Change the amount to '1G'. Next, arrow down one time to highlight the 'free space', select 'New' and set this partition to '4G'. Set the remaining free space into a new partition.
FIGURE 3
Arrow up to the '1G' partition and select 'Type'. Change the type to 'EFI System'. For the '4G' partition, set the type to 'Linux swap'. Set the last partition to 'Linux filesystem'. You should have a screen similar to Figure 4. Now, just highlight 'Write' and press Enter. It should prompt you if you want to write these settings to disk. Type 'yes' and press Enter. Highlight ‘Quit’ in 'cfdisk' to quit the program.
FIGURE 4
Running 'lsblk' should show the partitions. If not, then you need to run the commands under 'cfdisk' as root.
Since the partitions exist, we can format them properly to start installation soon.
The Boot partition needs to be FAT32. Issue the command to format it as:
Code:
mkfs.fat -F 32 /dev/sda1
The Root partition needs to be EXT4, so run the command:
Code:
mkfs.ext4 /dev/sda3
For the Swap partition, use the command:
Code:
mkswap /dev/sda2
swapon /dev/sda2
The first command will format it as a Swap partition, then the second one will enable it.
Next, we need to create a folder named '/mnt/gentoo' because this is where we will mount the partitions to install the files. To create the folder, we need to use the '-p' command to create a sub-directories if they do not exist:
Code:
mkdir -p /mnt/gentoo
So, we should now have a folder in which we will mount all the partitions with:
Code:
mount /dev/sda3 /mnt/gentoo
Next, we need to create a folder for the Boot partition and mount it:
Code:
mkdir -p /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
If you look, the 'boot' folder is empty and the '/mnt/gentoo' folder has folders in it which are the base of our system. Once we install all the files on these mounted partitions, we can reboot from the disk and not the LiveGUI image.
Step 4 - Installing the Gentoo Installation Files
Everything is in place to put in the basic operating system for Gentoo. The system we are running is completely in memory and booted from the ISO. We have our partitions created. We need to put our basic system in place. This step will require us to get the 'Stage 3' file for our system. If you look back at Figure 1, you can see that there is an option for 'Stage 3 openrc' for the 'AMD64' processor. So, in our LiveGUI, open Firefox and go to 'https://www.gentoo.org/downloads/'. Select the proper 'Stage 3' file (for openrc) and download it, then move it to '/mnt/gentoo'. You can do it in a terminal or through the GUI, but in the GUI you need to open the target as an administrator so you can write the file. From the terminal, we need to extract the 'Stage 3' file. Use the command:
Code:
tar xpvf stage3-<tab> --xattrs-include='*.*' --numeric-owner -C /mnt/gentoo
NOTE: Use the <tab> key to auto-complete the filename. Be sure to include the parameters after pressing <tab>.
Once completed, you can run 'ls' to see that a lot of files exist in the folder, which is '/dev/sda3'.
Now we need to configure the optimization settings for the compiler. The configuration settings are in '/mnt/gentoo/etc/portage/make.conf' and we need to edit the file with 'nano':
Code:
nano /mnt/gentoo/etc/portage/make.conf
There will be a line starting with 'COMMON_FLAGS=-02 -pipe', so change it to:
Code:
COMMON_FLAGS=-march=native -02 -pipe
After the 'FFLAGS' line, add a new line and enter:
Code:
MAKEOPTS="-j3"
Change the number to the number of cores plus one. In my case I have 2 cores, so I put in a '3'. Change your number according to your system. The number must also reflect the amount of RAM. Each core you specify requires 2 GB of RAM. Set the value to the lower number of the two calculations. Save and close the file.
Step 5 - Installing the Gentoo Base System
Right now, we are running as the LiveGUI system and we need to change to the basic '/mnt/gentoo' folder by 'chroot'. In this manner, we are looking at '/mnt/gentoo' as the root of the system. We need to prepare the system to allow everything to still work after we chroot into it. We need the DNS information so we can access the Internet. We need to copy the 'resolv.conf' file to our new system:
Code:
cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
There are quite a few of drives we need to mount to get things to work, so a shortcut here is a script:
Code:
arch-chroot /mnt/gentoo
We need to reload all the settings in '/etc/profile' into memory with the command:
Code:
source /etc/profile
If you perform 'ls', you can see that we are in the root of our partition we are building. We can have the system show we are using 'chroot' into the folder. We can change the default prompt:
Code:
export PS1="(chroot) $PS1"
The prompt should now be '(chroot) livecd / #'. If needed, anytime you lose the '(chroot)' prompt, just use the export command again. You can now try to ping a website on the Internet, and it should work just fine. Next, we need to get a snapshot of the Portage repositories. The developers update the file daily, so it may be best to run this once a day, especially before installing software. To get the snapshot, use the command:
Code:
emerge-webrsync
We should now select a repository to use as our default when downloading software. Of course, you want one that is close to you, so you need to select one or more from your country. Before selecting, we need to install the mirror select program:
Code:
emerge --verbose --oneshot app-portage/mirrorselect
Once installed, we can use:
Code:
mirrorselect -i -o >> /etc/portage/make.conf
Use the spacebar to select repositories and enter to save and quit. Now we need to update the new repository we selected:
Code:
emerge --sync
The system is set up on profiles that control the flags set in the configuration files. We now need to select a profile to use. To get a list, use the command:
Code:
eselect profile list
The one we want is 'default/linux/amd64/23.0/desktop (stable)', which should be number 23. You can see that number 22 is a 'systemd' profile, so 23 is an 'openrc' profile. To set the profile to number 23, use the command:
Code:
eselect profile set 23
We now need to update our profile with:
Code:
source /etc/profile
This will get rid of our chroot prompt, which we can export back again as before. We now need to add a binary package host to install binary packages which are pre-compiled and will install easier than compiling every package. Add the following line to '/etc/portage/make.conf':
Code:
FEATURES="binpkg binpkg-request-signature"
Now to get the GPG signatures, run:
Code:
getuto
We can set a USE flag to show what we want compiled into our system or removed. The following is an example to add future support for KDE:
Code:
USE="-gnome -gtk kde qt5 alsa"
Add this line to '/etc/portage/make.conf'. We now need to add entries for our CPU capability. To do this, we need to add a program named 'cpuid2cpuflags' using:
[code]emerge --oneshot app-portage/cpuid2cpuflags
If you run the new command, 'cpuid2cpuflags', you'll see an output of the capabilities of the CPU. We need to add this list to a file with the command:
Code:
echo "*/* $(cpuid2cpuflags)" > /etc/portage/package.use/00cpu-flags
Now we can perform an update to allow the downloading of all packages, which is called updating the world:
Code:
emerge -uv --update --deep --newuse @world
This update can take a long time to finish. We need to set the time-zone in our system we are building. At the beginning, we set the time-zone for the Operating System in RAM. You need to list the files in '/usr/share/zoneinfo' and find the time zone file. Mine is '/usr/share/zoneinfo/US/East-Indiana' and I will need to create a link from this file to '/etc/localtime' with:
Code:
ln -sf /usr/share/zoneinfo/US/East-Indiana /etc/localtime
We now need to set the locale by editing the file:
Code:
/etc/locale.gen
In the file is a list of locales, uncomment the line. My locale line is 'en_US.UTF-8 UTF-8'. Save and close the file after uncommenting your locale. Next, you can list locales with:
Code:
eselect locale list
Verify you set the locale, otherwise perform 'eselect locale set #' and specify the number of the line to set. The line with the asterisk (*) after it is the current one selected. Next, we can source the profile again followed by exporting the prompt again. We can then reload the environment and include the CPU information with:
Code:
env-update
Before continuing, we need to have the system show that we accept all licenses, just in case an add-on requires it. Open the file at '/etc/portage/make.conf' and add the line:
Code:
ACCEPT_LICENSE="*"
Save and close the editor.
Step 6 - Configuring the Linux Kernel
Now we can set up the kernel. As I said before, I will go through installing a basic kernel. We need to add some basic firmware:
Code:
emerge sys-kernel/linux-firmware
If you have an Intel CPU, then you need to run:
Code:
emerge sys-firmware/intel-microcode
If you had not accepted the licenses from before, you would get an error here. Also, there is the sound firmware:
Code:
emerge sys-firmware/sof-firmware
We can now install the kernel bin file:
Code:
emerge gentoo-kernel-bin
Figure 5 shows an error that occurred. I could have shown you the way around this, but you need to know how to handle these errors.
FIGURE 5
The information shows you need 'dracut' installed. The line you need is:
Code:
>=sys-kernel/installkernel-50 dracut
NOTE: Whenever you perform an install of any packages, watch for errors and know that you handle it as stated in the error message. You can
now try to ping a website on the Internet and it should work just finer this one is as follows.
So, to make this work, we can run the command:
Code:
echo ">=sys-kernel/installkernel-50 dracut" >> /etc/portage/package.use/installkernel
Once you issue the command, you can reissue the command that failed, and it should work now.
NOTE: Depending on your hardware, the failure may or may not happen. It could also occur in a different area. You can issue a command to
list all available kernels:
Code:
eselect kernel list
There should be only one kernel listed and it should be the default. If you use the command 'ls /boot' it should list files now that the kernel is present.
Step 7 - Configuring the System
In this section, we will set up the 'fstab' file, install DHCP, set the system's hostname and set the Root password. We can set the 'fstab' manually, but this can cause issues if anything is wrong. So we will install a program called 'genfstab' to generate the file for us.
Code:
emerge genfstab
If you run the command 'genfsta /' you can see the output that looks like just what we need for 'fstab'. To make this work, use:
Code:
genfstab / >> /etc/fstab
Now, when we edit '/etc/fstab' you will see something similar to Figure 6.
FIGURE 6
In the 'fstab' file, you need to uncomment the UUID lines and remove the portion of the following line that starts with the device name '/dev/sdxx'. Make it all on one line per UUID, as shown in Figure 7.
FIGURE 7
The Hostname is now ready to set. Determine what the Hostname will be and I will use a generic name like 'tester' which you can replace in the following lines of code.
Code:
echo tester > /etc/hostname
Edit the file 'etc/hosts' and add the hostname after the loopback address, before 'localhost', as shown:
Code:
127.0.0.1tester localhost
Save and close the file. It is time to install DHCP with the following commands:
[code]emerge dhcpcd rc-update add dhcpcd default rc-service dhcpcd start
The lines install DHCP, adds the service to start automatically and finally to start it now. We need to get the Ethernet service started. Initially, you need to find the name of the port with the command 'ifconfig'. My system shows the name 'enp1s0'. If yours differs, use the name listed on your system. To set it up, use the following commands to create a link:
Code:
cd /etc/init.d ln -s net.lo net.enp1s0 rc-update add net.enp1s0 default
We do not need to start it yet since this is the OS we are building and it is not active yet. We are still running from the Gentoo system we booted from and are running in RAM. We have set the password for Root on the system in RAM, but to set the password for the system we are building, run 'passwd' and set the password and verify it. If you use a keyboard other than a 'qwerty' style, you can edit the file 'etc/conf.d/keymaps' to change the type you use. We should also set up a user here for after we reboot.
Code:
useradd -m -G users, wheel -s /bin/bash user1 passwd user1
This will create a user named 'user1' with elevated privileges and sets a password. To make sure the user has elevated privileges, you need to edit '/etc/sudoers' and uncomment the line, giving all access to '%wheel', which is done at the end of this setup.
Step 8 - Install System Tools
We will need the command 'sudo' unless we will always log in as root.
Code:
emerge sudo
You can install a system logger and start it with:
Code:
emerge sysklogd rc-update add sysklogd default
We can install file indexing:
Code:
emerge sys-apps/mlocate updatedb
This installs the indexer and updates the index. Shell completion for BASH is definitely a must:
Code:
emerge app-shells/bash-completion
We need support for file systems:
Code:
emerge dosfstools e2fsprogs
This will give us support for FAT32 and EXT. If you have a system with an NVME drive, you need support for it:
Code:
emerge sys-block/io-scheduler-udev-rules
A time synchronization service would help:
Code:
emerge net-misc/chrony rc-update add chronyd default
We can also add tools necessary for wireless networking:
Code:
emerge net-wireless/iw net-wireless/wpa_supplicant wireless-tools
Step 9 - Configure the Bootloader
Now we need to set up GRUB. If you do not do this correctly, then the system will not boot properly. Let's start by setting the platform type:
Code:
echo 'GRUB_PLATFORMS="efi-64"' >> /etc/portage/make.conf emerge grub
If you plan on dual-booting, you need the OS-Prober too:
Code:
emerge sys-boot/os-prober --efi-directory=/boot
To finish the GRUB installation, use the following commands:
Code:
grub-install --target=x86_64-efi --efi-directory=/boot grub-mkconfig -o /boot/grub/grub.cfg
Enter 'exit' once. Here, we should still be in the elevated privilege mode. You can tell by the prompt ending in a pound sign (#). We can now open up the 'wheel' group for elevated privileges by editing the file '/etc/sudoers' and uncommenting the line for '%wheel' near the end.
Once saved, enter the command 'exit' again. The unmount the drives you mounted before using the command:
Code:
sudo umount -R /mnt/gentoo
Reboot the system, but remember to remove the LiveGUI after the system shuts down and before it restarts so the system does not boot from of it again.
Conclusion
This is a long procedure to get Gentoo installed and running. Granted, it is a Command-Line Interface (CLI) only, but it gets the OS running.
Most people may be used to using 'systemd' instead of 'openrc', but this is part of the modularity of Linux.
Last edited:

