Table of Contents
I've waited a few chapters before I started discussing the Gentoo Linux installation because it isn't for the faint of hearted. Although Gentoo has tried to offer a graphical installer in the past, its user- and developer base swore by the manual installation approach. As a result, the graphical installer has been deprecated and the installation procedure is once more a manual, step by step guide.
With the previous chapters discussed, you should now be able to install a Gentoo Linux yourself with the following simple set of instructions. However, if you want to do it the official way, do not hesitate to read the Gentoo Handbook. There are also handbooks available for other architectures.
A Gentoo Linux installation starts from a Linux environment. You can use any Linux environment you want, but most people suggest to use a LiveCD.
A popular LiveCD to install Gentoo from is System Rescue CD. All necessary documentation about booting the CD, including setting up networking (which you definitely need to do in order to install Gentoo) is available on the site.
Once your environment is set up, you'll need to setup your disks by partitioning them and then putting a file system on them. Partitioning and file system management has been discussed beforehand:
# fdisk /dev/sda (Partition the disk) # mkfs.ext2 /dev/sda1 # mkfs.ext3 /dev/sda2 # mkfs.ext3 /dev/sda3
Once that your partitions are created and a file system is put on it, it is time to really start the Gentoo Linux installation.
First, mount all the necessary partitions onto your Linux environment. In the rest of this chapter I will assume the partitioning layout as described in here.
Table 16.1. Example partition layout
| Device | Partition | Description |
| /dev/sda1 | /boot | Small boot partition to hold the Linux kernel and bootloader information. Can be ext2 |
| /dev/sda2 | / | Root partition; should be fairly large in this example. Suggested is ext3 |
| /dev/sda3 | /home | Home partition where all users' files are stored. Best to always have a separate partition for the home directories so that future reinstallations can reuse the home structure. |
| /dev/sda4 | <none> | Swap partition, roughly 1.5 times the amount of physical memory nowadays (still this large because I want to use hibernate-to-disk). |
~# mkdir /mnt/gentoo ~# mount /dev/sda2 /mnt/gentoo ~# mkdir /mnt/gentoo/boot ~# mount /dev/sda1 /mnt/gentoo/boot ~# mkdir /mnt/gentoo/home ~# mount /dev/sda3 /mnt/gentoo/home ~# swapon /dev/sda4
With the above commands executed, the various file systems we will
use for the Gentoo installation are now available at
/mnt/gentoo. Every file or directory we put beneath
/mnt/gentoo will show up on our final Gentoo
installation. For instance, /mnt/gentoo/boot =
/boot.
First, set your system time correct so that the files you're going to create do not have a weird timestamp:
~# ntpdate pool.ntp.orgNext, surf to the Gentoo mirror list and pick a mirror close to you. On most LiveCDs browsers are available. On the sysresccd you can use links or lynx (command-line browsers). Navigate to releases, select your architecture, autobuilds, the latest date directory to find a listing of stage3 files and install files.
~# cd /mnt/gentoo ~# links http://www.gentoo.org/main/en/mirrors2.xml
A stage3 file is an archive of a prebuilt Gentoo environment
which we will extract to the installation location
(/mnt/gentoo)
An install file is an ISO file (CD image) which contains a minimal Gentoo environment from which you can boot and install Gentoo from.
Download the stage3 file and store it in
/mnt/gentoo. If you have the full URL at hand, you
can also use wget:
# cd /mnt/gentoo # wget http://gentoo.osuosl.org/releases/x86/autobuilds/20091201/stage3-i686-20091201.tar.bz2
On many forums, you will find the notion of "funtoo" stages. Funtoo is, to say it in the author's own words (who happens to be Daniel Robbins, the founder of Gentoo Linux), a Gentoo Linux variant which offers freshly-built Gentoo Linux stable stages using Gentoo's official stable branch. You can use a funtoo stage instead of a Gentoo official stage if you want. After all, they both contain roughly the same material. Both (official and funtoo) stages are fine as they are both quite recent.
Next, go back a few directories until you can select snapshots.
Enter this directory and download the latest
portage-<date>.tar.bz2 you can find. Store it
in /mnt/gentoo as well. Finally, quit your browser
and extract the downloaded files on your installation location.
~# tar xvjpf stage3-*.tar.bz2 ~# tar xvjf portage-*.tar.bz2 -C /mnt/gentoo/usr
Again, you can use wget if you want:
# wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2The portage- file is a snapshot of Gentoo's
Portage tree.
Next, edit the /mnt/gentoo/etc/make.conf file.
As discussed previously, this file contains variables that define Portage'
behavior. Right now I'm focussing on the variables CFLAGS, CXXFLAGS and
MAKEOPTS...
CFLAGS (C) and CXXFLAGS
(C++) inform gcc (GNU's Compiler Collection) what optimizations it
should use (see Compiler
Directives)
MAKEOPTS defines how many parallel compilations should occur
when you install a package (especially useful for multicore / SMP
systems). A good choice is the number of core's in your system plus
one (for instance, a dual-core CPU would lead to
MAKEOPTS="-j3").
You can edit the make.conf file using
nano, vim or any other text
editor.
Our next step is to configure the installation environment.
First, prepare the environment for chrooting.
Chrooting is the process of altering your sessions' file system
root to another location. In our case, /mnt/gentoo
should become / for your running session. In order
to chroot succesfully, we need to ensure that networking will still
function properly and that both kernel data and device drivers are
available inside the chroot:
~# cp -L /etc/resolv.conf /mnt/gentoo/resolv.conf ~# mount -t proc none /mnt/gentoo/proc ~# mount -o bind /dev /mnt/gentoo/dev
Now, chroot into the Gentoo installation environment, update your environment variables and, for safety reasons, change your prompt so that you know you're inside your Gentoo installation environment.
~# chroot /mnt/gentoo /bin/bash ~# env-update ~# source /etc/profile ~# export PS1="(chroot) $PS1"
Right now, this session (where the prompt starts with "(chroot)") is inside your Gentoo installation environment.
Now, update the Portage tree to make sure you have the current set of packages at your disposal:
~# emerge --syncNext, select a Gentoo profile for your environment. A
Gentoo profile is a collection of default Portage settings. If you want
to know what a particular profile selects of default settings, check out
its content at /usr/portage/profiles (and don't
forget to read up on cascading profiles). Currently, the 2008.0 set of
profiles is the stable, default one. The 10.0 set of profiles is still
being developed for the upcoming Gentoo 10 release.
~# eselect profile list ~# eselect profile set <number>
Finally, set the USE flags you want in either
/etc/make.conf (global USE flags) or
/etc/portage/package.use (local USE flags).
~# nano -w /etc/make.confFor those of you who want to run Gentoo Linux with support for
international locales, edit /etc/locale.gen and
specify the locales you want to support. An example of locales are given
below. Once set, generate the locale files for your system.
~# nano -w /etc/locale.gen en_US ISO-8859-1 en_US.UTF-8 UTF-8 de_DE ISO-8859-1 de_DE@euro ISO-8859-15 ~# locale-gen
If you want to know which locales are supported, view the contents of the /usr/share/i18n/SUPPORTED file:
# less /usr/share/i18n/SUPPORTEDFirst select your time zone file from inside /usr/share/zoneinfo and copy it to /etc/localtime. For instance, to use the GMT time zone:
~# cp /usr/share/zoneinfo/GMT /etc/localtimeNext, install the kernel sources. Gentoo profiles a few kernel packages like vanilla-sources (bare Linux kernel as delivered by the kernel developers) and gentoo-sources (vanilla Linux kernel with patches managed by Gentoo developers).
~# emerge gentoo-sourcesYou will find the kernel sources at
/usr/src/linux. Now continue with building the
Linux kernel as discussed in Configuring a Kernel.
There are three blocks of information we need to configure now:
file system information
(/etc/fstab)
networking information
system information
To start with the file system information, you need to edit the
/etc/fstab file. The structure of this file has
been discussed before so this shouldn't be an issue (see The mount command).
/dev/sda1 /boot ext2 noauto,noatime 0 0 /dev/sda2 / ext3 defaults,noatime 0 0 /dev/sda3 /home ext3 defaults,noatime 0 0 /dev/sda4 none swap sw 0 0 none /dev/shm tmpfs defaults 0 0
Next, configure your network settings. Start by setting the system
hostname in /etc/conf.d/hostname and then configure
the networking settings in /etc/conf.d/net.
Finally, add your network interface initialization script to the default
run level so that networking is automatically started at boot
time.
~# nano -w /etc/conf.d/hostname ~# nano -w /etc/conf.d/net ~# rc-update add net.eth0 default
Also edit your /etc/hosts file to include the
IP addresses and host names of other systems you might need. Also add
your hostname to the 127.0.0.1 entry in
/etc/hosts.
~# nano -w /etc/hostsNow, set your root password
~# passwdNext, edit /etc/rc.conf which contains your
general system configuration settings:
~# nano -w /etc/rc.confNext, edit /etc/conf.d/keymaps to set your
system-wide keyboard layout settings:
~# nano -w /etc/conf.d/keymapsFinally, edit /etc/conf.d/clock to set the
clock options:
~# nano -w /etc/conf.d/clockInstall a system logger, like syslog-ng:
~# emerge syslog-ng ~# rc-update add syslog-ng default
Install a system scheduler (cron daemon), like vixie-cron:
~# emerge vixie-cron ~# rc-update add vixie-cron default
Install the file system tools for the file systems you use:
~# emerge xfsprogs ~# emerge reiserfsprogs ~# emerge jfsutils
Install the necessary networking tools, like a DHCP client:
~# emerge dhcpcdNow, we install the GRUB boot loader:
~# emerge grubOnce installed, edit the grub configuration file
(/boot/grub/grub.conf) as we've seen before. Finally,
install GRUB on the master boot record:
~# grep -v rootfs /proc/mounts > /etc/mtab ~# grub-install --no-floppy /dev/sda
Now that everything is installed, reboot your system by exiting the chroot, umounting all mounted file systems and reboot:
~# exit ~# cd ~# umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc ~# umount /mnt/gentoo/home /mnt/gentoo ~# reboot
Once rebooted (and hopefully inside your Gentoo Linux environment), log in as root and create a user for daily use:
~# useradd -m -G users,wheel,audio -s /bin/bash yournick ~# passwd yournick
And to remove the traces from the installation, remove the downloaded tarballs from your / file system:
~# rm /stage3-*.tar.bz2 ~# rm /portage-*.tar.bz2