Main Page Computing Hobbies Fun About

Installing Gentoo Linux

Category: Computing Keywords: GentooLinuxguide Share on Google+ Share on Facebook Share on Twitter Share on Digg

This is mainly a guide for myself, but if you want to install it in a similar way, you may also find it useful. It assumes you have some experience with Gentoo or at least Linux. I'm including some extra explanations and comments to make it easier for others to understand.

It is currently a work in progress, I don't recommend relying on it yet, but you can at least use it as an overview. You probably want to follow the Gentoo handbook instead, especially if you're a beginner.

  1. Get and boot the cd

    Gentoo Linux doesn't really have versions. It is being updated continuously, and no matter what you use to install it, you can always upgrade it. First, if you don't have an installation cd, get it from ("Get Gentoo!"). Use amd64 if you have a recent pc, x86 for older ones. Currently the installation files are provided through the "autobuilds" system and updated very frequently. Get the "minimal" iso and the stage3 archive. My mirror:

    Now, boot the cd, and check if you're connected to the network. If not, check the network interface. If that's missing, check the network card (lspci) and load the appropriate module if you can find it. If everything fails, you'll need to do a network-less installation. It is very helpful to have a USB drive and another computer available.

    If you are connected, you can actually start an SSH server and connect from another computer, so you can copy and paste things easily.

    /etc/init.d/sshd start
  2. Set up and mount the partitions

    I usually use 2 main partitions: root and swap. Refer to the Gentoo handbook if you want a separate boot partition, I don't like partition pollution. cfdisk is nice and convenient for partitioning, but in some cases you may need to use fdisk. Partition type 83 is for root (or FD if you use RAID), 82 is for swap.

    Then format and mount the partitions (replace the devices/file systems with the ones you are using):

    mkfs.ext3 /dev/sda1
    mkswap /dev/sda2
    swapon /dev/sda2
    mount /dev/sda1 /mnt/gentoo
    cd /mnt/gentoo
    mkdir boot
  3. Install the system files

    First, check and correct the system date, in UTC time. The format is: MMDDhhmmYYYY (month date hour minute year).

    date 061315002009

    Then put your stage3 archive (the main system files), which you downloaded earlier, in /mnt/gentoo. Also get a portage snapshot (the database of available packages), from (replace with your preferred mirror).

    Extract the archives (in /mnt/gentoo):

    tar xvjpf stage3-<tab>
    unlzma portage-<tab>
    tar xvf portage-<tab> -C usr

    If you have another computer already running Gentoo, it is convenient to copy over the /usr/portage/distfiles folder (perhaps using a usb drive).

  4. Enter into the new environment

    If you're online, copy the DNS info:

    cp -L /etc/resolv.conf etc/

    Mount proc and dev:

    mount -t proc none proc
    mount -o bind /dev dev

    Then chroot:

    chroot . /bin/bash
    . /etc/profile
    export PS1="(chroot) $PS1"
  5. Configure some system options

    Edit make.conf:

    nano /etc/make.conf

    Here's what I use:

    CFLAGS="-O2 -pipe -march=native"

    Adjust as appropriate for your system. You can also set up the USE variable, or leave it for later.

  6. Set the timezone and system clock

    List the timezones and copy the correct one

    ls /usr/share/zoneinfo
    cp /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime

    Edit the clock settings

    nano /etc/conf.d/clock

    Set the CLOCK and TIMEZONE options, e.g.


    Now check the date and fix it if it's wrong (it should be in your timezone now)

    date 061315002009

    Save the date and time to the hardware clock, otherwise it may be wrong when you reboot.

    hwclock --systohc
  7. Build the Linux kernel

    Very quick guide for "emerge": emerge is the tool used for installing packages from portage. "emerge -av foo" installs a package called "foo". "-a" means "ask before continuing" and "-v" is for "verbose". "emerge -s foo" searches for all the packages containing "foo" in the name and displays some basic information. For more details, "man emerge".

    Install the kernel files

    emerge -av gentoo-sources

    Configure the kernel

    cd /usr/src/linux
    make menuconfig

    Most important things are: "Processor type and features", "Device Drivers" -> "Network device support" (check the network card with lspci and/or ethtool -i, in a separate terminal) and "File systems". I generally don't use modules, but compile everything into the kernel. Drivers required for booting will only work that way.

    Compile the kernel

    make modules_install
  8. Configure the system

    Define partitions and file systems to mount

    nano /etc/fstab

    Delete or comment out the boot line (assuming you don't have a separate boot partition); replace ROOT and SWAP with the appropriate devices. You can also comment out the cdrom line if you plan to mount cds automatically in KDE.

    Edit the hostname and hosts file

    nano /etc/conf.d/hostname
    nano /etc/hosts

    Configure the network. If you just use DHCP, you don't need to do anything. Otherwise:

    nano /etc/conf.d/net

    Example static configuration:

    routes_eth0=("default via")

    Connect to the network automatically

    rc-update add net.eth0 default

    Set the root password


    Edit other system options

    nano /etc/rc.conf
    nano /etc/conf.d/rc
    nano /etc/conf.d/keymaps
  9. Install system services and tools

    System log

    emerge -av syslog-ng
    rc-update add syslog-ng default

    Task scheduler

    emerge -av vixie-cron
    rc-update add vixie-cron default

    DHCP client (if you need it)

    emerge -av dhcpcd

    Start the SSH server automatically

    rc-update add sshd default

    Other packages I would install immediately: pciutils, gentoolkit, eix, bind-tools, mtr, telnet-bsd, zsh, zsh-completion, logrotate, ntp, mlocate

  10. Set up the boot loader

    Install GRUB

    emerge -av grub

    Configure GRUB

    nano /boot/grub/grub.conf

    GRUB uses a different way to address devices. Generally, sda becomes (hd0), sdb becomes (hd1), sda1 becomes (hd0,0), sdb3 becomes (hd1,2) etc. Here is a sample configuration:

    default 0
    timeout 10
    title Gentoo Linux
    root (hd0,0)
    kernel /boot/kernel root=/dev/sda1
    # if you dual-boot with windoze
    title windows
    rootnoverify (hd1,0)
    chainloader +1

    Install GRUB into the master boot record. You can do it automatically:

    grep -v rootfs /proc/mounts|grep -v boot > /etc/mtab
    grub-install /dev/sda

    Or manually:

    root (hd0,0)
    setup (hd0)

    Install the kernel. Update: since "make install" doesn't work the way it used to anymore, I decided to stop using it and write two scripts instead:


    cp /usr/src/linux/arch/x86/boot/bzImage /boot/
    cp /usr/src/linux/.config /boot/
    cp /usr/src/linux/ /boot/


    cp /boot/ /boot/kernel
    cp /boot/ /boot/config
    cp /boot/ /boot/

    Run "newkernel" after compiling a new kernel, and "stablekernel" after booting it and verifying that it works. This needs another entry in grub.conf:

    title Gentoo Linux - new
    root (hd0,0)
    kernel /boot/ root=/dev/sda1
  11. Reboot

    You could probably just run "reboot", but it's better to tidy up first.

    umount /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo

    If everything is ok, you should be able to boot your new Gentoo system.

Created on 13 Jun 2009, last updated on 29 Nov 2010 Valid HTML5


aditsu's avatar


12 Nov 2010

The mirror has moved to a different connection which unfortunately blocks incoming port 80.
The mirror can currently be accessed on port 8000. I've updated the urls in the article.

MeaCulpa's avatar

Everything Gentoo provide is cool except boot CD

23 Oct 2009

Use Sabayon or SystemrescueCD or any Linux live instead :)

aditsu's avatar

Re: Everything Gentoo provide is cool except boot CD

27 Oct 2009

Those live cds are ok if you want to use Linux occasionally or for specific purposes, but for installing Gentoo Linux as a main OS on the computer, I probably wouldn't trust anything else than the manual installation, especially if I want to use a custom partition setup, or RAID.
Haven't tried Sabayon though.

jazzi's avatar

Good Guider

20 Oct 2009

This is a more simple manual than Gentoo handbook for instlling. The most diffculty part of installation I think is compiling the kernel. if you would live a thin kernel. you'll need use lspci -k to see what kind of modules are used and lspci -nn to get the specific info about your hardware.
I choose Gentoo and FVWM-crystal as my desktop envirenment.



Add a comment

Your name:Email address:
(will not be displayed)
Note: your comment will be reviewed, and displayed later if approved.
If you see this box, please leave it empty:
Your name:Email address:
(will not be displayed)
Note: your comment will be reviewed, and displayed later if approved.
If you see this box, please leave it empty: