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.

Boot from the Universal CD.

# 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/sda                                           (Partition the drive)
# mke2fs -L Boot /dev/sda1                       (Initialize the boot partition)

From here, I personally have some install scripts I install in the boot partition.

# mount /dev/sda1 /mnt/gentoo                         (mount the boot partition)
# cp /mnt/cdrom/scripts/boot.tar.bz2 /mnt/gentoo              (copy the tarball)
# cd /mnt/gentoo                                  (move to the tarball location)
# tar -xvjpf boot.tar.bz2                                  (extract the scripts)
# source install_1_swap_mounts.sh                      (launch the frist script)

The install scripts basicall continue with:

# mkswap /dev/hda5                               (Initialize the swap partition)
# swapon /dev/hda5                                 (Activate the swap partition)
# mke2fs -jL System /dev/sda6                  (Initialize the system partition)
# mke2fs -jL Portage /dev/sda7                (Initialize the portage partition)
# mke2fs -jL Backup /dev/sda3                  (Initialize the backup partition)
# mke2fs -jL Data /dev/sda4                      (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 -p usr/portage                           (Create the portage mountpoint)
# mkdir proc                                        (Create the proc mountpoint)
# mount /dev/hda1 boot                                (Mount the boot partition)
# mount -t ext3 /dev/hda7 usr/portage              (Mount the portage 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 -f mirrorselect                       (For changing the Gentoo mirrors)
# emerge isapnptools                       (For information about the ISA cards)
# pnpdump | less                                                      (Get info)
# emerge pciutils                          (For information about the PCI cards)
# lspci                                                               (Get info)
# emerge lshw                              (For information about the mainboard)
# lshw                                                                (Get info)
# emerge parted                                               (Partition editor)

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)
# emerge ntfs3g                                           (Windows NTFS drivers)
# cp arch/i386/boot/bzImage /boot                         (Copy over the kernel)
# cp .config /boot/config               (Copy the kernel configuration settings)

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/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 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/sda         (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!