Overview
The purpose of this HOWTO is to provide concise instructions on installing a Gentoo Linux system, which forms the basis of all Gentoo boxes, whether a network server, workstation or a laptop. The explanations of commands used, procedures followed and alternative configurations are kept to the minimum, as it is expected that you have already read the official Gentoo Linux x86 Handbook. Furthermore, a working grasp of computers, networking and Linux in general is required.
The machine used in this example is a VMware 5.5.8 instance, configured according to the guidelines, with my Toshiba Satellite Pro as host.
Get Everything Ready
- The following three files, downloaded either to the Windows machine or another Linux box:
- An IP address, even if your network has DHCP configured;
Installation Procedure
Boot with the Gentoo CD
Enter the following parameters at the boot screen:
boot: gentoo nox nodhcp
This boots the standard Gentoo kernel (gentoo), without support for X (nox) and DHCP (nodhcp). It is not necessary to load support for SCSI drives (doscsi) when installing to a VMware instance, even if the virtual drives are configured as SCSI. This is because the recommended controller emulated by VMware (a BusLogic BT-946C (BA80C30) [MultiMaster 10] (rev 01)) is defined seperate from the standard SCSI devices in the kernel. Change according to your configuration.
Follow the boot process and choose your keyboard layout when prompted. If your keyboard is an US-layout just press <enter> or wait for the process to timeout with the default, but since my laptop (the VMware host) has an UK-layout keyboard:
<< Load keymap (Enter for default): 40
System Date/Time
Check that the system date and time is correct. The timezone used by the Gentoo Install CD is UTC, therefore set accordingly. (Changing the time in a VMware instance does not affect the host clock.)
livecd root # date [MMDDhhmmYYYY]
Configure Networking
Since we passed the nodhcp parameter to the kernel at boot time, we need to configure the network manually:
livecd root # ifconfig eth0 192.168.0.18 netmask 255.255.255.0
livecd root # route add default gw 192.168.0.1
livecd root # echo nameserver 192.168.0.5 > /etc/resolv.conf
OPTIONAL: Start SSH
We now have a choice to consider: continue working at this console, or make a new connection through SSH from another machine. The latter option has the benefit of allowing us to copy & paste commands from this HOWTO directly into the console. Otherwise skip to the next section.
livecd root # passwd
livecd root # /etc/init.d/sshd start
With SSH running, we can login from a Windows workstation with PuTTY. It is suggested that the screen command be issued every time you connect through SSH, because this will preserve your session in case of a network failure.
livecd ~ # screen
Configure the Disks
livecd ~ # cfdisk /dev/sda
I tend to favour the layout suggested by the Gentoo-folks:
| Partition | Size |
|---|---|
| /boot | 100 MB |
| swap | 2048 MB or 2 × memory |
| / | (the rest) |
Create and mount the filesystems:
livecd ~ # mke2fs /dev/sda1
livecd ~ # mke2fs -j /dev/sda3
livecd ~ # mkswap /dev/sda2 && swapon /dev/sda2
livecd ~ # mount /dev/sda3 /mnt/gentoo
livecd ~ # mkdir /mnt/gentoo/boot
livecd ~ # mount /dev/sda1 /mnt/gentoo/boot
Install the Gentoo Files
Copy the stage3 tarball over to the machine from the Windows workstation (or VMware host):
C:\Documents and Settings\Robert Sadler> pscp "C:\Downloads\Gentoo\stage3-i686-2008.0.tar.bz2" root@192.168.0.18:/mnt/gentoo
or retrieve from another Linux box on the network, e.g.:
livecd ~ # scp root@192.168.0.5:/srv/samba/shared/Programme/Gentoo/stage3-i686-2008.0.tar.bz2 /mnt/gentoo
Extract:
livecd ~ # cd /mnt/gentoo
livecd gentoo # tar xvjpf stage3-i686-2008.0.tar.bz2 && rm -f stage3-i686-2008.0.tar.bz2
Copy the portage tarball over to the machine from the Windows workstation (or VMware host):
C:\Documents and Settings\Robert Sadler> pscp "C:\Downloads\Gentoo\portage-latest.tar.bz2" root@192.168.0.18:/mnt/gentoo/usr
or retrieve from another Linux box on the network, e.g.:
livecd ~ # scp root@192.168.0.5:/srv/samba/shared/Programme/Gentoo/portage-latest.tar.bz2 /mnt/gentoo/usr
Extract:
livecd gentoo # cd /mnt/gentoo/usr
livecd usr # tar xvjf portage-latest.tar.bz2 && rm -f portage-latest.tar.bz2
Enter the CHROOT Environment
livecd usr # cd /
livecd / # cp -L /etc/resolv.conf /mnt/gentoo/etc/
livecd / # mount -t proc proc /mnt/gentoo/proc
livecd / # mount -o bind /dev /mnt/gentoo/dev
livecd / # chroot /mnt/gentoo /bin/bash
livecd / # env-update && source /etc/profile
livecd / # export PS1="(chroot) $PS1"
(chroot) livecd / # passwd
Set the Time Zone
(chroot) livecd / # cp /usr/share/zoneinfo/Africa/Johannesburg /etc/localtime
(chroot) livecd / # nano -w /etc/conf.d/clock
# /etc/conf.d/clock CLOCK="local" TIMEZONE="Africa/Johannesburg" CLOCK_OPTS="" CLOCK_SYSTOHC="no" SRM="no" ARC="no"
Configure Host Details
(chroot) livecd / # echo "127.0.0.1 gentoo.groenheide.org.za gentoo localhost" > /etc/hosts
(chroot) livecd / # echo 'HOSTNAME="gentoo"' > /etc/conf.d/hostname
(chroot) livecd / # hostname gentoo
Edit make.conf
(chroot) livecd / # nano -w /etc/make.conf
# /etc/make.conf CHOST="i686-pc-linux-gnu" CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer" CXXFLAGS="${CFLAGS}" MAKEOPTS="-j3" USE="-X bzip2 caps gmp -gtk -ipv6 logrotate mmx nptl nptlonly sse sse2 -tcpd threads unicode" SYNC="rsync://192.168.0.7/gentoo-portage" http_proxy="http://192.168.0.7:8086"
Synchronise portage
(chroot) livecd / # emerge --sync
(chroot) livecd / # emerge portage
(chroot) livecd / # etc-update
Configure Locales
(chroot) livecd / # nano -w /etc/locale.gen
# /etc/locale.gen en_ZA ISO-8859-1 en_ZA.UTF-8 UTF-8
(chroot) livecd / # locale-gen
(chroot) livecd / # nano -w /etc/env.d/02locale
# /etc/env.d/02locale LANG="en_ZA.UTF-8" LC_COLLATE="C"
Install the Linux Kernel
(chroot) livecd / # USE="symlink" emerge gentoo-sources
(chroot) livecd / # emerge genkernel
(chroot) livecd / # mkdir /etc/kernels
(chroot) livecd / # scp robert@sella.groenheide.org.za:/home/robert/kernel-config-x86-2.6.34-gentoo-r6 /etc/kernels/(chroot) livecd / # genkernel --loglevel=5 --menuconfig all
The genkernel program stores kernel configuration files under /etc/kernels.
Edit the File Systems Table (fstab)
(chroot) livecd / # nano -w /etc/fstab
# <fs> <mountpoint> <type> <opts> <dump/pass> /dev/sda1 /boot ext2 noauto,noatime 1 2 /dev/sda3 / ext3 noatime 0 1 /dev/sda2 none swap sw 0 0 /dev/cdrom /mnt/cdrom iso9660 noauto,ro 0 0 #/dev/fd0 /mnt/floppy auto noauto 0 0 proc /proc proc defaults 0 0 shm /dev/shm tmpfs nodev,nosuid,noexec 0 0
A full explanation of the fstab file is available on Wikipedia. Remember to change the partitions to match your setup, i.e. hd? for IDE and sd? for SCSI/SATA.
Configure the Network
(chroot) livecd / # nano -w /etc/conf.d/net
config_eth0=( "192.168.0.18 netmask 255.255.255.0 brd 192.168.0.255" ) routes_eth0=( "default gw 192.168.0.1" ) dns_domain_eth0="groenheide.org.za" dns_search_eth0="groenheide.org.za" dns_servers_eth0=( "192.168.0.5" "192.168.0.1" )
(chroot) livecd / # rc-update add net.eth0 default
Install and Configure Essential Packages
(chroot) livecd / # rc-update add sshd default
(chroot) livecd / # emerge syslog-ng && rc-update add syslog-ng default
(chroot) livecd / # emerge logrotate
(chroot) livecd / # emerge postfix
(chroot) livecd / # emerge vixie-cron && rc-update add vixie-cron default
(chroot) livecd / # emerge screen
Install and Configure GRUB as the Bootloader
(chroot) livecd / # emerge grub
(chroot) livecd / # nano -w /boot/grub/grub.conf
default 0 timeout 10 splashimage=(hd0,0)/boot/grub/splash.xpm.gz title=Gentoo Linux 2.6.34-r6 root (hd0,0) kernel /boot/kernel-genkernel-x86-2.6.34-gentoo-r6 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/sda3 udev initrd /boot/initramfs-genkernel-x86-2.6.34-gentoo-r6
(chroot) livecd / # grep -v rootfs /proc/mounts > /etc/mtab
(chroot) livecd / # grub-install /dev/sda
Exit the CHROOT Environment and Reboot
(chroot) livecd / # exit
livecd / # umount /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo
livecd / # reboot
Update the System
gentoo ~ # emerge -D world
Some package might require manual attention:
gentoo ~ # hash -r
gentoo ~ # /usr/sbin/python-updater
gentoo ~ # find -L /etc/ssl/certs/ -type l -exec rm {} +
gentoo ~ # grpck
gentoo ~ # grpconv
Update configuration files:
gentoo ~ # etc-update
Check that there are no files we have previously edited and choose each, exit the editor (press q) and then option 2) Delete update, keeping original as is. For the rest, go with (-5 to auto-merge AND not use 'mv -i').
gentoo ~ # update-modules force
gentoo ~ # reboot
Install and Configure More Essential Packages
gentoo ~ # perl-cleaner all
gentoo ~ # emerge gentoolkit
gentoo ~ # emerge net-dns/bind-tools
gentoo ~ # emerge net-analyzer/traceroute
gentoo ~ # emerge sys-apps/pciutils
Create User(s)
gentoo ~ # useradd -c "Robert Sadler" -g users -G lp,wheel,audio,cdrom,portage,cron -m robert
gentoo ~ # passwd robert
Discussion
Next Steps
- Customise your Gentoo Installation
- Install & Configure NTP
- Configure Postfix
