Gentoo Linux Installation Guide with Screenshots – Part 2

As a previously mentioned in my last tutorial about Gentoo Linux Installation is a long and difficult process which requires extra time but in the end your system will look and perform exactly in what manner you want it, so will continue directly from where we left off last time.

Gentoo Linux Installation

Gentoo Linux Installation


  1. Installing Gentoo Linux – Part 1

Step 4: Configure Gentoo Installation

13. Make.conf file holds some important variables needed for Portage to optimize your packages configurations for compiling process. Open this file for editing and make sure the following variables are present (you should stick with default values which are good enough for your system).

# nano /mnt/gentoo/etc/portage/make.conf
CFLAGS="-O2  -pipe"
# Use the same settings for both variables
Configure make.conf File

Configure make.conf File

For more optimizations please visit Gentoo Optimization Guide.

14. Next use mirrorselect to select your nearest faster mirrors for downloading source code packages. Portage will use this mirrors by inspecting make.conf file.

# mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf
Select Nearest MIrrors

Select Nearest MIrrors

Download Source Packages

Download Source Packages

15. After you run mirrorselect verify make.conf settings again and check your mirror list, then copy DNS /etc/resolv.conf file to your installation environment path.

# nano /mnt/gentoo/etc/portage/make.conf
# cp -L /etc/resolv.conf /mnt/gentoo/etc/
Verify make.conf Settings

Verify make.conf Settings

Step 5: Installing Gentoo

16. When you first run Gentoo Live DVD, the Linux Kernel gathers important system information about all your hardware devices and loads the appropriate kernel modules to support this hardware, information that is placed in /proc, /sys and /dev directories, so mount those filesystems to /mnt/gentoo installation system path.

# mount -t proc /proc /mnt/gentoo/proc
# mount --rbind /sys /mnt/gentoo/sys
# mount --rbind /dev /mnt/gentoo/dev

17. The next step is to abort DVD live environment and enter our newly system installation path by using chroot, load previous system settings provided by /etc/profile file and change $PS1 Command Prompt.

# chroot /mnt/gentoo /bin/bash
# source /etc/profile
# export PS1="(chroot) $PS1"
Enter New Installation Path

Enter New Installation Path

18. Now download the latest Portage snapshot using emerge-webrsync command.

# mkdir /usr/portage
# emerge-webrsync
Download Latest Portage Snapshot

Download Latest Portage Snapshot

Download Complete

Download Complete

19. After Portage finishes synchronization select a profile for your future system destination. Depending on chosen profile the default values for USE and CFLAGS will change to appropriately reflect your system final environment (Gnome, KDE, server etc.).

# eselect profile list
# eselect profile set 6   ## For KDE
Select Profile

Select Profile

20. Next configure your system Time Zone and Locales by uncomment your preferred language from /etc/locale.gen file using the following series of commands.

# ls /usr/share/zoneinfo
# cp /usr/share/zoneinfo/Continent/City /etc/localtime
# echo " Continent/City " > /etc/timezone
Set System Time Zone

Set System Time Zone

# nano  /etc/locale.gen

Uncomment your system locales.

env-update && source /etc/profile
Open Locals.gen File

Open Locals.gen File

Set System Locals

Set System Locals

Update Profile

Update Profile

Step 6: Installing Linux Kernel

21. Gentoo provides two ways of building and installing Linux Kernel: using a manual kernel configuration or use an automated process by issuing genkernel command which builds a generic kernel based on the one used by installation Live DVD.

On this tutorial the second method will be used because the first method requires advanced knowledge of your system components and building a kernel with manual configurations.

First download kernel sources using emerge and verify kernel release by listing the content of /usr/src/linux directory.

# emerge gentoo-sources
# ls -l /usr/src/linux

22. Now compile your kernel using genkernel command, which automatically builds the kernel with the default hardware settings detected by DVD installer at boot time. Be aware that this process can take a lot of time depending on your hardware resources.

# emerge genkernel
# genkernel all
Compile Kernel

Compile Kernel

Compiling Kernel

Compiling Kernel

If you want to manually modify kernel configuration you can use genkernel –menuconfig all command. When the process finishes you can check the kernel and Ramdisk file by listing /boot directory content.

Step 7: Other System Configurations

23. Next step is to configure fstab file to automatically mount system partitions during boot process. Open /etc/fstab file and add the following content.

# nano /etc/fstab

At the botton of the file insert the following lines.

/dev/sda2	/boot	ext2    defaults,noatime     0 2
/dev/sda4       /       ext4    noatime              0 1
/dev/sda3       none	swap    sw                   0 0
Mount System Partitions

Mount System Partitions

24. Set a hostname for your system by editing /etc/conf.d/hostname file and /etc/hosts file similar to screenshots below and verify it using hostname command.

# hostname
Set System Hostname

Set System Hostname

Add Hostname in Hosts File

Add Hostname in Hosts File

Verify System Hostname

Verify System Hostname

25. To configure you network settings permanently with DHCP install dhcpcd Client and add it to system start up process.

# emerge dhcpcd
# rc-update add dhcpcd default
Configure Network Settings

Configure Network Settings

26. On this stage you can also install SSH daemon, a System Logger and other useful tools.

# emerge virtual/ssh
# emerge syslog-ng
# emerge cronie
# emerge mlocate
# rc-update add sshd default
# rc-update add syslog-ng default
# rc-update add cronie default

27. If you want to customize system services, keyboard and hwclock settings, open and edit the following files according to your needs.

# nano -w /etc/rc.conf
# nano -w /etc/conf.d/keymaps
# nano -w /etc/conf.d/hwclock

28. Next provide a strong password for root account and add a new system user with root privileges.

# passwd
# useradd -m -G users,wheel,audio,lp,cdrom,portage,cron -s /bin/bash caezsar
# passwd caezsar
Set Strong root Password

Set Strong root Password

# emerge sudo
Add New User in Gentoo

Add New User

Edit /etc/sudoers file and uncomment the %wheel group like in the screenshot below.

Uncomment Wheel Group

Uncomment Wheel Group

Step 8: Install System Boot Loader

29. To make Gentoo start after reboot install GRUB2 Boot Loader on your first hard disk and generate its configuration file by running the following commands.

# emerge sys-boot/grub
# grub2-install /dev/sda
# grub2-mkconfig -o /boot/grub/grub.cfg
Install GRUB2 Boot Loader

Install GRUB2 Boot Loader

Generate Grub Configuration

Generate Grub Configuration

If you want to verify Boot Loader configuration file open /boot/grub/grub.cfg file and check menuentry contents.

Verify Boot Loader

Verify Boot Loader

30. After installing the last piece of software needed to boot the system, leave installation chrooted environment, unmount all mounted partitions, reboot your system and eject your DVD media installer.

# exit
# cd
# umount -l /mnt/gentoo/dev{/shm,/pts,}
# umount -l /mnt/gentoo{/boot,/proc,}
# reboot

31. After reboot the GRUB menu should appear on your system screen demanding to choose one of its two Gentoo Kernel booting options.

Select Gentoo from Grub Menu

Select Gentoo from Grub Menu

32. After the system loads login to Gentoo environment using root account, remove stage3-*.tar.bz2 tarball and perform a Portage tree update.

Login to Gentoo

Login to Gentoo

# rm /stage3-*.tar.bz2
# emerge --sync
Remove Stage 3 File

Remove Stage 3 File

Congratulations! Now you have installed a minimal Gentoo Linux environment on you system but system configuration is far for finishing. On the next series of tutorials I will show you how you can install Xorg server, Graphics Adapters drivers, a Desktop Environment and other features and how you can transform Gentoo into a powerful Desktop or Server Platform based on this minimal system installation.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Matei Cezar

I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

12 Responses

  1. Samuel Prouse says:

    For me, “chroot”ing /bin/bash doesn’t work.
    “chroot: failed to run command ‘/bin/bash’: Exec format error”
    There’s nothing so far on the forums to fix this.

    • Samuel Prouse says:

      Correction, I’ve fixed it. Instead of “chrooting straight away, cd back to the /root directory, then run the Source and Export commands.

  2. Manea Florin says:

    Matthew Salve,

    Congratulations for tutorial.

    It went well until grub2 install, where grub2 says not found. Just go with simple grub, no crashes, but the reboot will not boot.

    I need help because I strive for two weeks with the installation.
    Thank you!

  3. elie says:

    This step didn’t work for me:

    mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf

    From what I read, this command output is meant for a repos.conf file under /etc/portage/repos.conf/.

    What did work was the same command but without the “-r” (this also added HTTP and FTP mirror options, not just rsync):

    mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf

    If you look at the make.conf file after running mirrorselect with “-r”, you can see that it doesn’t add a valid bash variable, which is what causes the “emerge-webrsync” to fail.


  4. MrAli says:

    I am looking forward to read part 3.

  5. Atanas says:

    The best gentoo install tutorial 10x

  6. indra says:

    i get kernel panic, on boot. i try to remove kernel and initfram /boot and recompile with “genkernel all” but still kernel panic with latest version of virtualbox v.5 and liveDvd gentoo 11.2. do you have solution for kernel panic problem.?

    • Matei Cezar says:

      Try to recompile a different kernel version an pay attention to compile with the appropriate modules! Still, maybe there’s a bug with virtualbox, but that i can’t know for sure!

  7. Vinicios Wentz says:

    Pls post the part 3 of the tutorial

  8. Jeremy says:

    For your own sake, never edit /etc/sudoers directly. If you make a syntax error, and you don’t know root’s password, you may get locked out from using sudo.
    I’m referencing this:

  9. walsk says:

    darryl, maybe you have used wifi connection? :)
    Seems like author assumed you’re using wired connectivity.

  10. darryl says:

    Thanks so much for this webpage, it saved me a lot of time by not having to read through the handbook or watch videos.

    Everything went flawless, except ’emerge –sync’ failed to connect.

Leave a Reply to MrAli Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.