The aim of this QND guide is to get you up and running the Gentoo linux distribution quickly on a i686 class computer (e.g. Pentium 2 or newer, including Pentium Pro, or AMD Athlon). To this end, the guide covers an install in which network access is not necessary, and thus not covered. If you would like the network to function during the install, see the Gentoo documentation. This guide is targetted at the Gentoo 1.4 release.
This guide is not exhaustive, nor will it result in the fastest / best possible Gentoo install. It does, however, get Gentoo installed on your box quickly without assaulting you with choices. I believe this makes it idea for a first Gentoo install. When you have learned a bit more about the system, you may want to re-install, or re-emerge your base system. The great thing about Gentoo is that you can take a system that "just boots", and customise it completely to your needs and architecture.
If you have access to a fast Internet connexion and a CD burner (or know someone who does), grab the latest Gentoo LiveCDs from:
http://gentoo.oregonstate.edu/releases/x86/1.4/livecd/i686/
You will want to download both .iso files and then burn a CD of each (i.e. this will result in you having a LiveCD Disc 1 CD and a LiveCD Disc 2 CD).
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
On most modern computers, this is as simple as putting the CD in your CD-ROM drive and [re-]booting the computer. If you try this and it does not boot from the CD-ROM, make sure you have Disc 1 in (Disc 2 is not bootable), and if you do, you may need to twiddle settings in your BIOS to boot off a CD. If you do not know how to do that, ask your local computer expert.
When you boot from the CD, you will be presented with some options. If you have an SMP system (i.e. you have more than one CPU), type smp and hit enter. Most people just want to hit enter here. You will see a splash screen with a progress bar, and then will be logged in as root. You will know that this has happened when the cursor blinks after a prompt that looks like this:
cdimage root #
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
Enter:
dateIf the resulting date and time are correct, move on to the next step. If they are incorrect, enter:
date MMDDhhmmYYYYwhere MM is the two-digit month (e.g. November is 11), DD is the two-digit day of the month (e.g. 01, 09, 13, etc), hh is the hour, in 24-hour time (e.g. 7 AM is 07, 7 PM is 19, etc), mm is the two-digit minute (e.g. 05, 15, etc), and YYYY is the four-digit year (e.g. 2003).
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
Before we can create filesystems, we must physically partition up the hard drive. This guide will assume that you have only one hard drive (or are using only one hard drive for Gentoo), that it is an IDE drive, and that it is the your first logical IDE drive (i.e. /dev/hda. If you do not understand any of that, don't worry, the setup just described is correct for 99% of personal computers. If you know that your setup is different, you also probably know how to alter the next bits of this guide to work with your setup (e.g. if you have a SCSI drive, change all of the /dev/hdas in the next few steps to /dev/sda). If you don't, consult your local Unix expert or:
Filesystems, partitions and block devices
!!! DANGER WILL ROBINSON !!! If you have any data that you love, back it up before proceeding. The next step in this guide will destroy *ALL* data on your system, *including* any currently installed Operating System!
Still reading? Good. :) Enter:
fdisk /dev/hdawhich will open the (somewhat arcane) partition editor. You will see something like:
The number of cylinders for this disk is set to 4863. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help):and a blinking cursor. Try not to be afraid.
Enter p at the prompt to display the current partition table, which will look something like:
Disk /dev/hda: 40.0 GB, 40000000000 bytes 255 heads, 63 sectors/track, 4863 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 7 56196 de Dell Utility /dev/hda2 8 24 136552+ 83 Win95 FAT32we now want to delete all of the current partitions, except for the first one if it happens to be labelled as a "utility" or "diagnostics" partition (in this example, we do not want to delete the first partition, because it is labelled "Dell Utility").
To delete a partition, enter d. You will be prompted for a partition number. You should enter 1 unless your first partition is labelled utility / diagnostics / whatever, in which case you should enter 2. Now, enter d again, and enter the number of the next partition. Repeat until you get a
No partition is defined yet!error.
Now, enter p. You should see:
Disk /dev/hda: 40.0 GB, 40000000000 bytes 255 heads, 63 sectors/track, 4863 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id Systemunless you have a utility / diagnostics / whatever partition, in which case it will be listed.
It is now time to start creating partitions. This guide will not (as some popular *koff* Mandrake Red Hat *koff* Linux distros tend to do) create one massive root partition. Instead, we will hold to the assertion that Linux is Unix and do things right. We will assume that your hard drive is at least 8GB in size. If it is smaller, you probably should not be using this document to install Gentoo.
Enter n to create a new partition. When asked:
Command action e extended p primary partition (1-4)enter p, and then, when prompted for a partition number, enter 1, unless you have a utility / diagnostics / whatever partition, in which case you should enter 2. When prompted to enter the first cylinder, press enter to accept the default. Finally, you will be prompted to enter the last cylinder (only if you have a PhD in mathematics) or a size. This partition shall be your /boot partition, so enter +64M to make it 64 megabytes large.
Now, enter n again to create your swap partition. Enter p to make it a primary partition, and 2 to make it the second partition, unless you have a utility / diagnostics / whatever partition, in which case you should enter 3. Enter +512M to make your swap partition 512 megabytes (if you know how big your swap partition should be, feel free to ignore this recommendation and use your own size.
Now, we need to create the root partition. For those of you who do not have utility / diagnostics / whatever partitions, repeat the partition creation process as above, and make the root partition 256MB. If you have a utility / diagnostics / whatever partition, skip ahead to the next paragraph, then create a root partition as detailed there.
It is time to create our extended partition that will hold the rest of the partition. Enter n at the main menu as usual, but when asked whether the partition should be extended or primary, enter e for extended. When asked for the first cylinder, press enter to accept the defaults. Also press enter to accept the defaults when asked about the last cylinder. This will create an extended partition that takes up the rest of the disk. If you have not yet created your root partition, (becuase you have a utility / diagnostics / whatever partition), do it now. Note that you will not be asked what kind of partition to create, you will just enter the first and last cylinder (size) information. Make the root partition 256MB.
Create the remaining partitions, as above, except note that you will not be asked what kind of partition to create, you will just enter the first and last cylinder (size) information. You will need, in this order: /opt, 512MB; /tmp, 512MB; /usr, 4096MB; /var, 1024MB; and /home, all remaining space on the disk (accept defaults for both first and last cylinders).
Now, enter p at the main menu to display the current partitions. It should look something like:
Disk /dev/hda: 100.0 GB, 100030242816 bytes 255 heads, 63 sectors/track, 12161 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 1 9 72261 83 Linux /dev/hda2 10 72 506047+ 83 Linux /dev/hda3 73 104 257040 83 Linux /dev/hda4 105 12161 96847852+ 5 Extended /dev/hda5 105 167 506016 83 Linux /dev/hda6 168 230 506016 83 Linux /dev/hda7 231 729 4008186 83 Linux /dev/hda8 730 854 1004031 83 Linux /dev/hda9 855 12161 90823446 83 LinuxNote that if you have a utility / diagnostics / whatever partition, everything will be shifted down one and the root partition will be in the extended partition.
Now, enter w to write your new partitioning scheme to the disk and exit fdisk.
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
If you have a utility / diagnostics / whatever partition, increment all partition names in this section by one (e.g. if /dev/hda1 is written, use /dev/hda2 instead) unless it is /dev/hda3. Here you must use /dev/hda5 instead (because of the extended partition).
Likewise, if you have a SCSI disk, substitute sda wherever hda is written.
You will make your /boot filesystem ext2, which is the old standby of Linux filesystems. We need not worry about a journalling filesystem for /boot since it should almost never be mounted. To create the filesystem, enter:
mke2fs /dev/hda1
Next, initialise your swap partition:
mkswap /dev/hda2
You will make your root partition reiserfs, since it is good at handling the large number of small files that tend to abound on root partitions:
mkreiserfs /dev/hda3If you have a utility / diagnostics / whatever partition, this should be hda5!
The rest of your partitions will be XFS, which is a good preforming general-purpose journalling filesystem:
for i in `seq 5 9`; do mkfs.xfs -f /dev/hda$i; doneIf you have a utility / diagnostics / whatever partition, this should be `seq 6 10`!
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
If you have a utility / diagnostics / whatever partition, increment all partition names in this section by one (e.g. if /dev/hda1 is written, use /dev/hda2 instead) unless it is /dev/hda3. Here you must use /dev/hda5 instead (because of the extended partition).
Likewise, if you have a SCSI disk, substitute sda wherever hda is written.
First, activate your swap space:
swapon /dev/hda2If you have a utility / diagnostics / whatever partition, this should be hda3!
Now, mount your root partition:
mount /dev/hda3 /mnt/gentooIf you have a utility / diagnostics / whatever partition, this should be hda5!
Change to your newly mounted root filesystem
cd /mnt/gentooand create the mountpoints for the rest of your filesystems:
for i in boot home opt proc tmp usr var; do mkdir $i; done
Now, mount all of the remaining filesystems:
mount /dev/hda1 boot mount /dev/hda5 opt mount /dev/hda6 tmp mount /dev/hda7 usr mount /dev/hda8 var mount /dev/hda9 homeIf you have a utility / diagnostics / whatever partition, remember to increment the partition number (and skip the dreaded hda4)!
Finally, mount the /proc partition on proc--we will need it later:
mount -t proc /proc proc
And now is as good a time as any to set the permissions on our newly mounted /tmp partition correctly:
chmod 1777 tmp
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
Make sure you are in the /mnt/gentoo directory, which is the mountpoint of your root filesystem:
cd /mnt/gentoo
Now, extract the Stage 3 base system tarball into the current directory:
tar xvjpf /mnt/cdrom/stages/stage3-i686-*.tar.bz2
Extract the Portage snapshot tarball into the usr/ directory:
tar xvjf /mnt/cdrom/snapshots/portage-*.tar.bz2 -C usr
Copy the distribution and GRP (Gentoo binary packages) files into your new Portage directory:
cp -R /mnt/cdrom/distfiles usr/portage/distfiles cp -a /mnt/cdrom/packages usr/portage/packages
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
Create a chroot jail for your new Gentoo system (yes, believe it or not, you almost have a fully functional system built in the /mnt/gentoo directory):
chroot /mnt/gentoo /bin/bash
Update your environment (to completely immerse yourself in the Matrix):
env-update source /etc/profile
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
Make a symbolic link (AKA symlink AKA soft link) from the zoneinfo file that correctly describes your time zone to /etc/localtime:
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtimeif you are in North America's Eastern Standard Time zone. If you are in Ireland, you want to use zoneinfo/Eire; if in Japan, zoneinfo/Japan; if in California, zoneinfo/America/Los_Angeles; if in Bulgaria, zoneinfo/Europe/Sofia; and so on. You should be able to figure it out. :)
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
/etc/fstab tells Linux all it needs to know about your filesystems. Open it
nano -w /etc/fstaband edit it (Nano is the GNU clone of Pico, if that helps you; Emacs / Readline style movement generally works; look at the bottom line of Nano for a quick keystroke reference) to look like this:
# /etc/fstab: static file system information. # # noatime turns off atimes for increased performance (atimes normally aren't # needed; notail increases performance of ReiserFS (at the expense of storage # efficiency). It is safe to drop the noatime options if you want and to # switch between notail and tail freely. # <fs> <mount point> <type> <opts> <dump/pass> # NOTE: If your BOOT partition is ReiserFS, add the notail option to opts. /dev/hda1 /boot ext2 noauto 1 1 /dev/hda3 / reiserfs defaults 0 0 /dev/hda5 /opt xfs defaults 0 0 /dev/hda6 /tmp xfs defaults 0 0 /dev/hda7 /usr xfs defaults 0 0 /dev/hda8 /var xfs defaults 0 0 /dev/hda9 /home xfs defaults 0 0 /dev/hda2 none swap sw 0 0 /dev/cdroms/cdrom0 /mnt/cdrom iso9660 noauto,ro,user 0 0 none /proc proc defaults 0 0
If you have a utility / diagnostics / whatever partition, remember to increment the partition number (and skip the dreaded hda4)!
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
This will be your first experience with emerge, which is the program used for manipulating Portage, the Gentoo package system. We will emerge (AKA install) the binary xfs-sources kernel:
emerge -k xfs-sourcesThe -k switch is what tells Portage to use a binary package as opposed to the preferred default source packages. (Though actually, the "binary" kernel package is not much different from the "source" one.)
For some reason, some part of the GRP install seems to create a boot symlink to /boot in the /boot directory, which has the unfortunate result of creating an infinitely deep directory structure. Said foppery will prevent genkernel from installing the kernel. Kill the symlink:
rm /boot/boot
Now, emerge the genkernel script and use it to compile and install your kernel:
emerge -k genkernel genkernel
When genkernel finishes, make sure you have the following files in /boot:
/boot/System.map-version /boot/kernel-versionwhere version is the Linux kernel version (e.g. 2.4.20) plus the Gentoo kernel name (in this case xfs) and the Gentoo ebuild release (e.g r3). If these files do not exist, you will have to install the kernel manually:
version=`ls -1 /usr/src/ | grep linux- | awk -F'linux' '{ print $2 }'` cp /usr/src/linux/System /boot/System.map$version cp /usr/src/linux/arch/i386/boot/bzImage /boot/kernel$version
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
You will install the most standard system logger, sysklogd, and cron daemon, vcron:
emerge -k sysklogd vcronAfter the packages are installed, add them to the default run-level:
rc-update add sysklogd default rc-update add vcron default
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
Since you have reiserfs and XFS filesystems, you should install the tools for both:
emerge -k reiserfsprogs xfsprogs
And if you are installing on a laptop, you will want to install the pcmcia-cs package and add it to the boot run-level:
emerge -k pcmcia-cs rc-update add pcmcia boot(this will involve a compile--a binary package is not distributed on the LiveCD).
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
If you forget to set a password for the root account, you will not be able to login to your box! Do it now:
passwd rootEnter a good password, then enter it again for verification.
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
If you are on a LAN, or are connected to the Internet by an Ethernet NIC (e.g. you have a cable or DSL modem), you will want to configure your network settings. If you dial up to the Internet, skip ahead to the next step.
Set your hostname and domain name:
echo 'hostname.domain.tld' >/etc/hostname echo 'domain.tld' >/etc/dnsdomainname
Add at least one nameserver to your /etc/resolve.conf:
echo 'nameserver 123.456.789.1' >/etc/resolv.conf echo 'nameserver 123.456.789.2' >>/etc/resolv.confPlease note that in the first step, you are truncating your /etc/resolv.conf, and in the second, you are appending to it (>> versus >)!
Now, configure your primary Network Interface Card (NIC) by entering:
nano -w /etc/conf.d/netEdit the file to look something like this (note that you only need to edit the lines coloured red):
# /etc/conf.d/net: # $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7 2002/11/18 19:39:22 azarah Exp $ # Global config file for net.* rc-scripts # This is basically the ifconfig argument without the ifconfig $iface # iface_eth0="192.168.4.209 broadcast 192.168.4.255 netmask 255.255.255.0" #iface_eth1="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0" # For DHCP set iface_eth? to "dhcp" # For passing options to dhcpcd use dhcpcd_eth? # #iface_eth0="dhcp" #dhcpcd_eth0="..." # For adding aliases to a interface # #alias_eth0="192.168.0.3 192.168.0.4" # NB: The next is only used for aliases. # # To add a custom netmask/broadcast address to created aliases, # uncomment and change accordingly. Leave commented to assign # defaults for that interface. # #broadcast_eth0="192.168.0.255 192.168.0.255" #netmask_eth0="255.255.255.0 255.255.255.0" # For setting the default gateway # gateway="eth0/192.168.4.254"In the iface_eth0="192.168.4.209 broadcast 192.168.4.255 netmask 255.255.255.0" line, replace 192.168.4.209 with your IP address. Replace 192.168.4.255 with your broadcast address (which is usually just your IP address, except the number after the third dot is 255). If you know that you are not in a class C (or its CIDR equivalent, */24) network, replace 255.255.255.0 with your network mask. If you do not know these settings, consult your ISP, sysadmin, or local networking guru.
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
You will need to install a bootloader (in this case, GRUB) in order to boot into Linux:
emerge -k grub
Now, enter
nano -w /boot/grub/grub.confto create a GRUB configuration file. Edit it to look like this:
default 0 timeout 10 splashimage=(hd0,0)/grub/splash.xpm.gz title=Gentoo 1.4 (Linux version) root (hd0,0) kernel (hd0,0)/kernel-version root=/dev/hda3 initrd (hd0,0)/initrd-versionwhere version is the Linux kernel version (e.g. 2.4.20) plus the Gentoo kernel name (in this case xfs) and the Gentoo ebuild release (e.g r3); i.e. the output of:
version=`ls -1 /usr/src/ | grep linux- | awk -F'linux' '{ print $2 }'`
If you have a utility / diagnostics / whatever partition, you should change (hd0,0) to (hd0,1)!
The Gentoo instructions for this step (see below) have you enter (hd0,0)/boot instead of just (hd0,0)/. In my experience, GRUB cannot find any files prefixed with /boot. This makes sense in that (hd0,0) refers to the /boot partition, and is probably why the /boot/boot infinite symlink is created. What a kludge!
To invoke the GRUB shell (one of the big reasons why it is the best bootloader, period), enter:
grub --no-floppyYou will be presented with a prompt:
GNU GRUB version 0.93 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ] grub>To tell GRUB that your boot partition is the first partition (or second, if you have a utility / diagnostics / whatever partition) of the first hard drive, enter:
root (hd0,0)
If you have a utility / diagnostics / whatever partition, you should change (hd0,0) to (hd0,1)!
GRUB will report:
Filesystem type is ext2fs, partition type 0x83
To install GRUB onto the Master Boot Record (MBR) of your first hard drive, enter:
setup (hd0)
GRUB will report:
Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 16 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded Done.
To exit GRUB, enter:
quit
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
If you are installing Gentoo on a server, you probably do not want to install X. Skip to the next step.
Using Portage and GRP, installing XFree86 is a simple as entering:
emerge -k xfreeAgain, the -k flag tells emerge to use binary packages when available.
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
To escape from the chroot jail, enter:
exitor hit Ctrl+d.
Unmount all of your filesystems:
cd / for i in /mnt/gentoo/*; do umount /mnt/gentoo/$i; done umount -l /mnt/gentooand reboot:
reboot
Make sure to remove the bootable CD as soon as you are able (i.e. right after the machine resets). If all is well, you will see a slick GRUB menu that will wait 10 seconds, then boot into your new Gentoo Linux system!
If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.
Login to the system with the root password that you set in Step 14.
Insert the Gentoo LiveCD, Disc 2 into your CD-ROM drive and enter:
cp /mnt/cdrom/packages/All/* usr/portage/packages/All/which will copy around 450MB worth of binary packages onto your hard drive. Don't worry, it is only temporary. :)
Install a decent editor, vim, sudo a package that lets you run commands with root privileges without having to be root (so you can avoid the onset of carpal tunnel due to typing su - a thousand times a day), and the Gentool Toolkit:
emerge -k vim sudo gentoolkit
If you are installing Gentoo on a server, you are done. Create some user accounts and away you go! You should skip the rest of the steps in this guide.
Now, install the window manager of your choice:
emerge -k gnomeOpen /etc/rc.conf in a text editor (e.g. nano or vim) and find the line:
#DISPLAYMANAGER="xdm"Add a new line right below it:
DISPLAYMANAGER="gdm"and save and exit the file.
emerge -k kdeOpen /etc/rc.conf in a text editor (e.g. nano or vim) and find the line:
#DISPLAYMANAGER="xdm"Add a new line right below it:
DISPLAYMANAGER="kdm"and save and exit the file.
To install the Mozilla web browser, enter:
emerge -k mozilla
Generate an XFree86 configuration file:
cd /etc/X11 XFree86 -configure mv ~/XF86Config.new ./XF86Config-4Open the newly created /etc/X11/XF86Config-4 file in the editor of your choice (e.g. nano or vim) and find the lines:
Section "Screen" Identifier "Screen0"Add a new line right beneath them:
DefaultDepth 16for 16 million colours, or:
DefaultDepth 24for 24 million colours.
Save the file and exit.
To have X start automatically on boot, enter:
rc-update add xdm default
To start XFree86, using either GNOME or KDE, enter:
/etc/init.d/xdm startIf all is well, you should be presented with a graphical login screen. Voila, you have installed Gentoo with XFree86!