Gentoo Quick Install

The last update to this installation guide was on April 2009, whether it is accurate still I can not say. Gentoo evolves gradually so for the most part it should be alright, best to use in reference with the Gentoo Handbook.

Installing Gentoo really is a breeze… once it has been done before. This guide is for installing Gentoo in a logical straight-forward manner. I have written everything generically, with necessary links for additional resource, look at the Gentoo Handbook from which this guide derives for more complex set-ups.

I choose to install from a LiveCD [1]. I choose not to use Gentoo’s Minimal Install CD because many distro CD’s create a nice desktop to work on and a web browser can be useful to look up any questions.

Partitioning

Just about any Live CD a person has/likes can be used to install Gentoo with. For beginners it helps if it contains Gparted, an easy tool to partition with. If it doesn’t consider using Gparted’s LiveCD [2] to first partition the drive.

For security purposes and for convenience, I’d recommend having a partition for the system (root “/“) and another for “/home” (aka the users partition).

Linux uses a considerable less amount of memory than Windows or Mac OS X. Users with memory of 2GB or more probably don’t need a swap partition. If you choose not to have a swap partition and need to use swap, a swap file can be created later [3].

Date

When done partitioning, restart and open the BIOS. Make sure the hardware clock is set to the right time, start the install disk and check the time in the terminal:

date

Possibly the installCD is using the UTC clock (Universal Time Clock – aka Greenwich Mean Time) for time and date and the clock will be skewed. This is not a problem. The correct settings will be entered on the new installation.

Remote Install (Optional)

Some people may want to use another computer to install Gentoo from. This can be handy if say the remote machine has a bigger screen or has notes on it you’d like to access.

Begin by starting sshd on the computer to be installed upon:

/etc/init.d/sshd start

How to start a daemon differs though per distribution. Give root a password on the machine to be installed on for security purposes:

passwd

Type “ifconfig” to find the internet address, then on the remote computer:

ssh -l root@address

Preparing the Storage Unit

Mount the system partition created for the system install:

mount /dev/devicename /mnt/gentoo && cd /mnt/gentoo

You can find out the partition you need to use with:

fdisk -l

(e.g. /dev/hda3, or /dev/sda4) are examples of what your partition may be named.

A stage3 tarball will be needed now. Stage3 tarballs are tools and a base system that contains just enough necessary to boot your system. Gentoo builds regular stage3 tarballs. You should find the newest on the mirror (contained in /releases/<architecture>/autobuilds and download it.

On the LiveCD the internet networking needs to be working. Learn how to do this (it probably already is) and copy DNS info over to the system that is being built so the network will work on it:

Basic Settings – Add Timezone, Locales, Keymap

Set Time Type

vim /etc/conf.d/hwclock # or
vim /etc/conf.d/clock

Set time type to “local” if dual-booting Windows or Mac OS =<9. Later we’ll add an NTP program the syncs the time on boot, so it might be a good idea to edit “clock_systohc” to “YES” to keep the hardware clock in sync with Network Time Protocol.

Don’t bother to look at “date” as the chroot still uses the CD settings. The effect won’t be seen until you boot into your Gentoo system.

Enter your locale. Here’s and example of the United States local setting:

en_US ISO-8859-1
en_US.UTF-8 UTF-8

To generate locale, run “locale-gen” and “locale” to check if the correct locale is set.

Update environment:

env-update && source /etc/profile

Keyboard Layout for Console

vim /etc/conf.d/keymaps

Available keymaps are in /usr/share/keymaps.

Make Files

The make files are basic settings for the system being built. There is the “make.default” file that is the system profile for building a system. And there is the “make.conf” file – a user-controlled profile that contains hardware information, properties wanted in packages (USE flags), and adds to or overrides the “make.default” file.

A system profile link to “make.default” is set by default, make sure it is the correct one for the system:

“Make.conf” sits on top of the system profile choosen, adding and over-riding those settings. The most important item to a successful Gentoo build is providing as complete a “make.conf” as possible.

vim /etc/make.conf

CHOST defines the basic architecture of the computer – 486,586,PPC… This is important to get right. It is alot of work and dangerous to try and fix this later in the build, research and be sure that it is right one.

USE flags define options programs have that can be enabled or disabled. Try “emerge -pv gcc” to see available flags.

It is nice to install Gentoo and have a reference to USE flags. You can install “gentoolkit” and use equery to find out about USE flags per packages:

equery uses gcc

The ACCEPT_KEYWORDS variable defines what software branch to use on the system. In Gentoo, there is a stable branch for already tested software and an experimental branch. If user is willing to test more recent software, consider using the testing branch, but expect more time debugging problems. To have Portage use the testing branch, add a ~ in front of the architecture.

VIDEO_CARDS define video card type. This value will tell xorg-server what video card drivers to pull in, and what DRI to use for the X server. Also a video card DRM is required either by selecting it in the kernel, x11-drm package, or the driver may have support for it: e.g. nvidia, ati, intel video card… A few values are available.

INPUT_DEVICES tells xorg-server what basic devices are or will be connected. Items include keyboard, mouse, touchpad…

GENTOO_MIRRORS are used for syncing the portage tree. You can test and add the three fastest mirrors by:

mirrorselect -s3 -b10 -o -D >> /etc/make.conf

Beginning to Build

There will be a lot of compiling that can take several days to build on older computers. Portage is a well tested and complete compiling system and eases the process, but likely a few bugs will appear. A few tips:

Previous Versions

Occasionally during compiling errors can occur. If choosing to use the unstable branch, the newest updates and less tested programs come with it. If there is a problem compiling along the way, check Dibb’s Package Page and revert back to an older version to compile. Or you can install eix (run eix-sync to update database) and do a quick search with “eix <package>“.

Dependencies

Check the dependencies of a program to see if a dependency is causing the problem:

When emerging finishes developers will often leave notes about the program. It may mean more time and work but it is usually a good idea to follow them.

If you miss a note, developer notes are recorded in:

vim /var/log/portage/elog/summary.log

Installing a Kernel

The kernel contains the information of almost all the hardware on the computer and how to run it.

If this is the first time working with a kernel, I’d recommend using the genkernel – a basic all types kernel that will run on most systems.

Otherwise the configuration can be done manually. Manual configuring the kernel can make for a slightly faster boot but isn’t necessary in most cases. Manual configuration can take a long time though and requires alot of research, begin by:

emerge gentoo-sources
cd /usr/src/linux

Make sure the “/usr/src/linux” link matches the downloaded kernel source[5]:

ls -la /usr/src/linux

Enter the directory and run “make menuconfig” to get to the kernel configuration editor.

A Few Tips for Configuring the Kernel

A good amount of details about the computer can be discovered with “lspci” (part of the “pciutils” package).

“lsusb” can be useful for USB hardware (“lsusb” is part of the “usbutils” package).

It’s a good idea to build sound support into the kernel if you need it.

If unsure about an option, try adding it as a module – these can be specified to load or not load at boot time.

When the kernel config file is finished, compile the kernel, the modules, and install them:

make clean bzImage modules modules_install install

Now the modules that were created need you need to specify which ones you need to boot.

find /lib/modules/ -type f -iname '*.o' -or -iname '*.ko'

Now add the ones needed to /etc/modules.conf. Gentoo hasn’t added OpenRC to it’s stage3 yet but that should happen soon. When that happens you’ll have to add modules to /etc/conf.d/modules. See the OpenRC migration guide for details.

Filesystem Information

The fstab file contains storage devices (drives and partitions), their mount points and any options that will mount at boot time. The “/etc/fstab” file must be edited manually with the storage units you plan to be use.

Unique device nodes (UUID’s) can be used too that can prevent possible device conflicts. Take a look at this.

Setup the “/etc/mtab” file here too. Usually the system discovers what filesystems are mounted and adds them to this file, but since this isn’t a full system yet, it needs to be created for your bootloader later:

grep -v rootfs /proc/mounts > /etc/mtab

Configuring the Network

Naming the pc is important so people on a network can recognize you. This is done with a hostname. A good practice is to name the computer <owner>-<machine> but people can name them anything – after famous philosophers, your favorite Gentoo developers… Open /etc/conf.d/hostname

HOSTNAME=”smith-dell”

Add the hostname boot script to run at startup:

rc-update add hostname default

Hostname will also need to be set in “/etc/hosts” so some programs can become aware of it:

127.0.0.1 smith-dell localhost

Setting a domainname is primarily used if the computer is to be server or if on a specialized network. Most people can ignore this setting.

Networking with DHCP

Most ISP’s (Internet Service Providers) use dhcp (network discovery) that makes setup easy.

Type “ifconfig” to see if your devices have been recognized. There should be a “lo” (loopback) device (necessary for some programs to access the network) a wired interface (eth0 is a common wired interface) and possibly a wireless interface (eth1, ath0…).

Any wired/wireless device will have to be linked to net.lo for the boot init system to recognize it.

ln -s /etc/init.d/net.lo /etc/init.d/net.eth0

Wait until reboot to see if the wired/wireless devices connect to the internet. Networks that require greater configuration can be done in “/etc/conf.d/net“, see the Gentoo Documentation links below.

ACPI (Advanced Configuration and Power Interface) is used by most modern computers for power saving, suspend…

emerge acpid && rc-update add acpid default

NTP client (Network Time Protocol) keeps the computer in sync with an internet time server.

emerge ntp && rc-update add ntp-client default

File System Tools, if using another file system beside ext2/3, you’ll need their tools – xfsprogs, reiserfsprogs, jfsutils.

Check out what boot scripts are to load to be sure you got them all:

rc-update show

Adding Password and User

Root doesn’t have a password yet, so give it one and also create a new user.

passwd

If you need to create a regular user (not root) and you made a home partition (/home) partition, it needs to be mounted now [4]:

mount /dev/devicename /home

Now add a new user. Groups give the user permission to do certain tasks. Add a user to the wheel group to allow the user to ‘su’ to root. Other programs you add later may require you add a group to gain certian permissions (a developer note will usually tell you when you have to do this).

Warning: For the install, root user is being used for installing but besides this process it is not a good idea to log in as root. Login as regular user and use ’su‘ to log into root when you need administrative priveledges.

Configuring the Bootloader

A boot loader is required to load Linux. The boot loader should almost always be installed in the Master Boot Record (the first 512k of the disk – not partition). The MBR defines partitions, partition types, labels, whether it’s bootable… Getting this right is very important. Grub is the preferred bootloader, installing makes it the default system bootloader and will boot both Windows and Linux.

Grub nomenclature is different for devices. The first disk it recognizes is called “hd0“, the first partition it sees is “0” So the Linux root partition located on the first hard drive on the first partition, is labeled “hd0,0“.

First, the Grub configuration file (/boot/grub/grub.conf) needs to be created manually:

Here’s a sample grub configuration file:

# /boot/grub/grub.conf

# Default system to boot, 0 is first,…
default=0
# Timeout to wait before automatic loading of default system
timeout=10

Pretty good! The best part is that you only have to do this once, everything is always fine after that, you just need sysrescuecd and a little patience. Once I helped a friend with 15s of `rm -fr /`, it took “only” 2 hours to be able to boot again, but time is never the factor with Gentoo.

Welcome to linuxtidbits.

linuxtidbits is a place for common bits of Linux knowledge. Linux is a good operating system with good people. Being part of Linux, to me, means being a part of something that everyone can contribute to.