HOWTO Install Gentoo Quick Reference
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
Contents |
[edit] Introduction
After installing Gentoo on many systems, using the Gentoo Linux x86 Handbook can get a little annoying. It's an excellent document, especially for beginners, but it's a little outdated in some places, and gets side-tracked a little in other places. Also, it consists of many pages and is hard to read in a text-only browser which may be all you have while you're installing.
This Wiki page attempts to bypass all the fluff that's in other installation documentation. It's meant for people who've seen and done Gentoo installs before (possibly many times), who probably just want a quick reference on one page that they can keep open in Links on a second virtual terminal while installing. Needless to say, Do not use this page if you've never installed Gentoo before or if you have little experience with Linux. The page pretty much assumes that you know what you're doing; if something goes wrong, you're on your own.
[edit] Overview
This guide concentrates on getting your system up and running with as little effort as possible; we will install a minimum amount of tools before we reboot from the harddisk (and we'll stop there!).
This is what we'll do:
- Boot from a Gentoo CD-ROM
- Partition and format the hard disk
- Download and unpack the latest Stage3 tarball and a Portage snapshot
- Chroot to the harddisk
- Edit essential configuration files
- Compile kernel (genkernel)
- Install boot loader (grub)
- Download essential tools and updates and edit their configuration files
- Reboot
[edit] Booting the System, Initializing and Mounting the Harddisk
Boot from a Gentoo CD-ROM. Pretty much any version that runs a 2.6 kernel will do (if you try to use a 2.4 kernel, the chroot will fail). ISO files for the latest minimal Gentoo CD-ROM should be available from:
http://<your-mirror>/releases/x86/current/installcd/
After booting, set your system's time using date MMDDhhmmYYYY; keep in mind that at this time the system thinks your hardware clock is UTC and you will have to correct for that. For example if you're in central Europe, you may have to set your clock back by one hour (two hours in the summer), if you're in the USA on the West coast you will have to set it ahead by 8 hours (7 hours in the summer). If your forget to change the time at this point, you will run into minor problems after rebooting for the next day or so (e.g. at boot time the computer may think your file system's last modified time is in the future and will give you a warning about it).
Use something like fdisk /dev/hda to partition the harddisk. The common Gentoo partitioning scheme is as follows:
- Partition 1: boot partition, 16MB should be plenty for Grub, and probably two kernels plus ramfs images. Don't forget to activate this partition.
- Partition 2: swap partition, size between 0.5 and 1.0 times your memory size. Don't forget to set the type to 82.
- Partition 3: root partition, usually the rest of the disk.
Initialize the file systems:
- mke2fs /dev/hda1
- mkswap /dev/hda2
- mke2fs -j /dev/hda3
Activate the swap partition:
- swapon /dev/hda2
Mount the other partitions:
- mount /dev/hda3 /mnt/gentoo
- cd /mnt/gentoo
- mkdir boot
- mount /dev/hda1 boot
Your current directory is /mnt/gentoo.
[edit] Download and Unpack Gentoo and Portage, Chroot
Downloading and unpacking (in /mnt/gentoo):
- wget http://<your-mirror>/{\
releases/x86/current/stages/stage3-i686-2006.1.tar.bz2,\
snapshots/portage-latest.tar.bz2} - I leave it to you to check the downloaded files using md5sum
- tar xfvjp sta*
- tar xfvj por* -C usr
Chroot-ing into your snapshot
- cp /etc/resolv.conf etc otherwise you won't be able to use the network from the chroot
- mount -t proc none proc
- mount -o bind /dev dev
- chroot .
- env-update
- source /etc/profile
- ln -sf /usr/share/zoneinfo/<your-timezone> /etc/localtime
- date to see your date/time, followed by date MMDDhhmmYYYY if necessary.
[edit] Edit Configuration Files
Still in the chroot:
| File: /etc/make.conf |
# Add: (note, set number in MAKEOPTS to number of processors # or cores or hyperthreads + 1) MAKEOPTS="-j2" GENTOO_MIRRORS="http://<your-mirror>" # Following USE flags are just an example USE="-X -ipv6 -nls -fortran acpi" |
| File: /etc/fstab |
# Change /dev/BOOT to /dev/hda1 (or whatever) # Change /dev/SWAP to /dev/hda2 (or whatever) # Change /dev/ROOT to /dev/hda3 (or whatever) |
| File: /etc/conf.d/hostname |
# Change host name to desired hostname |
| File: /etc/conf.d/net |
# (Modify if necessary; if you're using DHCP you probably don't have to) |
| File: /etc/hosts |
# Insert your hostname (as entered in /etc/conf.d/hostname) # between "127.0.0.1" and "localhost" |
| File: /etc/conf.d/clock |
# Modify the following to taste: CLOCK="local" CLOCK_SYSTOHC="yes" # Add (for recent baselayout versions): TIMEZONE="<your-timezone>" |
[edit] Build the Kernel
For quick setups, Genkernel is the perfect solution. It takes longer to build but it takes almost no time to configure and it works on a wide variety of hardware.
While still in the chroot, do:
- USE="-doc symlink" emerge gentoo-sources
- emerge genkernel
- zcat /proc/config.gz >/usr/share/genkernel/x86/kernel-config-2.6
- genkernel all This will take about 30 minutes on a Pentium4 at 2.4GHz.
[edit] Install Grub
Install Grub:
- emerge grub
- grub and enter the following commands:
root (hd0,0) setup (hd0) quit
- echo kernel /boot/kernel* real_root=/dev/hda3 >> /boot/grub/menu.lst
- echo initrd /boot/initramfs-genkernel* >> /boot/grub/menu.lst
Just to get started (easier than switching back and forth between two terminals to get the kernel and initramfs filenames right)
After editing, the menu.lst file should similar to this (modify to taste):
| File: /boot/grub/menu.lst |
default 0 timeout 5 title Gentoo 2.6.20-r7 kernel /boot/kernel-genkernel-2.6.20-gentoo-r7 real_root=/dev/hda3 initrd /boot/initramfs-genkernel-2.6.20-gentoo-r7 |
[edit] Install Other System Tools
[edit] System logger
You can leave this out if you want to finish the setup really quickly, but I like to install it in case something goes wrong at first boot.
- emerge syslog-ng or one of the other sysloggers
- rc-update add syslog-ng default
It's probably also a good idea to use logrotate so your drive won't fill up:
- emerge logrotate
Logrotate is started as a cron job so we need a cron daemon:
- emerge vixie-cron or another cron if you prefer
- rc-update add vixie-cron default
The default settings of the above tools are fine as they are, in most cases.
[edit] DHCP client
Forgetting to download a DHCP client if you need one is going to cost you a lot of extra time because you will have a chicken-and-egg problem after you reboot your machine: you can't bring up the network because you don't have DHCP and you can't download DHCP because you don't have a network...
- emerge dhcpcd Don't forget the 2nd 'c' in dhcpcd.
[edit] Finally
Set the root password: passwd
[edit] Reboot
Still in the chroot:
- exit Leave the chroot
- cd /;umount /mnt/gentoo/{boot,dev,proc,};reboot
[edit] Now What?
After this, you should be able to run your minimal Stage3 install from harddisk without help from a CD-ROM. Some suggestions on what to do next:
