6. Installing the Gentoo Base System
Optional: Selecting Mirrors
In order to download source code quickly it is recommended to select a fast mirror. Portage will look in your make.conf file for the GENTOO_MIRRORS variable and use the mirrors listed therein. You can surf to our mirror list and search for a mirror (or mirrors) close to you (as those are most frequently the fastest ones), but we provide a nice tool called mirrorselect which provides you with a nice interface to select the mirrors you want.
Code Listing 1.1: Using mirrorselect for the GENTOO_MIRRORS variable
# mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
A second important setting is the SYNC setting in make.conf. This variable contains the rsync server you want to use when updating your Portage tree (the collection of ebuilds, scripts containing all the information Portage needs to download and install software). Although you can manually enter a SYNC server for yourself, mirrorselect can ease that operation for you:
Code Listing 1.2: Selecting an rsync mirror using mirrorselect
# mirrorselect -i -r -o >> /mnt/gentoo/etc/make.conf
After running mirrorselect it is adviseable to double-check the settings in /mnt/gentoo/etc/make.conf !
Note: If you want to manually set a SYNC server in make.conf, you should check out the community mirrors list for the mirrors closest to you. We recommend choosing a rotation, such as rsync.us.gentoo.org, rather than choosing a single mirror. This helps spread out the load and provides a failsafe in case a specific mirror is offline.
Copy DNS Info
One thing still remains to be done before we enter the new environment and that is copying over the DNS information in /etc/resolv.conf. You need to do this to ensure that networking still works even after entering the new environment. /etc/resolv.conf contains the nameservers for your network.
Code Listing 1.3: Copy over DNS information
(The "-L" option is needed to make sure we don't copy a symbolic link)
# cp -L /etc/resolv.conf /mnt/gentoo/etc/
Mounting the /proc and /dev Filesystems
Mount the /proc filesystem on /mnt/gentoo/proc to allow the installation to use the kernel-provided information within the chrooted environment, and then mount-bind the /dev filesystem.
Code Listing 1.4: Mounting /proc and /dev
# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev
Entering the new Environment
Now that all partitions are initialized and the base environment installed, it is time to enter our new installation environment by chrooting into it. This means that we change from the current installation environment (Installation CD or other installation medium) to your installation system (namely the initialized partitions).
This chrooting is done in three steps. First we will change the root from / (on the installation medium) to /mnt/gentoo (on your partitions) using chroot. Then we will create a new environment using env-update, which essentially creates environment variables. Finally, we load those variables into memory using source.
Code Listing 1.5: Chrooting into the new environment
# chroot /mnt/gentoo /bin/bash
>> Regenerating /etc/ld.so.cache...
# source /etc/profile
# export PS1="(chroot) $PS1"
Congratulations! You are now inside your own Gentoo Linux environment. Of course it is far from finished, which is why the installation still has some sections left :-)