[ << ] [ < ] [ Home ] [ > ] [ >> ]


5. Installing the Gentoo Installation Files

Content:

5.a. Installing a Stage Tarball

Setting the Date/Time Right

Before you continue you need to check your date/time and update it. A misconfigured clock may lead to strange results in the future!

To verify the current date/time, run date:

Code listing 1: Verifying the date/time

# date
Fri Oct 29 16:21:18 CEST 2004

If the date/time displayed is wrong, update it using the date MMDDhhmmYYYY syntax (Month, Day, hour, minute and Year). For instance, to set the date to October 29th, 16:21 in the year 2004:

Code listing 2: Setting the date/time

# date 040116212005

Locating the Stage3 File

If you have configured networking because you need to download a stage3 file for your architecture, continue with Alternative: Using a Stage3 from the Internet. Otherwise read Default: Using a Stage3 from the Installation CD.

5.b. Default: Using a Stage from the Installation CD

Extracting the Stage Tarball

The stages on the CD reside in the /mnt/cdrom/stages directory. To see a listing of available stages, use ls:

Code listing 3: List all available stages

# ls /mnt/cdrom/stages

If the system replies with an error, you may need to mount the CD-ROM first:

Code listing 4: Mounting the CD-ROM

# ls /mnt/cdrom/stages
ls: /mnt/cdrom/stages: No such file or directory
# mount /dev/cdroms/cdrom0 /mnt/cdrom
# ls /mnt/cdrom/stages

Now go into your Gentoo mountpoint (usually /mnt/gentoo):

Code listing 5: Changing directory to /mnt/gentoo

# cd /mnt/gentoo

We will now extract the stage tarball of your choice. We will do this with the GNU tar tool. Make sure you use the same options (-xvjpf)! Again, the v argument is optional. In the next example, we extract the stage tarball stage3-<subarch>-2005.0.tar.bz2. Be sure to substitute the tarball filename with your stage.

Code listing 6: Extracting the stage tarball

# tar -xvjpf /mnt/cdrom/stages/stage3-<subarch>-2005.0.tar.bz2

Now that the stage is installed, continue with Installing Portage.

5.c. Alternative: Using a Stage from the Internet

Downloading the Stage Tarball

Go to the Gentoo mountpoint at which you mounted your filesystems (most likely /mnt/gentoo):

Code listing 7: Going to the Gentoo mountpoint

# cd /mnt/gentoo

Depending on your installation medium, you have a couple of tools available to download a stage. If you have links2 available, then you can immediately surf to the Gentoo mirrorlist and choose a mirror close to you.

If you don't have links2 available you should have lynx at your disposal. If you need to go through a proxy, export the http_proxy and ftp_proxy variables:

Code listing 8: Setting proxy information for lynx

# export http_proxy="http://proxy.server.com:port"
# export ftp_proxy="http://proxy.server.com:port"

We will now assume that you have links2 at your disposal.

Pick the releases/ directory, followed by your architecture (for instance x86/) and the Gentoo version (2005.0/) to finish up with the stages/ directory. There you should see all available stage files for your architecture (they might be stored within subdirectories named to the individual sub architectures). Select one and press D to download. When you're finished, press Q to quit the browser.

Code listing 9: Surfing to the mirror listing with links2

# links2 http://www.gentoo.org/main/en/mirrors.xml

(If you need proxy support with links2:)
# links2 -http-proxy proxy.server.com:8080 http://www.gentoo.org/main/en/mirrors.xml

If you want to check the integrity of the downloaded stage tarball, use md5sum and compare the output with the MD5 checksum provided on the mirror. For instance, to check the validity of the x86 stage tarball:

Code listing 10: Example checking integrity of a stage tarball

# md5sum -c stage3-x86-2005.0.tar.bz2.md5
stage3-x86-2005.0.tar.bz2: OK

Unpacking the Stage Tarball

Now unpack your downloaded stage onto your system. We use GNU's tar to proceed as it is the easiest method:

Code listing 11: Unpacking the stage

# tar -xvjpf stage3-*.tar.bz2

Make sure that you use the same options (-xvjpf). The x stands for Extract, the v for Verbose to see what happens during the extraction process (okay, yes, this is optional), the j for Decompress with bzip2, the p for Preserve permissions and the f to denote that we want to extract a file, not standard input.

Now that the stage is installed, continue with Installing Portage.

5.d. Installing Portage

Unpacking a Portage Snapshot

You now have to install a Portage snapshot, a collection of files that inform Portage what software titles you can install, which profiles are available, etc.

Unpack the Snapshot from the Installation CD

To install the snapshot, take a look inside /mnt/cdrom/snapshots/ to see what snapshot is available:

Code listing 12: Checking the /mnt/cdrom/snapshots content

# ls /mnt/cdrom/snapshots

Now extract the snapshot using the following construct. Again, make sure you use the correct options with tar. Also, the -C is with a capital C, not c. In the next example we use portage-<date>.tar.bz2 as the snapshot filename. Be sure to substitute with the name of the snapshot that is on your Installation CD.

Code listing 13: Extracting a Portage snapshot

# tar -xvjf /mnt/cdrom/snapshots/portage-<date>.tar.bz2 -C /mnt/gentoo/usr

Copy Source Code Archives

You also need to copy over all source code from the Universal Installation CD.

Code listing 14: Copy over source code

# mkdir /mnt/gentoo/usr/portage/distfiles
# cp /mnt/cdrom/distfiles/* /mnt/gentoo/usr/portage/distfiles/

5.e. Configuring the Compile Options

Introduction

To optimize Gentoo, you can set a couple of variables which impact Portage behaviour. All those variables can be set as environment variables (using export) but that isn't permanent. To keep your settings, Portage provides you with /etc/make.conf, a configuration file for Portage. It is this file we will edit now.

Note: A commented listing of all possible variables can be found in /mnt/gentoo/etc/make.conf.example. For a successful Gentoo installation you'll only need to set the variables which are mentioned beneath.

Fire up your favorite editor (in this guide we use nano) so we can alter the optimization variables we will discuss hereafter.

Code listing 15: Opening /etc/make.conf

# nano -w /mnt/gentoo/etc/make.conf

As you probably noticed, the make.conf.example file is structured in a generic way: commented lines start with "#", other lines define variables using the VARIABLE="content" syntax. The make.conf file uses the same syntax. Several of those variables are discussed next.

Warning: Do not make any modifications to the USE variable if you are performing a stage3 with GRP installation. You can alter the USE variable after having installed the packages you want. Gremlins are known to attack your system if you ignore this warning!

CHOST

Warning: Although it might be tempting for non-stage1 users, they should not change the CHOST setting in make.conf. Doing so might render their system unusable. Again: only change this variable if you use a stage1 installation.

The networkless installation approach only supports stage3 installations. Do not touch the CHOST variable!

CFLAGS and CXXFLAGS

The CFLAGS and CXXFLAGS variables define the optimization flags for the gcc C and C++ compiler respectively. Although we define those generally here, you will only have maximum performance if you optimize these flags for each program separately. The reason for this is because every program is different.

In make.conf you should define the optimization flags you think will make your system the most responsive generally. Don't place experimental settings in this variable; too much optimization can make programs behave bad (crash, or even worse, malfunction).

We will not explain all possible optimization options. If you want to know them all, read the GNU Online Manual(s) or the gcc info page (info gcc -- only works on a working Linux system). The make.conf.example file itself also contains lots of examples and information; don't forget to read it too.

A first setting is the -march= flag, which specifies the name of the target architecture. Possible options are described in the make.conf.example file (as comments). For instance, for the x86 Athlon XP architecture:

Code listing 16: The GCC march setting

# AMD64 users who want to use a native 64 bit system should use -march=k8
-march=athlon-xp

A second one is the -O flag (that is a capital O, not a zero), which specifies the gcc optimization class flag. Possible classes are s (for size-optimized), 0 (zero - for no optimizations), 1, 2 or 3 for more speed-optimization flags (every class has the same flags as the one before, plus some extras). For instance, for a class-2 optimization:

Code listing 17: The GCC O setting

-O2

Another popular optimization flag is -pipe (use pipes rather than temporary files for communication between the various stages of compilation).

Mind you that using -fomit-frame-pointer (which doesn't keep the frame pointer in a register for functions that don't need one) might have serious repercussions on the debugging of applications!

When you define the CFLAGS and CXXFLAGS, you should combine several optimization flags, like in the following example:

Code listing 18: Defining the CFLAGS and CXXFLAGS variable

CFLAGS="-march=athlon-xp -pipe -O2"   # AMD64 users should not use athlon-xp
CXXFLAGS="${CFLAGS}"                  # Use the same settings for both variables

MAKEOPTS

With MAKEOPTS you define how many parallel compilations should occur when you install a package. A good choice is the number of CPUs in your system plus one, but this guideline isn't always perfect.

Code listing 19: MAKEOPTS for a regular, 1-CPU system

MAKEOPTS="-j2"

Ready, Set, Go!

Update your /mnt/gentoo/etc/make.conf to your own preference and save (nano users would hit Ctrl-X). You are now ready to continue with Chrooting into the Gentoo Base System.


[ << ] [ < ] [ Home ] [ > ] [ >> ]