HOWTO Install Gentoo Linux: Configuring

From Gentoo Linux Wiki

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

Image:Gentoo_tux.png

Base Install

  1. What is Gentoo?
  2. About
  3. Preparation
  4. Partitioning
  5. Configuring
  6. Stage Progression
  7. Kernel
  8. Bootloader
  9. Test
  10. Troubleshooting
  11. Maintaining

Configuration

Base Extras

Server

Desktop

Other Articles

edit

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

[edit] Building Your System

  • If you plan on setting up more than one system then set buildpkg and start with a stage3 and the same portage snapshot on your next target system. You can skip much of this upcoming section (and the hours of toil assosiated with it) and recycle the binaries and distfiles you created on your first system. Set up a Gentoo Server Serving Gentoo and make it happen.
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
      • I noted an odd issue here... if following the prior page and you run the tar for stage1 - you get an odd error with tar: ./proc/.keep - unable to blahblahblah... to fix this, unmount the proc from the last stage (umount /mnt/gentoo/proc) and then remount it before chrooting into the environment.

[edit] 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.

  • A caution when starting with a stage one: using an extensive array USE Flags may seriously break the transformation from stage2 to stage3 because the dependencies won't necessarily be build in the correct order (or one is somehow dependant on the other). This is easy enough work around, but you'll have to intervine, read the screen, use some logic and reasoning, and emerge package preventing the target package from being built. Instead of using fewer use flags I circumvented the problems as they came up by running emerge --resume (<ctrl>+<z>) USE="-*" emerge ${DEPENDENCY} && fg %1. It's important to start and then pause the resume job otherwise it gets just plain stupid... God gave us all brains, don't make Him look bad.

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:

  • NOTE: CFLAGS: Don't use "-fweb" until gcc-.3.4 or later has been emerged.
  • NOTE: Previous to gcc-3.4.x "-mtune" was "-mcpu".
  • NOTE: LDFLAGS: "-Wl,--relax" breaks glibc, but everything else below seems to work.


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
## OPTIMIZATIONS ##
# These flags are stable for all packages, AFAIK
CHOST="i686-pc-linux-gnu"
# 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
CXXFLAGS="${CFLAGS}"
# LDFLAGS="-Wl,-O1 -Wl,--sort-common -z combreloc -Wl,--enable-new-dtags" # -Wl,--relax
MAKEOPTS="-j3"
PORTAGE_NICENESS="15"
# 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 http://gentoo-portage.com
# HARDWARE #
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"
HARDWARE="${CPU} ${PM} ${VIDEO} ${AUDIO} ${BLK_DEV} ${NET} ${OTHER}" ##
# SOFTWARE #
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"
SOFTWARE="${SYS_AUTH} ${X11} ${MMX_SND} ${MMX_VID} ${MMX_OTHER} ${PROG} ${WWW} ${MISC}" ##
## USE ##
USE="${HARDWARE} ${SOFTWARE}"
 
 
## PORTAGE SETTINGS ##
# Read /etc/make.conf.example for explanation
AUTOCLEAN="yes"
RSYNC_RETRIES="1"
RSYNC_TIMEOUT="30"
# 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="http://coolaj86.homedns.org:4887/pub/gentoo/grp/i686/" # Built following this guide
# Warning: If you alter a variable to point to a different location, never end the path with a trailing / !
PORTDIR_OVERLAY="/usr/local/portage"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
RPMDIR="${PORTDIR}/rpm"
PORTAGE_TMPDIR="/var/tmp"
BUILD_PREFIX="${PORTAGE_TMPDIR}/portage"
# Uncomment for logging
#PORT_LOGDIR="/var/log/portage"


## OTHER SETTINGS ##
# ALSA_CARDS="via82cxx"
# ALSA_CARDS="emu10k1"
# CCACHE_SIZE="2G"
# DISTCC_DIR="${PORTAGE_TMPDIR}/.distcc"
 
#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.

[edit] 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:

  • Including "$HOME/bin" in the PATH
  • A script in $HOME/.bash_profile to check and notify you if you have new mail at login.
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;\
 	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
 cd
 emerge --sync
 clear
 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/locales.build

For example, if German:

File: /etc/locales.build
en_US/ISO-8859-1 
en_US.UTF-8/UTF-8 
de_DE/ISO-8859-1 
de_DE@euro/ISO-8859-15 
de_DE.UTF-8/UTF-8 


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-3.4.3.20050110-r1 ~x86" >> /etc/portage/package.keywords
# echo "=sys-libs/libstdc++-v3-3.3.4 ~x86" >> /etc/portage/package.keywords
Personal tools