Gentoo Wiki


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc


Base Install

  1. What is Gentoo?
  2. About
  3. Preparation
  4. Partitioning
  5. Configuring
  6. Stage Progression
  7. Kernel
  8. Bootloader
  9. Test
  10. Converting from or to a non-Gentoo distribution
  11. Troubleshooting
  12. Maintaining


Base Extras



Other Articles


>> WARNING << This page is very out dated!

Building Your System

Code: stage0
 cd /mnt/gentoo/
 wget ${MIRROR_0}/releases/x86/current/stages/x86/stage1-x86-2005.0.tar.bz2
 wget ${MIRROR_0}/releases/x86/current/stages/x86/stage1-x86-2005.0.tar.bz2.md5
 md5sum -c stage1-x86-2005.0.tar.bz2.md5 && tar -xjpf stage1-x86-2005.0.tar.bz2 -C /mnt/gentoo/
 mv stage1-x86-2005.0.tar.bz2 /mnt/gentoo/root/ # for safe keeping
 wget ${MIRROR_0}$/snapshots/portage-YYYYMMDD.tar.bz2
 wget ${MIRROR_0}$/snapshots/portage-YYYYMMDD.tar.bz2.md5sum
 md5sum -c portage-YYYYMMDD.tar.bz2.md5 && tar -xjpf portage-YYYYMMDD.tar.bz2 -C /mnt/gentoo/usr
 mirrorselect -s4 -o | grep 'GENTOO_MIRRORS=' >> /mnt/gentoo/etc/make.conf

Optimizing with make.conf

I did some research on optimizations so that I can do this decently as possible. I started a thread in the Gentoo Forums where I listed some of my documentation sources and got some feedback on how get the most out of my system.

As it turns out (and this is coming from a devout gentoo user), optimizations aren't all they're cracked up to be!

Concerning CFLAGS, specifying -O3 isn't certain to do anything that -O2 doesn't except take more time and possibly increase binary size. Although this may improve performance in CPU load for apps like apache2 and mysql on a hard-core server, it will probably slow down an average desktop system considerably due to the extra time needed to load binaries. I read that big optimizations can increase binary size by 30%. That's a lot of wasted RAM if you ask me. I've only got a gig! On average, I don't think it's a big deal if your browser uses 10% of your CPU to load a page when it only needs 9%, were it 'optimized correctly'. But if it loads 30% faster, that's noticeable! Personally, I have plans for LTSP, so size counts. I want tiny binaries.

Some users will want the latest versions of gcc and libstdc. Personally, I think it's a bad choice for a rock-solid system (and for that matter, so is Gentoo - I love it, but it moves too fast to be entirely stable. Keeps things interesting, for sure). Anyway, I'll throw some caution to the adventurous who want the challenge:

This is centric to an AMD Athlon XP system running Gnome, although I believe it to be an excellent example, links to other 'make.conf's or more extensive comments for specific KDE or specific no-X configurations would be appreciated.

Code: nano -w
nano -w etc/make.conf
File: /mnt/gentoo/etc/make.conf
# These flags are stable for all packages, AFAIK
# If you get an error like this when compiling, you have misspelled or are otherwise using a flag incorrectly
# ''checking for C compiler default output... configure: error: C compiler cannot create executables''
CFLAGS="-Os -march=i686 -mcpu=athlon-xp -pipe -falign-functions=4" # -mtune=athlon-xp -fweb
# LDFLAGS="-Wl,-O1 -Wl,--sort-common -z combreloc -Wl,--enable-new-dtags" # -Wl,--relax
# Use 'buildpkg' if you want other systems to have access to the binaries on this system
# However, don't add it yet, wait until you're at stage3 and you pull that final `emerge -e system`
# A small number of programs won't compile with the sandbox, userpriv, usersandbox options
# Use `FEATURES="-sandbox -userpriv -usersandbox" emerge [package]` on a case-by-case basis
FEATURES="candy ccache digest fixpackages sfperms sandbox userpriv usersandbox" # buildpkg
# See also [[MAN_make.conf_5]]

## USE ##
# grep ${FLAG} /usr/portage/profiles/use.desc for explanation
# See also
CPU="3dnow gcj gcc mmx mmx2 nptl nptlonly pic sse threads x86"
PM="acpi -apm"
VIDEO="nvidia mythtv xinerama -3dfx"
AUDIO="audiofile alsa -arts esd openal"
BLK_DEV="cdr cdparanoia dvd dvdr"
NET="howl -ipv6 -nas samba tcpd"
OTHER="cups foomaticdb gphoto2 gimp-print gpm hal -pcmcia pda ppds scanner -joystick usb xprint"
SYS_AUTH="berkdb crypt hardened -imap innodb ldap mysql pam pam-mysql -selinux ssl"
X11="X accessibility artworkextra bonobo gnome gtk gtk2 gtkhtml -Xaw3d -qt -kde"
MMX_OTHER="exif -gd gif gimp gstreamer imagemagick jpeg mime ming mng pdflib png tiff wmf" #fdftk
MMX_VID="avi divx4linux dv encode flash mpeg quicktime xine xvid"
MMX_SND="aac flac mad ogg oggvorbis xmms"
WWW="aim apache2 icq ftp jabber libwww maildir mailwrapper mozilla msn nntp oscar yahoo xml xml2"
PROG="bash-completion curl java mono pcre perl php python" # cscope ruby"
MISC="gnomedb gnutls spell tcltk tidy truetype unicode"
## USE ##
# Read /etc/make.conf.example for explanation
# You may wish for other PCs to use these binaries, if so:
# mkdir /var/www/localhost/pub/gentoo/grp -p
# ln -s /usr/portage/packages/All /var/www/localhost/pub/gentoo/grp/i686
# 'Options FollowSymLinks' directive must be specified in /etc/apache2/conf/commonapache.conf
# PORTAGE_BINHOST="" # Built following this guide
# Warning: If you alter a variable to point to a different location, never end the path with a trailing / !
# Uncomment for logging

# ALSA_CARDS="via82cxx"
# ALSA_CARDS="emu10k1"
#Support for english, greek and german language for KDE and Openoffice
#LINGUAS="en el de"

It's also not a bad idea to use prelink, however, you should emerge it when you want to use it and unmerge it when you're done. Otherwise portage will use it automatically, and some packages have issues with prelink - though gstreamer is the only one that comes to mind.

Don't Overlook this Stage1 Muck! (even if you're starting with stage3)

Code: Important Steps
 cp -L /etc/resolv.conf etc/resolv.conf
 ''mount -t proc none /mnt/gentoo/proc'' # Just in case you missed it the first time

The chroot is really an interesting thing. It basically shifts your root from / to /mnt/gentoo and from there any userspace progs that interface with the kernel can still do so. I.E. provided that your new kernel and your old kernel are similar enough, you could change iptable rules from your new system.

To make Gentoo more "user-friendly" I'm going to use the quick'n'dirty (tm) way to add a few of the niceties that I've found on other distros, such as:

Code: Continued...
 chroot /mnt/gentoo/ /bin/bash
 cp /proc/mounts /etc/mtab
 echo 'Please edit me! /etc/motd: Hello World!' > /etc/motd # see [[TIP Fortune]]
 mkdir /usr/local/portage/ -p
 mkdir /etc/portage/profile/ -p
 mkdir /etc/config-archive -p # to use dispatch-conf instead of etc-update
 echo 'PATH="${PATH}:${HOME}/bin"' >> /etc/profile
 echo "alias grep='grep --color=auto'" >> /etc/profile
 echo "alias ls='ls --color=auto'" >> /etc/profile

 # This is notifies you of new system mail! once you install postfix
 echo 'if [ -d "${HOME}/.maildir/new" ];\
 	then NEWMAIL=`find ${HOME}/.maildir/new/ -type f`;\
 	if [ ! -z "${NEWMAIL}" ];\
 	then echo "You have new mail. Read it with 'mutt'.";\
 	fi' >> /etc/skel/.bash_profile
 mkdir /etc/skel/bin -p
 touch /etc/skel/bin/.keep
 cp -R /etc/skel/ /root
 mv /root/skel/* /root
 mv /root/skel/.* /root >/dev/null 2>1
 rmdir /root/skel
 mkdir -p /tmp && chmod 1777 /tmp
 env-update; source /etc/profile; source /root/config.vars
 emerge --sync
 ls -l /etc/make.profile
 echo "Check that the profile is linked to 2005.0"; sleep 3
 echo "sys-libs/glibc userlocales" >> /etc/portage/package.use
 echo "Comment out everything except your language(s) in 10 seconds"; sleep 10
 nano -w /etc/

For example, if German:

File: /etc/

If you're the brave type, go ahead and grab the latest gcc, but I advise against it.

# echo "Ensure that we grab the latest versions of gcc & libstdc++:"
# echo "=sys-devel/gcc- ~x86" >> /etc/portage/package.keywords
# echo "=sys-libs/libstdc++-v3-3.3.4 ~x86" >> /etc/portage/package.keywords
Retrieved from ""

Last modified: Fri, 05 Sep 2008 22:52:00 +0000 Hits: 16,414