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.

Requirements
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 CXXFLAGS="${CFLAGS}"

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


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/

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"

18. Now download the latest Portage snapshot using emerge-webrsync command.
# mkdir /usr/portage # emerge-webrsync


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

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

# nano /etc/locale.gen
Uncomment your system locales.
locale-gen env-update && source /etc/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


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

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



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

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

# emerge sudo

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

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


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

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.

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

# rm /stage3-*.tar.bz2 # emerge --sync

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.
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.
Correction, I’ve fixed it. Instead of “chrooting straight away, cd back to the /root directory, then run the Source and Export commands.
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!
This step didn’t work for me:
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):
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.
Source: https://wiki.gentoo.org/wiki/Mirrorselect#Usage
I am looking forward to read part 3.
The best gentoo install tutorial 10x
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.?
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!
Pls post the part 3 of the tutorial
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: http://unix.stackexchange.com/questions/27594/why-do-we-need-to-use-visudo-instead-of-directly-modifying-the-sudoers-file
darryl, maybe you have used wifi connection? :)
Seems like author assumed you’re using wired connectivity.
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.