Gentoo
Installation
The Gentoo Handbook is usually a very good guide through the whole installation process. In short:
Download a bootable CD image:
http://distfiles.gentoo.org/releases/x86/autobuilds/current-iso/
Verify signature:
gpg --keyserver subkeys.pgp.net --recv-keys 96D8BF6D 2D182910 17072058 gpg --verify install-x86-minimal-*.iso.DIGESTS.asc sha1sum -c install-x86-minimal-*.iso.DIGESTS
Setup networking:
ifconfig eth0 10.0.0.30 netmask 255.255.255.0 route add default gw 10.0.0.1 echo "nameserver 10.0.0.1" > /etc/resolv.conf
Enable ssh and set a password - that way we'll be able to install the system remotely:
/etc/init.d/sshd start passwd
While we're at it, set the system time:
ntpdate pool.ntp.org
Continue with the actual setup:
parted # Create partitions mkfs.ext4 /dev/sda1 # Create filesystem mkswap /dev/sda2 # Initialize swapspace
mount -t ext4 /dev/sda1 /mnt/gentoo swapon /dev/sda2
Download stage tarball and portage snapshot:
cd /mnt/gentoo LATEST=`wget -q http://distfiles.gentoo.org/releases/x86/autobuilds/latest-stage3-i686.txt -O - | tail -1` wget http://distfiles.gentoo.org/releases/x86/autobuilds/$LATEST{,.DIGESTS.asc,.DIGESTS} wget http://distfiles.gentoo.org/releases/snapshots/current/portage-latest.tar.xz{,.gpgsig,.md5sum} md5sum -c stage3-*.tar.bz2.DIGESTS gpg --verify stage3-*.tar.bz2.DIGESTS.asc md5sum -c portage-latest.tar.xz.md5sum gpg --verify portage-latest.tar.xz.gpgsig
Unpack:
tar -xjpvf stage3-*.tar.bz2 xz -dc portage-latest.tar.xz | tar -C /mnt/gentoo/usr -xvf -
Check make.conf, as we'll build a few things afterwards:
$ cat /mnt/gentoo/etc/make.conf CFLAGS="-O2 -march=i686 -pipe" CXXFLAGS="${CFLAGS}" CHOST="i686-pc-linux-gnu" MAKEOPTS="-j4" $ mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
Chroot into our new system:
mount -t proc none /mnt/gentoo/proc mount --rbind /dev /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash env-update source /etc/profile export PS1="(chroot) $PS1"
Set root password:
passwd
Configure locale:
$ grep ^[a-z] /etc/locale.gen en_US.UTF-8 UTF-8 $ locale-gen
Configure timezone:
cp /usr/share/zoneinfo/PST8PDT /etc/localtime
Update portage tree, select system profile
$ emerge --sync $ eselect profile list Available profile symlink targets: [1] default/linux/x86/10.0 * [2] default/linux/x86/10.0/selinux [3] default/linux/x86/10.0/desktop [4] default/linux/x86/10.0/desktop/gnome [5] default/linux/x86/10.0/desktop/kde [6] default/linux/x86/10.0/developer [7] default/linux/x86/10.0/server [8] hardened/linux/x86 [9] hardened/linux/x86/selinux $ eselect profile set 1
Emerge and activate a few programs:
emerge syslog-ng vixie-cron bash-completion less vim [dhcpcd, xfsprogs, reiserfsprogs, jfsutils] rc-update add syslog-ng default rc-update add vixie-cron default rc-update add sshd default
Oh, to actually enable bash-completion, this hack might be helpful:
cd /etc/bash_completion.d/ for c in /usr/share/bash-completion/[a-z]*; do ln -s $c `basename $c` done
Configure network:
$ grep . /etc/conf.d/hostname /etc/conf.d/net /etc/conf.d/hostname:hostname="foobar" /etc/conf.d/net:dns_domain_lo="example.com" /etc/conf.d/net:nis_domain_lo="example.com" /etc/conf.d/net:#config_eth0="dhcp" /etc/conf.d/net:config_eth0="10.0.0.30 netmask 255.255.255.0 brd 10.0.0.255" /etc/conf.d/net:routes_eth0="default via 10.0.0.1" $ cd /etc/init.d $ ln -s net.lo net.eth0 $ rc-update add net.eth0 default
Configure kernel, manually:
emerge gentoo-sources cd /usr/src/linux make menuconfig [...] make && make modules_install cp System.map arch/x86/boot/bzImage /boot/
Configure kernel, with genkernel, check modules to be loaded:
$ emerge genkernel $ genkernel all $ grep ^m /etc/conf.d/modules modules="3c59x"
Configure fstab:
$ grep ^/ /etc/fstab /dev/sda1 / ext4 noatime 0 1 /dev/sda2 none swap sw 0 0 tmpfs /tmp tmpfs nodev,nosuid,noexec,mode=1777 0 0 proc /proc proc nodev,nosuid,noexec,hidepid=2 0 0
Install bootloader:
$ emerge grub $ cat /boot/grub/grub.conf default 0 timeout 30 # splashimage=(hd0,0)/boot/grub/splash.xpm.gz title Gentoo Linux root (hd0,0) kernel /boot/bzImage root=/dev/sda1 # initrd /boot/initramfs
$ grep -v rootfs /proc/mounts > /etc/mtab $ grub-install --no-floppy /dev/sda
If this last step fails, try manually:
$ grub --no-floppy > root (hd0,0) > setup (hd0) > quit
There's also /etc/rc.conf, /etc/conf.d/keymaps and /etc/conf.d/hwclock to setup, but this can be done later as well.
Reboot into the newly installed system:
exit cd / umount -l /mnt/gentoo/dev{/shm,/pts,} umount -l /mnt/gentoo{/boot,/proc,} reboot
When rebooting was successful and the new system is up & running, remove the tarballs:
rm /stage3-*.tar.bz2* /portage-latest.tar*
Postinstall
distcc, ccache
$ cat /etc/make.conf [...] MAKEOPTS="-j6" FEATURES="ccache distcc" ← Order matters! CCACHE_DIR="/var/tmp/ccache" CCACHE_SIZE="2G" # CC="gcc" ← Can help if the distcc nodes are # CXX="c++" using different compiler versions
See distcc for details.
cachefilesd
Use cachefilesd to speed up NFS mounts by caching contents:
emerge cachefilesd rc-update add cachefilesd default
Now NFS filesystems can be mounted with fsc and will be cached to /var/cache/fscache/
Updating
Update the portage tree, this might take a few minutes:
emerge --sync
Update a specific package, e.g. curl:
emerge --update --deep --newuse --ask curl
Update the whole system, this might take even longer:
- with deep dependency checking
- including build dependencies
- check for newly modified USE flags
- ask before doing anything
emerge --update --deep --newuse --ask --with-bdeps=y world
Update configuration files in /etc after world has been updated:
etc-update
Removing orphaned dependencies:
emerge --depclean --ask emerge gentoolkit && revdep-rebuild
Kernel Update
Before updating the kernel, make sure the "symlink" flag is set, so that the /usr/src/linux symlink gets updated too:
$ grep symlink /etc/portage/make.conf USE="symlink"
Update the kernel sources:
emerge --update sys-kernel/hardened-sources # Or /vanilla-sources or /gentoo-sources, etc...
We can build the kernel as a mere user:
cd /usr/src/linux DIR=/var/tmp/linux mkdir $DIR sudo zcat /proc/config.gz > $DIR/.config make O=$DIR oldconfig make -j4 O=$DIR
Install the kernel as root:
sudo make O=$DIR modules_install cd $DIR V=$(awk '/Kernel Configuration/ {print $3}' .config) # In this case, "3.7.0-hardened" sudo cp arch/x86/boot/bzImage /boot/bzImage-$V sudo cp System.map /boot/System.map-$V sudo cp .config /boot/config-$V
Be sure to update the bootloader as well!
Upgrading
There's not really an upgrade path, but to follow the #Updating instructions above. Sometimes a new release provides a new profile, which can be selected via eselect profile.
Portage
make.conf
PORTDIR=/usr/portage PORTAGE_TMPDIR=/var/tmp DISTDIR=/usr/portage/distfiles # Fixme: is there a way to relocate /usr/portage/metadata? # NOCOLOR=true