Table of Contents

Preperation

Before proceeding with installing Gentoo it is perhaps worthwhile running the Asus LiveUpdate which will download and install a load of irrelevant Windows drivers (if you select to), but also updates the BIOS. Once complete you are ready to proceed. Although these could be downloaded and installed individually.

Install

First you need a bootable USB drive. I found that there were a few problems with the Gentoo Minimal install CD and opted instead to use Xubuntu (64-bit) placed on a USB drive using Unetbootin. Restart the laptop and enter the BIOS using F2. You may need to enable UEFI boot option under the boot section of BIOS and change the boot order so that the laptop boots from the USB device first before booting from the internal hard disk.

Ensure that the USB network cable is connected and plugged into a router or switch. This just makes the networking side of things a lot more straight-forward.

Getting and Installing Gentoo

For the most part what follows is based on the excellent Gentoo Handbook, so if something isn't clear please refer to this primary source.

Partition the Hard Drive

I didn't care for keeping the M$-Win7 install so I fired up cfdisk deleted the hidden recovery partition and the main partition and created two new partitions, one 20Gb for the Gentoo install, the remainder for my /home/ data partition (see Gentoo Handbook : Preparing the Disks). Start up a terminal and switch to root (sudo su) and you can use cfdisk (or fdisk) to delete existing partitions and create new ones.

   Name       Flags       Part Type  FS Type        [Label]             Size (MB)
---------------------------------------------------------------------------------
   sda1       Boot        Primary    Linux                               20480.95
   sda2                   Primary    Linux                              107554.73*

I then created ext4 file-systems ( on each partition…

 mkfs.ext4 /dev/sda1
 mkfs.ext4 /dev/sda2

Mount the partitions

Now mount the partitions (see Gentoo Handbook : 4f Mounting).

mkdir /mnt/gentoo
mount /dev/sda1 /mnt/gentoo
mkdir /mnt/gentoo/home
mount /dev/sda2 /mnt/gentoo/home

Installing Gentoo

Now its time to grab a Gentoo stage and install it to the newly mounted partition (see Gentoo Handbook : Installing the Gentoo Installation Files).

wget http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo/releases/amd64/current-stage3/stage3-amd64-20121107.tar.bz2
wget http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo/snapshots/portage-latest.tar.bz2
tar xvjpf stage3-*.tar.bz2
tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr

Chroot

You can now chroot to the new environment that has just been installed (see Gentoo Handbook : 6a chrooting

# mount -t proc none /mnt/gentoo/proc
# mount --rbind /sys /mnt/gentoo/sys
# mount --rbind /dev /mnt/gentoo/dev
# chroot /mnt/gentoo /bin/bash
# env-update && source /etc/profile
# export PS1="(chroot) $PS1"

Now update the portage tree and select an appropriate profile…

# emerge --sync --quiet &
# eselect profile list

Portage Configuration

Portage is configured via /etc/portage/make.conf (which used to reside at /etc/make.conf), everyone's preferences will vary but mine is below…

# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j3"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# Sync/Mirrors
SYNC="rsync://rsync.uk.gentoo.org/gentoo-portage"
#SYNC="rsync://rsync.gentoo.org/gentoo-portage"
GENTOO_MIRRORS="http://gentoo.virginmedia.com/ http://www.mirrorservice.org/sites/ibiblio.org/gentoo/"
# Accept Key Options
ACCEPT_KEYWORDS="~amd64"
ACCEPT_LICENSE="*"
 
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="a52 aac acpi alsa bash-completion bluetooth branding cdda cddb cdparanoia cdr consolekit cups dbus device-mapper -doc dvd dvdr emacs exif ffmpeg flac gif gimp glitz gnome gtk gtk3 -hal icu id3tag ipv6 jpeg kpathsea -kde lensfun libsexy lock mmx mp3 mpeg nsplugin ntp offensive ogg opengl pam pdf png policykit -qt3 qt4 scanner sdl spell sse sse2 ssh svg thunar tiff truetype udev usb vorbis win32codecs X x264 xcb xinetd xulrunner xvmc"
 
# Features
EMERGE_DEFAULT_OPTS="--alphabetical --keep-going"
FEATURES="parallel-fetch"
INPUT_DEVICES="keyboard mouse evdev synaptics"
VIDEO_CARDS="i915 i965"
LINGUAS="en_GB"
PORTDIR_OVERLAY="/usr/portage/local"
source /var/lib/layman/make.conf

NB You may notice that there is a PORTDOR_OVERLAY declared, if this directory doesn't exist Portage will complain that it doesn't so just create it.

Date and Time

Set your date and time…

# cp /usr/share/zoneinfo/Europe/London /etc/localtime
# echo 'Europe/London' > /etc/timezone

Kernel Configuration

I was lucky here because I found a sample kernel config that I could use. After you have emerged the kernel sources…

# emerge -av gentoo-sources

…you can drop the sample configuration file (either the one from the above site or mine) into /usr/src/linux/.config and after then use it to configure and build your own kernel…

# cd /usr/src/linux
# make silentoldconfig
# make && make modules_install
# cp arch/x86/boot/bzImage /boot/vmlinuz-3.6.6

zenbook_ux21e_linux-3.6.8.config.bz2

GRUB2 Configuration

Because I run testing (ACCEPTKEYWORDS=“~amd64”) when I emerge the boot loader Grub it actually pulled in Grub2 which is a slightly different beast. Once emerged (emerge -av sys-boot/grub) you can explicitly define the kernel you wish to boot by adding entries to /etc/grub.d/40custom

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
timeout=5
set root=(hd0,1)
menuentry "Gentoo 3.6.6" {
    insmod ext2
    search --no-floppy
    linux /boot/vmlinuz-3.6.6 root=/dev/sda1 rootfstype=ext4 libahci.ignore_sss=1 i915.i915_enable_rc6=1
}

I'm not entirely sure that this is needed though because kernel images that are name vmlinux-3.. are purportedly automatically detected by Grub2, but I didn't read that until after I had configured this file.

You can then make the necessary configuration files and install the images with…

# grub2-mkimage -o /boot/grub
# grub2-install --boot-directory=/boot --directory=/ /dev/sda

…and all being well they will run and install without error.

Root Password and User Account

You should set the root password…

# passwd
Password: (Enter the password for root)
Re-enter password: (Re-enter the password to verify)

…and setup a user account for everyday business as its exceptionally stupid to run everything as root

# useradd -m -G users,wheel,audio -s /bin/bash johndoe
# passwd johndoe
Password: (Enter the password for johndoe)
Re-enter password: (Re-enter the password to verify)

Exit & Reboot

You can now exit your chroot environment, umount the disks and reboot into your fresh Gentoo install.

# exit
# cd
# umount -l /mnt/gentoo/dev{/shm,/pts,}
# umount -l /mnt/gentoo{/boot,/proc,}
# reboot

Post Install Configuration

Once installed and rebooted into your fresh install its time to finish things off by installing Xorg, a desktop system and all the other tools I wish to use. Rather than type out every emerge here is a copy of my /var/lib/portage/world file where these are recorded. If you want to install these files simpy copy and paste them into your /var/lib/portage/world and then emerge -uDNa @world (ideally overnight as its going to take a while to install all the packages and their dependencies!).

app-admin/logrotate
app-admin/sudo
app-admin/syslog-ng
app-cdr/gnomebaker
app-editors/gedit
app-editors/nano
app-emacs/color-theme
app-emacs/csv-mode
app-emacs/ess
app-emacs/org-mode
app-emacs/twittering-mode
app-forensics/chkrootkit
app-misc/colordiff
app-misc/gnuit
app-office/libreoffice
app-portage/eix
app-portage/genlop
app-portage/gentoolkit
app-portage/layman
app-text/dos2unix
app-text/tree
dev-lang/R
dev-texlive/texlive-bibtexextra
dev-texlive/texlive-genericextra
dev-texlive/texlive-pstricks
gnome-base/gdm
gnome-extra/gconf-editor
media-fonts/font-adobe-100dpi
media-gfx/gimp
media-gfx/gtkam
media-gfx/rawtherapee
media-gfx/ristretto
media-libs/mesa
media-video/gnome-mplayer
media-video/vlc
net-fs/cifs-utils
net-im/skype
net-irc/rhapsody
net-misc/dropbox
net-misc/keychain
net-misc/ssh-askpass-fullscreen
sci-mathematics/rstudio
sys-apps/lshw
sys-apps/mlocate
sys-apps/portage
sys-boot/grub
sys-kernel/gentoo-sources
sys-process/fcron
www-client/firefox
www-client/lynx
www-client/opera
www-plugins/adobe-flash
x11-apps/xcalc
x11-base/xorg-server
x11-drivers/xf86-video-fbdev
x11-drivers/xf86-video-intel
x11-drivers/xf86-video-modesetting
x11-drivers/xf86-video-vesa
x11-plugins/compiz-plugins-extra
x11-plugins/compiz-plugins-main
x11-terms/terminal
x11-wm/compiz-fusion
xfce-base/xfce4-meta
xfce-extra/tumbler
xfce-extra/xfce4-cpugraph-plugin
xfce-extra/xfce4-datetime-plugin
xfce-extra/xfce4-dict
xfce-extra/xfce4-power-manager
xfce-extra/xfce4-soundmenu-plugin
xfce-extra/xfce4-taskmanager
xfce-extra/xfce4-verve-plugin

Obviously if you'd rather use KDE and have no desire to use Xfce then don't include those in your /var/lib/portage/world file and emerge KDE explicitly yourself.

Power Management

In order to enable power management I followed two guides, the Gentoo Power Management Guide and the Gentoo Wiki : Userspace Suspend. Then for managing things in user-space I emerged xfce-extra/xfce4-power-manager with the networkmanager, udisks, policykit and brightness USE flags enabled.

Suspend/Hibernate

Suspend to RAM worked fine out of the box with the current kernel, but battery only lasted a couple of days maximum and as this laptop has a SSD resuming from that shouldn't take much longer so I set about hibernating (i.e. suspending to disk).

Ensure you have the required kernel options enable as highlighted in the Gentoo Power Management Guide (this includes all options that the Wiki suggests).

Laptop Mode Tools

The Gentoo Power Management Guide covers these handy tools for managing power on your laptop. Simply emerge laptop-mode-tools with USE=acpi enabled (add it to /etc/portage/package.use so that future updates include this USE flag too).

emerge -av app-laptop/laptop-mode-tools
/etc/init.d/laptop_mode start
rc-update add laptop_mode default

You set configuration options in the file /etc/laptop-mode/laptop-mode.conf and fine control is provided by the files that are to be found in /etc/laptop-mode/conf.d/. In particular I wanted to reduce permanently the brightness of my screen so I set the brightness for all instances to 50.

Compiz

I like a bit of eye-candy for switching between desktops and windows so wanted to install Compiz. Its pretty straight-forward and the Gentoo Wiki : Compiz page is the best thing to use, but its pretty much…

echo 'x11-wm/compiz-fusion emerald' >> /etc/portage/package.use
emerge -av x11-wm/compiz-fusion x11-plugins/compiz-plugins-main x11-plugins/compiz-plugins-extra

Then create the following file (I stored it in ~/bin/start-compiz.sh rather than the suggested ~/.start-compiz.sh

#!/bin/bash
compiz --replace --sm-disable ccp&
emerald --replace

…and then under the Xfce4 Menu > Settings > Session & Startup make sure that this script is started on login.

You will likely find that when first run all of your window decorations disappear, but don't panic, this is normal. All you need to do is enable them using the CompizConf Settings Manager (Menu > Settings > CompizConf Settings Manager or run ccsm from a terminal). You can enable “Window Decuration” under the 'Effects' section along with any other eye candy you wish to run.

TmpFS

Portage, by its nature, can be heavy on read/write cycles when compiling. This has the potential to shorten the life of your Solid-State Hard Disk (SSD). An alternative option is to mount the directories that Portage uses to Tmpfs which sits in RAM so that packages are compiled there. TmpFS size is changed dynamically as required up to a maximum which is by default 50% of the physical RAM, but it can be explicitly specified. This means that there should usually be sufficient space available to run other programs and use the laptop at the same time. There are however some packages that require more than the physical RAM (or maximum limit specified) to compile such as Libreoffice (which generally requires around 6-10Gb), but thats not a problem as Portage can be configured to not use tmpfs for compiling certain packages. I followed the Gentoo Wiki : Portage TMPDIR on tmpfs guide and performed the following.

Kernel

If you've used one of the kernels from this page then you will already have the necessary kernel configuration options enabled to support tmpfs

/etc/fstab

Add an entry for tmpfs to your /etc/fstab

tmpfs                   /var/tmp/portage        tmpfs   size=2G         0 0

Thats it you can now mount your tmpfs

Per-package Configuration

As mentioned above there are some packages that are too large to be built in tmpfs. I didn't fancy using the suggested method of using tmpfs temporarily because it would then mean running emerge -puDNv @world to see if there were any packages that were too large to be built in tmpfs emerging those under the proposed tmerge and then everything else using emerge. Instead I opted to use portage to configure packages that compile under tmpfs. Essentially its a way of excluding which packages are to be built using tmpfs.

First add the following line to /etc/portage/env/notmpfs

# mkdir /etc/portage/env
# echo 'PORTAGE_TMPDIR="/var/tmp/notmpfs"' >> /etc/portage/env/notmpfs

Then add packages that you do not wish to use the tmpfs to /etc/portage/package.env, for example…

app-office/libreoffice notmpfs.conf

..thats it you're good to go with tmpfs for portage builds. However read on if you want to have all of your RAM available when not compiling packages.

AutoFS

AutoFS is a smart way of automatically mounting partitions as required. I followed the Gentoo Wiki : Portage with AutoFS (see also Gentoo Wiki : AutoFS and Official Gentoo Wiki : AutoFS) and I use it to mount/unmount the above TmpFS as well as Portage distfiles when I'm on my home network (so that my install partition doesn't get filled up with source packages on this laptop).

Kernel

Make sure you have AutoFS support compiled into your kernel

-> File Systems
  <*> Kernel automounter version 4 support (also supports v3)  

Install AutoFS and configure

Emerge the AutoFS package

# emerge -av net-fs/autofs

Links & Resources

Linux Zenbook Resoruces

Battery Replacement

A full UX21e hardware listing (output from ''lshw'') is provided.

Asus Resources

linux gentoo latptop howto installation asus zenbook