Gentoo Logo

Gentoo Linux x86 with Software Raid and LVM2 Quick Install Guide


1.  Introduction

This guide contains all commands you should use to complete a stage3 installation including LVM2 on top of software RAID. This guide is targeted at experienced users. You need a connection to the Internet to download the stage3 and Portage snapshots.

Important: New users should read the Handbook as it gives a better overview about the installation process. The Quick Install guide is designed for experienced users who just need a checklist to follow.

Timing output follows all commands that take more than a couple of seconds to finish. Commands were timed on an AMD 2000 1.66 Ghz PC with 512 Mb of RAM and two SATA disks connected to a hardware controller configured as JBOD (i.e. two separate hard disks are seen by Gentoo). If you have a "hardware" RAID controller on your motherboard, it is most likely not a hardware controller.

Code Listing 1.1: Test box specs

(The following specs and the timing information should help you determine
a rough estimate of the time you need to complete your install)

# grep bogo /proc/cpuinfo
bogomips       : 3337.81

# hdparm -tT /dev/sda /dev/sdb
reads:   1048 MB in  2.00 seconds = 524.00 MB/sec
 Timing buffered disk reads:  152 MB in  3.01 seconds =  50.50 MB/sec

 Timing cached reads:   1048 MB in  2.00 seconds = 524.00 MB/sec
 Timing buffered disk reads:  152 MB in  3.01 seconds =  50.50 MB/sec

# grep MemTotal /proc/meminfo
MemTotal:       509248 kB

2.  Quick Install Guide

Installation Media

Download a CD from one of our mirrors. You can find the minimal CD ISO in releases/x86/current-iso/. The minimal installation CD is only useful for Internet-based installations. This guide will use the minimal CD.

Burn the CD and boot it.

Booting the CD

Press F2 at the boot screen to find out what boot options exist. You can either start gentoo or gentoo-nofb, the latter disables the framebuffer. If you booted the LiveCD, don't forget to add the nox option to prevent the X graphical environment from starting. Several options allow to enable or disable some features. If all goes well, your hardware will be detected and all modules will be loaded. If the kernel fails to boot properly or if your computer hangs during the boot procedure, you may have to experiment with different configurations. The safest way is probably to use the nodetect option and then load required modules explicitly.

Code Listing 2.1: Boot the minimal CD

Gentoo Linux Installation LiveCD           
Enter to Boot; F1 for kernels  F2 for options.
boot: gentoo-nofb
  (or in case of problems)
boot: gentoo-nofb nodetect

Optional: loading modules

If you used the nodetect option, once booted, load the required modules. You need to enable networking and have access to your disks. The lspci command can help you identify your hardware.

Code Listing 2.2: Load required modules

livecd root # lspci
(Use lspci's output to identify required modules)

(The following is an example, adapt it to your hardware)
livecd root # modprobe 3w-9xxx
livecd root # modprobe r8169

Network Configuration

If your network does not work already, you can use net-setup to configure your network. You might need to load support for your network card using modprobe prior to the configuration. If you have ADSL, use pppoe-setup and pppoe-start. For PPTP support, first edit /etc/ppp/chap-secrets and /etc/ppp/options.pptp and then use pptp <server ip>.

For wireless access, use iwconfig to set the wireless parameters and then use either net-setup again or run ifconfig, dhcpcd and/or route manually.

If you are behind a proxy, do not forget to initialize your system using export http_proxy, ftp_proxy and RSYNC_PROXY.

Code Listing 2.3: Configure networking the guided way

livecd root # net-setup eth0

Alternatively, you can start networking manually. The following example assigns the IP address to your PC and defines as your router and name server.

Code Listing 2.4: Configure networking the manual way

livecd root # ifconfig eth0
livecd root # route add default gw
livecd root # echo nameserver > /etc/resolv.conf

The installation CD allows you to start an sshd server, add additional users, run irssi (a command-line chat client) and surf the web using links.

Optional: connect to your new box over ssh

The most interesting feature is of course sshd. You can start it and then connect from another machine and cut and paste commands from this guide.

Code Listing 2.5: Start sshd

livecd root # time /etc/init.d/sshd start
 * Generating hostkey ...
(sshd generates the key and displays more output)
 * starting sshd ...                            [ok]

real   0m13.688s
user   0m9.420s
sys    0m0.090s

Now, set the root password on the liveCD so that you can connect to it from another PC. Please note that allowing root to connect over ssh is not recommended under normal circumstances. If you can't trust your local network, use a long and complex password, you should use it only once as it will disappear after your first reboot.

Code Listing 2.6: Set the root password

livecd root # passwd
New UNIX password: type_a_password
Retype new UNIX password: type_a_password
passwd: password updated successfully

Now, you can start a terminal on another PC and connect to your new box, follow the rest of this guide in another window, and cut and paste commands.

Code Listing 2.7: Connect to your new box from another PC

(Use the IP address of your new box)
$ ssh root@
The authenticity of host ' (' can't be established.
RSA key fingerprint is 96:e7:2d:12:ac:9c:b0:94:90:9f:40:89:b0:45:26:8f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
Password: type_the_password

Preparing the Disks

Load the software RAID and LVM2 modules.

Code Listing 2.8: Load RAID and LVM2 modules

livecd ~ # modprobe raid0
livecd ~ # modprobe raid1
(raid5, raid6 and raid10 are also available)

livecd ~ # modprobe dm-mod

Use fdisk or cfdisk to create your partition layout. The device names are likely to be either /dev/sda and /dev/sdb for a SATA or SCSI disks, or /dev/hda and /dev/hdb for IDE disks. The following layout will be used in this guide:

/dev/sda /dev/sdb Type
/dev/md1 /boot /boot Raid-1 (mirroring)
swap swap Normal partitions
/dev/md3 / / Raid-1 (mirroring)
/dev/md4 LVM2 volumes Raid-0 (striped)

Important: The partition you boot from must not be striped. It may not be raid-5 or raid-0.

Note: On the one hand, if you want extra stability, consider using raid-1 (or even raid-5) for your swap partition(s) so that a drive failure would not corrupt your swap space and crash applications that are using it. On the other hand, if you want extra performance, just let the kernel use distinct swap partitions as it does striping by default.

Code Listing 2.9: Create the partitions

livecd ~ # fdisk /dev/sda
(Make sure you use type fd and set the bootable flag)

(The rest of this guide uses the following partitioning scheme)
livecd ~ # fdisk -l /dev/sda

Disk /dev/sda: 299.9 GB, 299989204992 bytes
255 heads, 63 sectors/track, 36471 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          11       88326   fd  Linux raid autodetect
/dev/sda2              12          61      401625   82  Linux swap / Solaris
/dev/sda3              62         311     2008125   fd  Linux raid autodetect
/dev/sda4             312       36471   290455200   fd  Linux raid autodetect

(Partition the second disk exactly as the first)
livecd ~ # fdisk /dev/sdb

Then create the RAID device nodes and devices. Please bear in mind that, if you are not using an initramfs to help during boot (which is mandatory if you use a separate /usr partition as our example shows), the /boot and / mount points should use an older metadata format which can be specified by the --metadata=0.90 flag:

Code Listing 2.10: Create device nodes and devices

livecd ~ # mknod /dev/md1 b 9 1
livecd ~ # mknod /dev/md3 b 9 3
livecd ~ # mknod /dev/md4 b 9 4

livecd ~ # mdadm --create /dev/md1 --level=1 --raid-devices=2 --metadata=0.90 /dev/sda1 /dev/sdb1
mdadm: array /dev/md1 started.
livecd ~ # mdadm --create /dev/md3 --level=1 --raid-devices=2 --metadata=0.90 /dev/sda3 /dev/sdb3
mdadm: array /dev/md3 started.
livecd ~ # mdadm --create /dev/md4 --level=0 --raid-devices=2 /dev/sda4 /dev/sdb4
mdadm: array /dev/md4 started.

(Wait until all units are ready)
livecd ~ # cat /proc/mdstat
Personalities : [raid0] [raid1]
md4 : active raid0 sdb4[1] sda4[0]
581006592 blocks 64k chunks

md3 : active raid1 sdb3[1] sda3[0]
1959808 blocks [2/2] [UU]

md1 : active raid1 sdb1[1] sda1[0]
88256 blocks [2/2] [UU]

If you use an initramfs, then it is responsible for assembling the RAID arrays during boot. When using a genkernel initramfs, this can be triggered using the domdadm boot option.

Then create the LVM2 volumes in /dev/md4. The following scheme is used as an example:

Directory Size File system
/usr 8 GB ext3
/usr/portage 2 GB ext2, small block size, many inodes
/usr/portage/distfiles 4 GB ext2, large block size, less inodes
/home 10 GB ext3
/opt 4 GB ext3
/var 4 GB ext3
/var/tmp 6 GB ext2
/tmp 2 GB ext2

Code Listing 2.11: Create LVM2 volumes

livecd ~ # vgscan
  Reading all physical volumes.  This may take a while...
  No volume groups found
livecd ~ # vgchange -a y
  No volume groups found

(Create physical volumes, we have only one in our example)
livecd ~ # pvcreate /dev/md4
  Physical volume "/dev/md4" successfully created

(Create volume groups, again, we have only one in our example)
livecd ~ # vgcreate vg /dev/md4
  Volume group "vg" successfully created

(Create logical volumes)
livecd ~ # lvcreate -L8G -nusr vg
  /dev/cdrom: open failed: Read-only file system
  Logical volume "usr" created (Further similar messages not displayed)
livecd ~ # lvcreate -L2G -nportage vg
livecd ~ # lvcreate -L4G -ndistfiles vg
livecd ~ # lvcreate -L10G -nhome vg
livecd ~ # lvcreate -L4G -nopt vg
livecd ~ # lvcreate -L4G -nvar vg
livecd ~ # lvcreate -L6G -nvartmp vg
livecd ~ # lvcreate -L2G -ntmp vg

(Display volume groups and logical volumes)
livecd ~ # vgs
  VG   #PV #LV #SN Attr  VSize   VFree
  vg     1   8   0 wz--n 554.09G 514.09G
livecd ~ # lvs
  LV        VG   Attr   LSize  Origin Snap%  Move Copy%
  distfiles vg   -wi-a-  4.00G
  home      vg   -wi-a- 10.00G
  opt       vg   -wi-a-  4.00G
  portage   vg   -wi-a-  2.00G
  tmp       vg   -wi-a-  2.00G
  usr       vg   -wi-a-  8.00G
  var       vg   -wi-a-  4.00G
  vartmp    vg   -wi-a-  6.00G

Use mke2fs, mke2fs -j, mkreiserfs, mkfs.xfs and mkfs.jfs to create file systems. Initialize swap using mkswap and swapon.

Code Listing 2.12: Create the file systems and activate swap

(ext2 is all you need on the /boot partition)
livecd ~ # mke2fs /dev/md1

(Let's use ext3 on the root partition)
livecd ~ # mke2fs -j /dev/md3

(Create file systems on logical volumes)
livecd ~ # mke2fs -b 4096 -T largefile /dev/vg/distfiles
livecd ~ # mke2fs -j /dev/vg/home
livecd ~ # mke2fs -j /dev/vg/opt
livecd ~ # mke2fs -b 1024 -N 200000 /dev/vg/portage
livecd ~ # mke2fs /dev/vg/tmp
livecd ~ # mke2fs -j /dev/vg/usr
livecd ~ # mke2fs -j /dev/vg/var
livecd ~ # mke2fs /dev/vg/vartmp

(Create and activate swap)
livecd ~ # mkswap /dev/sda2 && mkswap /dev/sdb2
livecd ~ # swapon -p 1 /dev/sda2 && swapon -p 1 /dev/sdb2
(Check that all swap partitions use the same priority)
livecd ~ # swapon -v -s
Filename                   Type            Size    Used    Priority
/dev/sda2                  partition       401616  0       1
/dev/sdb2                  partition       401616  0       1

Mount the freshly created file systems on /mnt/gentoo. Create directories for the other mount points and mount them too.

Code Listing 2.13: Mount the file systems

livecd ~ # mount /dev/md3 /mnt/gentoo
livecd ~ # cd /mnt/gentoo
livecd gentoo # mkdir boot home usr opt var tmp
livecd gentoo # mount /dev/md1 /mnt/gentoo/boot
livecd gentoo # mount /dev/vg/usr /mnt/gentoo/usr
livecd gentoo # mount /dev/vg/home /mnt/gentoo/home
livecd gentoo # mount /dev/vg/opt /mnt/gentoo/opt
livecd gentoo # mount /dev/vg/tmp /mnt/gentoo/tmp
livecd gentoo # mount /dev/vg/var /mnt/gentoo/var
livecd gentoo # mkdir usr/portage var/tmp
livecd gentoo # mount /dev/vg/vartmp /mnt/gentoo/var/tmp
livecd gentoo # mount /dev/vg/portage /mnt/gentoo/usr/portage
livecd gentoo # mkdir usr/portage/distfiles
livecd gentoo # mount /dev/vg/distfiles /mnt/gentoo/usr/portage/distfiles

(Set proper perms on tmp directories)
livecd gentoo # chmod 1777 /mnt/gentoo/tmp /mnt/gentoo/var/tmp

Setting Up The Stage

First make sure your date and time is set correctly using date MMDDhhmmYYYY. Use UTC time.

Code Listing 2.14: Set the date and UTC time

(Check the clock)
livecd gentoo # date
Mon Mar  6 00:14:13 UTC 2006

(Set the current date and time if required)
livecd gentoo # date 030600162006 (Format is MMDDhhmmYYYY)
Mon Mar  6 00:16:00 UTC 2006

Next, download a stage from one of our mirrors:

Code Listing 2.15: Download a stage3 archive

livecd gentoo # links
(Pick a mirror, move to the releases/x86/current-stage3/ directory,
highlight the stage3 of your choice, probably the i686 stage3, and press D to
download it)

(Or download it directly with wget without choosing a nearby mirror)
livecd gentoo # wget*.tar.bz2

Go to /mnt/gentoo and unpack the stage using tar xjpf <stage3 tarball>.

Code Listing 2.16: Unpack the stage3 archive

livecd gentoo # time tar xjpf stage3*

real  1m14.157s
user  1m2.920s
sys   0m7.530s


Mount the /proc, /dev, and /sys file systems, copy over the /etc/resolv.conf file, then chroot into your Gentoo environment.

Code Listing 2.17: Chroot

livecd usr # cd /
livecd / # mount -t proc proc /mnt/gentoo/proc
livecd / # mount --rbind /dev /mnt/gentoo/dev
livecd / # mount --rbind /sys /mnt/gentoo/sys
livecd / # cp -L /etc/resolv.conf /mnt/gentoo/etc/ 
livecd / # chroot /mnt/gentoo /bin/bash
livecd / # source /etc/profile

Fetch the latest portage snapshot from the mirrors using emerge-webrsync.

Code Listing 2.18: Running emerge-webrsync to install a Portage snapshot

livecd / # mkdir /usr/portage
livecd / # emerge-webrsync

Set your time zone

Set your time zone information by using the correct listing in /usr/share/zoneinfo.

Code Listing 2.19: Setting your timezone

livecd / # ls /usr/share/zoneinfo
(Using Brussels as an example)
livecd / # cp /usr/share/zoneinfo/Europe/Brussels /etc/localtime
livecd / # echo "Europe/Brussels" > /etc/timezone

livecd / # date
Wed Mar  8 00:46:05 CET 2006

Select your profile

Choose your profile using eselect. This is an example of the output you might see.

Code Listing 2.20: Verifying System Profile

livecd / # eselect profile list
Available profile symlink targets:
  [1]    default/linux/x86/13.0 *
  [2]    default/linux/x86/13.0/desktop
  [3]    default/linux/x86/13.0/desktop/gnome
  [4]    default/linux/x86/13.0/desktop/kde
  [5]    default/linux/x86/13.0/server

Choose the appropriate profile. Keep in mind that default USE flags are determined based on the profile you pick.

Code Listing 2.21: Changing Profile

livecd / # eselect profile set 2

Set your host name and domain name

Set your host name in /etc/conf.d/hostname and /etc/hosts. In the following example, we use mybox as host name and at.myplace as domain name. You can either edit the config files with nano or use the following commands:

Code Listing 2.22: Set host and domain name

livecd / # cd /etc
livecd etc # echo " mybox localhost" > hosts
livecd etc # sed -i -e 's/hostname.*/hostname="mybox"/' conf.d/hostname
(Use defined host name and check)
livecd etc # hostname mybox
livecd etc # hostname -f

Kernel Configuration

Install a kernel source (usually gentoo-sources), configure it, compile it and copy the arch/i386/boot/bzImage file to /boot.

Code Listing 2.23: Install a kernel source, compile it and install the kernel

livecd etc # time emerge gentoo-sources

real  3m3.110s
user  1m2.320s
sys   0m34.990s
livecd etc # cd /usr/src/linux
livecd linux # make menuconfig

(Configure your kernel as usual and make sure the raid and lvm modules you need are
compiled in, i.e. not as modules. The same applies to the disk drivers and filesystems.)
Multi-device support (RAID and LVM)  --->
[*] Multiple devices driver support (RAID and LVM)
  <*>   RAID support
  < >     Linear (append) mode (NEW)
  <*>     RAID-0 (striping) mode
  <*>     RAID-1 (mirroring) mode
  < >     RAID-10 (mirrored striping) mode (EXPERIMENTAL) (NEW)
  < >     RAID-4/RAID-5 mode (NEW)
  < >     RAID-6 mode (NEW)
  < >     Multipath I/O support (NEW)
  < >     Faulty test module for MD (NEW)
  <*>   Device mapper support
  < >     Crypt target support (NEW)
  < >     Snapshot target (EXPERIMENTAL) (NEW)
  < >     Mirror target (EXPERIMENTAL) (NEW)
  < >     Zero target (EXPERIMENTAL) (NEW)
  < >     Multipath target (EXPERIMENTAL) (NEW)
  < >     Bad Block Relocation Device Target (EXPERIMENTAL) (NEW)

livecd linux # time make -j2

(Elapsed time depends highly on the options you selected)
real  5m5.869s
user  4m32.320s
sys   0m32.930s

livecd linux # make modules_install
livecd linux # cp arch/i386/boot/bzImage /boot/kernel

Next build an initramfs to boot the system with.

Code Listing 2.24: Building an initramfs

# emerge genkernel
# genkernel --install --no-ramdisk-modules --lvm --mdadm initramfs

Configure the system

Edit your /etc/fstab and replace BOOT, ROOT and SWAP with the actual partition names and add your logical volumes. Don't forget to check that the file systems match your installation.

Code Listing 2.25: Example fstab

livecd linux # cd /etc
livecd etc # nano -w fstab
/dev/md1          /boot                   ext2  noauto,noatime  1 2
/dev/md3          /                       ext3  noatime         0 1
/dev/sda2         none                    swap  sw,pri=1        0 0
/dev/sdb2         none                    swap  sw,pri=1        0 0
/dev/vg/usr       /usr                    ext3  noatime         1 2
/dev/vg/portage   /usr/portage            ext2  noatime         1 2
/dev/vg/distfiles /usr/portage/distfiles  ext2  noatime         1 2
/dev/vg/home      /home                   ext3  noatime         1 2
/dev/vg/opt       /opt                    ext3  noatime         1 2
/dev/vg/tmp       /tmp                    ext2  noatime         1 2
/dev/vg/var       /var                    ext3  noatime         1 2
/dev/vg/vartmp    /var/tmp                ext2  noatime         1 2

Configure your network in /etc/conf.d/net. Add the net.eth0 init script to the default run level. If you have multiple NICs, symlink them to the net.lo init script and add them to the default run level as well. Don't forget to set your hostname too. Either edit /etc/conf.d/net and /etc/conf.d/hostname with nano or use the following commands:

Code Listing 2.26: Configure networking

livecd etc # cd init.d
livecd init.d # ln -s net.lo net.eth0
livecd init.d # cd ../conf.d
livecd conf.d # echo 'config_eth0=" netmask brd"' >> net
livecd conf.d # echo 'routes_eth0="default via"' >> net
livecd conf.d # echo 'hostname="myhostname"' > hostname
livecd conf.d # rc-update add net.eth0 default
(If you compiled your network card driver as a module, add it to /etc/conf.d/modules
livecd conf.d # echo 'modules="r8169"' >> /etc/conf.d/modules
(If you want to reconnect via ssh after you have rebooted your new box)
livecd conf.d # rc-update add sshd default

Note: Emerge pcmciautils if you need support for PCMCIA cards.

Set the root password using passwd.

Code Listing 2.27: Set the root password

livecd conf.d # passwd
New UNIX password: type_the_password
Retype new UNIX password: type_the_password_again
passwd: password updated successfully

Edit /etc/conf.d/hwclock to set clock options.

Code Listing 2.28: Edit /etc/conf.d/hwclock

livecd # nano -w /etc/conf.d/hwclock

Check the system configuration in /etc/rc.conf and /etc/conf.d/keymaps and edit any of those files if required.

Code Listing 2.29: Optional: edit some config files

livecd conf.d # nano -w /etc/rc.conf
livecd conf.d # nano -w /etc/conf.d/keymaps

Installing System Tools

Install RAID and LVM2 utilities.

Code Listing 2.30: Install RAID & LVM2 tools

livecd conf.d # emerge mdadm lvm2
livecd conf.d # rc-update add mdraid boot
livecd conf.d # rc-update add lvm boot

Install a system logger like syslog-ng and a cron daemon like vixie-cron, and add them to the default run level.

Note: Cron daemons depend on an MTA. mail-mta/ssmtp will be pulled in as a dependency. If you want to use a more advanced MTA, you might want to install it now. If you are in a hurry, let ssmtp be installed and remove it later when you install the MTA of your choice.

Code Listing 2.31: Install a syslogger and a cron daemon

livecd conf.d # time emerge syslog-ng vixie-cron

real  1m54.099s
user  1m2.630s
sys   0m34.620s
livecd conf.d # rc-update add syslog-ng default
livecd conf.d # rc-update add vixie-cron default

Install the necessary file system tools (xfsprogs, reiserfsprogs or jfsutils) and networking tools (dhcpcd or ppp) if you need any.

Code Listing 2.32: Install extra tools if required

livecd conf.d # emerge xfsprogs       (If you use the XFS file system)
livecd conf.d # emerge jfsutils       (If you use the JFS file system)
livecd conf.d # emerge reiserfsprogs  (If you use the Reiser file system)
livecd conf.d # emerge dhcpcd         (If you need a DHCP client)
livecd conf.d # emerge ppp            (If you need PPPoE ADSL connectivity)

Configuring the Bootloader

Emerge grub and configure it. Do not forget to update the necessary boot parameters if you are using an initramfs.

Code Listing 2.33: Emerge grub and edit its configuration file

livecd conf.d # time emerge grub

real  1m4.634s
user  0m39.460s
sys   0m15.280s
livecd conf.d # nano -w /boot/grub/grub.conf

Code Listing 2.34: Example grub.conf

default 0
timeout 10

title Gentoo
root (hd0,0)
kernel /boot/kernel root=/dev/md3
initrd /boot/initramfs # Only when initramfs is needed like with separate /usr partition

Code Listing 2.35: Install grub on both disks

livecd conf.d # grub
Probing devices to guess BIOS drives. This may take a long time.

grub> root (hd0,0)
 Filesystem type is ext2fs, partition type 0xfd

grub> setup (hd0)
 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.
 Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 /boot/
grub/menu.lst"... succeeded

grub> root (hd1,0)
 Filesystem type is ext2fs, partition type 0xfd

grub> setup (hd1)

grub> quit


Exit the chrooted environment, unmount all file systems and reboot:

Code Listing 2.36: Reboot

livecd conf.d # exit
livecd / # umount -l /mnt/gentoo/usr{/portage/distfiles,/portage,}
livecd / # umount -l /mnt/gentoo/dev{/pts,/shm,}
livecd / # umount -l /mnt/gentoo{/usr,/var/tmp,/tmp,/var,/opt,/dev,/proc,/home,/boot,}
livecd / # reboot
(Don't forget to remove the CD)

Finalizing the Installation

Note: The total elapsed time between the display of the boot prompt on the minimal CD and the display of the login prompt after the reboot was 00:42:31 on our test box. Yes, less than one hour! Note that this time also includes the stage3, Portage snapshot and several packages download time and the time spent configuring the kernel.

Log in as root, then add one or more users for daily use with useradd.

Code Listing 2.37: Connect to your new box from another PC

(Clean up your known_hosts file because your new box
has generated a new definitive hostkey)
$ nano -w ~/.ssh/known_hosts
(Look for the IP of your new PC and delete the line,
then save the file and exit nano)

(Use the IP address of your new box)
$ ssh root@
The authenticity of host ' (' can't be established.
RSA key fingerprint is 96:e7:2d:12:ac:9c:b0:94:90:9f:40:89:b0:45:26:8f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
Password: type_the_password

Code Listing 2.38: Add a new user

mybox ~ # useradd -g users -G lp,wheel,audio,cdrom,portage,cron -m john
mybox ~ # passwd john
New UNIX password: Set John's password
Retype new UNIX password: Type John's password again
passwd: password updated successfully

Last configuration touches

Start by selecting nearby mirrors either by defining the SYNC and GENTOO_MIRRORS variables in /etc/portage/make.conf or by using mirrorselect. You can also define the number of concurrent compilation processes at this point.

Code Listing 2.39: Use mirrorselect and set MAKEOPTS

mybox ~ # emerge mirrorselect
mybox ~ # mirrorselect -i -o >> /etc/portage/make.conf
mybox ~ # mirrorselect -i -r -o >> /etc/portage/make.conf
(Usually, (the number of processors + 1) is a good value)
mybox ~ # echo 'MAKEOPTS="-j2"' >> /etc/portage/make.conf

Now is a good time to enable or disable some USE flags. Run emerge -vpe world to list all currently installed packages and their enabled and disabled USE flags. Either edit /etc/portage/make.conf or use the following command to define the USE variable:

Code Listing 2.40: View USE flags in use and enable or disable some

mybox ~ # emerge -vpe world
(Portage displays the packages and their USE flags, as an example, let's
disable fortran, and enable ipv6 and unicode)
mybox ~ # echo 'USE="nptl nptlonly ipv6 -fortran unicode"' >> /etc/portage/make.conf

Recent versions of glibc use /etc/locale.gen to define locale settings.

Code Listing 2.41: Define locales

mybox ~ # cd /etc
mybox etc # nano -w locale.gen
mybox etc # locale-gen

Last but not least, you may want to alter the CFLAGS variable in your /etc/portage/make.conf to optimise the code to your specific needs. Please note that using a long list of flags is rarely needed and can even lead to a broken system. It is recommended to specify the processor type in the march option and stick to -O2 -pipe.

You may also want to switch to ~x86. You should only do this if you can deal with the odd broken ebuild or package. If you'd rather keep your system stable, don't add the ACCEPT_KEYWORDS variable.

Code Listing 2.42: Last edit of make.conf

mybox etc # cd portage
mybox portage # nano -w make.conf
(Set -march to your CPU type in CFLAGS)
CFLAGS="-O2 -march=athlon-xp -pipe"
(Only add the following if you know what you're doing)

You might want to recompile your whole system twice to make full use of your latest configuration changes. It would take quite a long time to complete and yield minimal speed benefits. You can let your system optimise itself gradually over time when new versions of packages are released. However, recompiling is a still good idea from the standpoint of maintaining system consistency. Please see the Gentoo GCC Upgrading Guide for a discussion on the benefits of ensuring a consistently built system and world.

Recompiling only the packages that have already been updated since the release or that are affected by your new USE flags will take enough time. You might also have to remove packages that block your upgrade. Look for "[blocks B ]" in the output of emerge -vpuD --newuse world and use emerge -C to remove them.

Code Listing 2.43: Update your packages

(Please note that the switch to ~x86 causes many packages to be upgraded)
mybox etc # emerge -vpuD --newuse world
(Take a good look at the package list and their USE flags,
remove blocking packages if any, and start the lengthy process)
mybox etc # time emerge -vuD --newuse world
(79 packages have been (re)compiled)

real  180m13.276s
user  121m22.905s
sys   36m31.472s

(Remerge libtool to avoid further potential problems)
mybox etc # emerge --oneshot libtool

(Update config files, make sure you do not let dispatch-conf
update config files you have edited)
mybox etc # dispatch-conf

(If perl has been updated, you should run the perl-cleaner script)
mybox etc # time perl-cleaner all
real  1m6.495s
user  0m42.699s
sys   0m10.641s

(In case of a major upgrade of python, you should run the python-updater script)
mybox etc # python-updater

What to do next

Depending on what your new Gentoo machine is supposed to do, you will probably want to install server applications or a desktop system. Just as an example, emerge gnome and emerge kde have been timed on the ~x86 system installed as describe above. Both have been installed from the same starting point.

You should check our documentation index to find out how to install and configure the applications of your choice.

Important: The following is only an example. It is in no way meant as a recommended setup.

Code Listing 2.44: Emerge GNOME

mybox etc # emerge -vp gnome
(Look at the list of packages and their USE flags,
then edit make.conf if required.
mybox etc # nano -w /etc/portage/make.conf
(The following USE flags have been defined)
USE="-fortran dbus -kde -qt4 -eds "

mybox etc # time emerge gnome
(326 packages have been emerged)

real  520m44.532s
user  339m21.144s
sys   146m22.337s

Code Listing 2.45: Emerge KDE

mybox etc # emerge -vp kde-meta
(Look at the list of packages and their USE flags,
then edit make.conf if required.
mybox etc # nano -w /etc/portage/make.conf
The following USE flags have been defined)
USE="-fortran -eds -gnome -gstreamer -gtk -firefox"

mybox etc # time emerge kde-meta
(391 packages have been emerged)

real  1171m25.318s
user  851m26.393s
sys   281m45.629s


Page updated August 15, 2013

Summary: The Quick Install guide covers the Gentoo install process in a non-verbose manner. Its purpose is to allow users to perform a stage3 install with software RAID and LVM2 in no time. Users should already have prior experience with installing Gentoo Linux if they want to follow this guide.

Xavier Neys

Sven Vermeulen

Steven Wagner

Donate to support our development efforts.

Copyright 2001-2015 Gentoo Foundation, Inc. Questions, Comments? Contact us.