Install Gentoo from Minimum Installation CD (2009)

We are going to install Gentoo on a very old PC, with an old graphic card, and only 384MB RAM. We want to run X on it. So we decided to use Xfce as the desktop of choice.

Preparation

Download the minimum installation CD from the Gentoo download site. Don't be afraid of the command line stuff. It's not that bad if you follow closely the Gentoo guide.

When you install Gentoo, it always helps to have another computer in front of you for you to reference the Gentoo handbook. After you have boot up the CD and set up the network in the new computer, you can ssh into the new computer from your working PC. Then you will be able to cut and paste the commands from the Gentoo handbook into the shell running in the new computer.

Boot the installation CD

Read the hardware options for kernel before you start. Once you are clear what kernel option you will need, insert the installation CD into the new computer and boot it up. At the boot prompt, enter "gentoo", which is the default kernel, or "gentoo <options>" with whatever needed.

Configure network

If /sbin/ifconfig doesn't show a ready network, follow the steps in Configuring your Network. Basically, fire off the command "net-setup", and go through the wizard. After you finish "net-setup", check /sbin/ifconfig again. Then run "ping www.gentoo.org" to make sure you network is working.

Prepare ssh login

After you have booted the installation CD and set up the network, you will be able to continue the installation from another computer. In order to do that, just start the SSH daemon using "/etc/init.d/sshd start". Then set the root password using "passwd" command. Use "/sbin/ifconfig" to get the IP of this computer.

Now that you have the IP and the root password, you can use your working computer to ssh into this box, and continue with the installation.

Prepare and mount the disks

Follow Preparing the Disks to create disk partitions and format the partitions into you desired filesystem.

Normally, we put /boot into a partition of itself, and keeping it as the first available partition on the boot disk. 50 to 100MB is all you need for your /boot partition. This is a small partitioner, so you don't really need the journaling feature of a filesystem, which takes up extra space. Thus we often use ext2.

If you have multiple disks, please consider spreading your swap onto different disks for improved performance. The swap partition should be the next available partition in a disk, - either right after /boot, or be the first one. When you create /etc/fstab, give your swap on the secondary disk (not the boot disk) a higher priority than your swap on the boot disk. This will give your swap on the secondary disk a higher priority, another little thing that might give you a little better performance.

To mount the disks, do something like:

# mount /dev/sda3 /mnt/gentoo
# mkdir /mnt/gentoo/boot
# mount /dev/sda1 /mnt/gentoo/boot

Install Gentoo installation files

UTC date

Before you install anything, set the UTC date to the correct time. From you working computer, run "date -u" to see the current UTC time. Then go to your computer to be installed, run "date MMDDHHMM" to set the date.

Stage file

Open the Gentoo mirrorlist, find a mirror site close to you, and browse to its releases/x86/current. I found some mirror sites don't have "current". Then copy the URL for the most current stage-i686-*.tar.bz2. Go to you ssh window that login into the installing computer, and do

# cd /mnt/gentoo
# wget <url-in-clipboard>

If you were not using ssh to install, you will have to do "links" as suggested by Installing the Gentoo Installation Files, which is slower to operate.

After you have downloaded the stage file, untar it:

# tar xvjpf stage3-*.tar.bz2

Portage

From the mirror site of your choice, browse to its snapshots/current directory, and find the latest portage snapshot. Copy that URL. Then do

# cd /mnt/gentoo
# wget <url-in-clipboard>

After you have downloaded the portage snapshot file, untar it:

# tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr

Prepare make.conf

Compile options

Follow Configuring the Compile Options to set CFLAGS, CXXFLAGS, and MAKEOPTS options in make.conf file, which is in /mnt/gentoo/etc/make.conf at the moment.

Mirror sites

Use the commands below to set the GENTOO_MIRRORS and SYNC in make.conf:

# mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
# mirrorselect -i -r -o >> /mnt/gentoo/etc/make.conf

Prepare chroot

Copy DNS Info

(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 -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev

Note: when we later unmount the disk before reboot, we have to unmount these two before we can unmount /mnt/gentoo.

chroot into the new envionment

# chroot /mnt/gentoo /bin/bash
# env-update
>> Regenerating /etc/ld.so.cache...
# source /etc/profile
# export PS1="(chroot) $PS1"

Configuring Portage

Update portage

# emerge --sync

If you are warned about a new portage, then run

# emerge --oneshot portage

Then review the profile:

# ls -FGg /etc/make.profile

To change profile, do

# ln -snf /usr/portage/profiles/<profile name> /etc/make.profile

Configuring the USE variable

At this time, you shall know whether you need to run X, and if you do, what desktop you will use.

If you do not plan to run X at all, then add "-X -gnome -kde -gtk -qt3 -qt4" to the USE flag.

If you plan to run some application in X through SSH X11-forwarding, then you can add "X" to the selected application in /etc/portage/package.use.

Then check Gentoo Documentation Resources for USE flags for the desktop of your choice. All Gentoo USE flags are listed in this page: http://www.gentoo.org/dyn/use-index.xml

If you don't develop on python programming language, you may add "-python" to the USE flag. Many packages have python support enabled by default. Turn it off if you don't need it. This will make it easier when you upgrade python, which may not be the smoothest thing.

If you don't need ipv6 support, turn it off.

Since we are going to use Xfce as the desktop, we are going to start with the following USE flags:

USE="-ipv6 -python -gnome -kde -qt3 -qt4 X dbus hal startup-notification xscreensaver alsa midi jpeg nls unicode cjk"

Configuring the Kernel

timezone

# ls /usr/share/zoneinfo
(Suppose you want to use GMT)
# cp /usr/share/zoneinfo/GMT /etc/localtime

Installing the Sources

# emerge gentoo-sources

Manually Configuring the kernel

# cd /usr/src/linux
# make menuconfig

There are a LOT of options in the configuration menu. Here are some references to help you select:

To find out your processor type, you can reference:

Compiling and Installing the kernel

Compile:

# make && make modules_install

Install:

# cp arch/i386/boot/bzImage /boot/kernel-2.6.24-gentoo-r5

If you have kernel modules that you want to load automatically, follow Kernel modules.

Configure the system and install system tools

Filesystem, nework, and clock

Now follow this page to configure your fstab, network, and other system information.

In /etc/fstab, make sure you have an entry for /proc, something like this:

proc            /proc        proc    defaults    0 0

 

Basic system tools

Follow this page to install logger, cron, file system tools, and networking tools.

Bootloader

Follow this page to install and configure the bootloader. Don't bother with the framebuffer for now. We can come back to it later.

Before you reboot, make sure you unmount all disks cleanly. Otherwise you may encounter corrupted disk partitions, and all of your effort above would go in vain.

Use mount to check for all mounted file systems and devices:

# mount

Everything mounted to /mnt/gentoo/* must be unmounted before you you can unmount /mnt/gentoo.

Now reboot....

We saw "kernel panic"...

As we said earlier, this computer is rather old. "fdisk -l" during installation showed the disks as /dev/hda and /dev/hdb. So we put root=/dev/hda3 in the boot command of grub, and the new kernel no longer recognize hda. Though kernel panic, we don't need to panic. Just boot the system using the installation CD again, mount the / and /boot, and fix the grub config and /etc/fstab.

X server

Getting X up and running is the hardest part. I have it in the separate note here: X Server on ATI Rage X.

Sound

This part was easy, since we already configured kernel to support the sound card, and support ALSA.

Printer support

This is another hard part. Follow Gentoo Printing Guide should get you there. the hard part is to find the driver for the printer, and then you might need to find and download the ppd file for the printer driver somewhere.

NTP setup

Follow NTP - Gentoo to setup the NTP.