Main Page Computing Misc About

Installing Gentoo Linux

Category: Computing Keywords: GentooLinux

This is mainly a guide for myself, but if you want to install it in a similar way, you may also find it useful. 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 www.gentoo.org ("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.

    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. passwd /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 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 http://gentoo.aditsu.net/snapshots/portage-latest.tar.lzma (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 env-update . /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=nocona" CXXFLAGS="${CFLAGS}" CHOST="x86_64-pc-linux-gnu" MAKEOPTS="-j3" GENTOO_MIRRORS="http://gentoo.aditsu.net/ http://ftp.jaist.ac.jp/pub/Linux/Gentoo/" Adjust as appropriate for your system. If you already have gcc 4.3, use -march=native. 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. CLOCK="UTC" TIMEZONE="Asia/Hong_Kong"

    Now check the date and fix it if it's wrong (it should be in your timezone now) date 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 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: config_eth0=("192.168.1.2/24") routes_eth0=("default via 192.168.1.1") dns_servers_eth0=("218.102.62.71 203.198.23.208")

    Connect to the network automatically rc-update add net.eth0 default

    Set the root password passwd

    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, flagedit, eix, bind-tools, traceroute, telnet-bsd, zsh, zsh-completion

  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 splashimage=(hd0,0)/boot/grub/splash.xpm.gz title Gentoo Linux root (hd0,0) kernel /boot/kernel root=/dev/sda1 # if you dual-boot with windoze title windows rootnoverify (hd1,0) makeactive 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: grub root (hd0,0) setup (hd0) quit

    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:

    newkernel: cp /usr/src/linux/arch/x86/boot/bzImage /boot/kernel.new cp /usr/src/linux/.config /boot/config.new cp /usr/src/linux/System.map /boot/System.map.new

    stablekernel: cp /boot/kernel.new /boot/kernel cp /boot/config.new /boot/config cp /boot/System.map.new /boot/System.map

    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/kernel.new root=/dev/sda1

  11. Reboot

    You could probably just run "reboot", but it's better to tidy up first. <ctrl>-d cd umount /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo reboot

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

Created on 13 Jun 2009, last updated on 12 Sep 2009 Valid HTML 4.01

Comments:

Everything Gentoo provide is cool except boot CD

From MeaCulpa on 23 Oct 2009

Use Sabayon or SystemrescueCD or any Linux live instead :)

Reply

Re: Everything Gentoo provide is cool except boot CD

From aditsu on 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.

Reply

Good Guider

From jazzi on 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.

jazzi

Reply

Add a comment

Your name:Email address:
(will not be displayed)
Title:
Comment:
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)
Title:
Comment:
Note: your comment will be reviewed, and displayed later if approved.
If you see this box, please leave it empty: