Gentoo Linux 2.6 Base Install

Content:

1. Boot

The installation ISOs are on the Gentoo Mirrors. Detailed descriptions of the different CDs are available in the Gentoo Store. A universal CD contains everything you need to install Gentoo Linux quickly and without a connection to the Internet. A Package CD is optional and contains pre-compiled packages such as KDE, GNOME, OpenOffice, Mozilla, Evolution and more.

Boot from the Universal CD. Press <F1> and/or <F2> to see what boot options are available. For installing Linux 2.4, press <ENTER> at the bootscreen to continue with the default kernel. For Linux 2.6, type smp<ENTER>.

# loadkeys /usr/share/keymaps/i386/qwertz/fr_CH       (Load keyboard definition)
# date                                 (Make sure your time and date is correct)
# date MMDDhhmmCCYY                                          (Set time and date)
# cat /proc/meminfo                                          (check memory size)

2. Partition

My setup is

# fdisk /dev/hda                                           (Partition the drive)
# mke2fs -L Boot /dev/hda1                       (Initialize the boot partition)
# mkswap /dev/hda5                               (Initialize the swap partition)
# swapon /dev/hda5                                 (Activate the swap partition)
# mke2fs -jL System /dev/hda6                  (Initialize the system partition)
# mke2fs -jL Backup /dev/hda3                  (Initialize the backup partition)
# mke2fs -jL Data /dev/hda4                      (Initialize the data partition)

3. Installation files

Continue by mounting the partitions and extracting the appropriate stage file.

# mount -t ext3 /dev/hda6 /mnt/gentoo                 (Mount the root partition)
# cd /mnt/gentoo                                          (Go to the mountpoint)
# mkdir boot                                        (Create the boot mountpoint)
# mkdir home                                        (Create the home mountpoint)
# mkdir proc                                        (Create the proc mountpoint)
# mount /dev/hda1 boot                                (Mount the boot partition)
# mount -t ext3 /dev/hda4 home                        (Mount the home partition)
# mount -t proc none proc                             (Mount the proc partition)
# cat /proc/cpuinfo                                    (look for processor type)
# tar -xvjpf /mnt/cdrom/stages/stage3-*.tar.bz2        (Extract a stage tarball)
# tar -xvjf /mnt/cdrom/snapshot/portage-*.tar.bz2 -C usr/   (Copy portage files)
# mkdir usr/portage/distfiles              (create distribution files directory)
# cp -v /mnt/cdrom/distfiles/* usr/portage/distfiles/      (copy over distfiles)

Configure the system installation process.

# nano -w etc/make.conf                             (Edit configuration options)
# mirrorselect -a -s4 -o >> etc/make.conf                      (Select a mirror)
# ln -snf /usr/portage/profiles/default/linux/<profile> etc/make.profile  (2008)
# cp /etc/resolv.conf etc/resolv.conf         (Copy over nameserver information)

4. Change root

Now that all partitions are initialized and the base environment installed, it is time to enter our new installation environment by chrooting into it.

# chroot /mnt/gentoo /bin/bash                 (Chroot into the new environment)
# env-update                                      (Load the necessary variables)
# source /etc/profile

5. Install Gentoo

In order to have more information about the machine, one can install following tools:

# emerge isapnptools                       (For information about the ISA cards)
# pnpdump | less                                                      (Get info)
# emerge pciutils                          (For information about the PCI cards)
# lspci                                                               (Get info)
# USE="-gtk" emerge lshw                   (For information about the mainboard)
# lshw                                                                (Get info)

Now we can install the system:

# emerge gentoo-sources                         (Install the 2.6 kernel sources)
# cd /usr/src/linux; make menuconfig                      (Configure the kernel)
# make && make modules_install                             (Compile your kernel)
# cp arch/i386/boot/bzImage /boot                         (Copy over the kernel)
# cp .config /boot/config               (Copy the kernel configuration settings)

One can find the liveCD .config file in usr/share/genkernel/x86/kernel-config-2.<n>.

6. Configure

Next, we configure Gentoo and install basic tools.

# ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime    (Set the time zone)
# nano -w /etc/fstab                                (Build the filesystem table)
# nano -w /etc/conf.d/hostname                               (Set the host name)
# nano -w /etc/conf.d/domainname                   (Set the network domain name)
# rc-update add domainname default                     (Domain name init script)
# nano -w /etc/conf.d/net                                         (Configure IP)
# rc-update add net.eth0 default                 (Have ethernet started at boot)

# nano -w /etc/hosts            (Add the host name at the end of the first line)

# nano -w /etc/conf.d/keymaps                           (Define keyboard layout)
# nano -w /etc/conf.d/clock                               (Define clock options)
# emerge syslog-ng                                (Install system logger daemon)
# rc-update add syslog-ng default        (Have the systemlogger started at boot)
# emerge vixie-cron                                        (Install cron daemon)
# rc-update add vixie-cron default        (Have the cron daemon started at boot)

For a DHCP ethernet setup, you have to install dhcpcd as well.

Let's define the users.

# passwd                                                 (Set the root password)
# useradd <username> -m -g users -G wheel,audio,tty -s /bin/bash    (Add a user)
# passwd <username>                                    (Set the user's password)

7. Bootloader

Now install a bootloader.

# emerge lilo                              (Install the bootloder setup program)
# nano -w /etc/lilo.conf                                (Configure boot options)
# lilo                                                 (Have lilo write the MBR)

You might as well use grub.

# emerge grub                              (Install the bootloder setup program)
# nano -w /boot/grub/grub.conf                          (Configure boot options)
# cp /proc/mounts /etc/mtab          (update information on mounted filesystems)
# grub-install --root-directory=/boot /dev/hda         (Have grub write the MBR)

8. Reboot

Finally, unmount all partitions and reboot into your new system.

# exit                                                         (Exit the chroot)
# cd /mnt/gentoo                                           (Move to mount point)
# umount boot/ home/ proc/                    (Unmount the secondary partitions)
# cd ..                                                      (Move one level up)
# umount gentoo/                                    (Unmount the root partition)
# reboot                                                                (Reboot)

Remove the Gentoo CD from the tray!

You can get more information from the Gentoo Documentation.

9. Backup

Clean-up your installation.

# cd /usr/src/linux; make mrproper                      (Clean compiled modules)
# cp /boot/config .config                   (Copy the kernel configuration back)
# make && make modules_install                              (Compile the kernel)
# cp arch/i386/boot/bzImage /boot/                        (Copy over the kernel)
# reboot                                                                (Reboot)

Reboot on the Gentoo liveCD.

# mount /dev/hda3 /mnt/gentoo                       (Mount the backup partition)
# cd /mnt/gentoo                                                    (Move there)
# mkdir backup                                  (Prepare the backup mount point)
# mount /dev/hda6 backup                            (Mount the system partition)
# tar -cvjpf hda6.tar.bz2 backup               (Compress and archive the system)
# umount backup                                (Unmount the backed-up partition)
# cd ..                                                      (Move one level up)
# umount gentoo/                                  (Unmount the backup partition)
# reboot                                                                (Reboot)

Remove the Gentoo CD from the tray!