Sometime in June 2010...

...And so I received a new laptop at work. Dell E6400. It is devoted to work related activities and has a mighty Windows 7 Ultimate 64-bit OS installed (seriously, after experiencing it a bit, IMHO it is a significant improvement over the other Windows OS's). Still I thought it would be a great benefit for this notebook to have another decent operating system installed, thus, even more separating its use at work and outside of work. Remembering how much time I spent setting up Gentoo a few years ago on another (very second-hand) laptop that soon after died maturely (as opposed to prematurely), I decided to keep a little diary of activities.

 

Initial steps

Download the latest stable minimal Gentoo install ISO image. Burn it onto a CD-RW. Boot.

Networking is fine, since my company uses DHCP, the computer just got a dynamic IP address. Check the file /etc/resolv.conf for network configuration.

Prepare partitions using fdisk.

First, list them by fdisk -l. What my machine already had when it arrived was 298GB HDD with

  • /dev/sda1 = 100MB (NTFS - Windows system restore partition)
  • /dev/sda2 = 40GB (NTFS - Windows drive C:)

I turned the second partition into a 278GB (remember, it's a work-related machine :-)), thus, leaving around 20GB for Linux. Then, hesitant to touch existing NTFS partitions, I created the following:
Primary partition 3 - Linux boot (32MB)
Extended partition 4- Linux swap (1024MB)
Linux root- rest

In other words, my HDD became

  • /dev/sda1 - NTFS
  • /dev/sda2 - NTFS
  • /dev/sda3 - Linux boot
  • /dev/sda4 - extended
  • /dev/sda5 - Linux swap
  • /dev/sda6 - Linux root

Apply filesystems to partitions
mke2fs /dev/sda3- ext2 for boot
mke2fs -j /dev/sda6- ext3 for root
mkswap /dev/sda5- activate swap

Create mount points and mount boot & root partitions

  • mkdir /mnt/gentoo
  • mount /dev/sda6 /mnt/gentoo
  • mkdir /mnt/gentoo/boot
  • mount /dev/sda3 /mnt/gentoo/boot

Download and install Stage 3 Tarball

Choose mirror via links -http-proxy [ip]:[port] http://www.gentoo.org/main/en/mirrors.xml
(where [ip]:[port] are http proxy details, since I am behind the company's firewall)

Install by tar xvjpf stage3-i686-[date].tar.bz2 -C /mnt/gentoo

Download and install portage

Choose mirror as above, go to snapshots folder and download portage-latest.tar.bz2

Install by tar xvjpf portage-latest.tar.bz2 -C /mnt/gentoo/usr

Check etc/make.conf flags, for instance MAKEOPTS="-j[n]"
(where [n] is the number of parallel compilations allowed = number of CPUs + 1)

 

Set up the new environment

Choose Gentoo mirrors by mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
(in order for this to work, I had to do export HTTP_PROXY="http://[ip]:[port]", variable name in CAPITAL letters, otherwise I got no connection to mirror list)

Two important entries will appear in the file /mnt/gentoo/etc/make.conf, for example:

  • SYNC="rsync://rsync.gentoo.org/gentoo-portage"
    (server used by rsync to synchronise Portage tree)
  • GENTOO_MIRRORS="http://distfiles.gentoo.org http://www.ibiblio.org/pub/Linux/distributions/gentoo"
    (list of FTP & HTTP servers for source retrieval - separated by spaces)
Portage is a software management tool which is used to maintain Gentoo packages. More information on it can be found here. Portage tree consists of ebuilds -- files (per software package) that contain information about each package: how to compile, install it, and so on. Compilation flags for each package are governed by
  • - global USE flags in /etc/make.conf
  • - local (per package) USE flags in /etc/portage/package.use
  • - one-time USE flags with emerge command
For instance, USE="kde -gnome" means that every package (where applicable) should compile with kde compiler flag set and gnome flag unset. More information on USE flags can be found here.

Emerge tool is the interface to portage. Basically it takes the package title (supplied to it as an argument), looks at the corresponding ebuild, applies patches, compiles it, and installs it. Useful examples of emerge commands are:

  • emerge --sync (update portage tree)
  • emerge-webrsync (same as above when rsync port is blocked by firewall -- like I have at my work)
  • emerge --search [arg] (find a package that contains [arg] in its name)
  • emerge --update --deep --newuse --verbose --ask world (update every single package, taking into account any new USE flags, showing all available USE flags for each package, asking if you want to continue at the beginning; man emerge is your friend)

Another useful entry would be LINGUAS="en_GB ru" (to specify which language packs/tools to install with applications where it matters)

Copy network config for the new environment by cp /etc/resolv.conf /mnt/gentoo/etc

Mount /proc & bind /dev file systems
mount -t proc none /mnt/gentoo/proc- proc is a virtual file system which shows the state of the running Linux kernel
mount -o bind /dev /mnt/gentoo/dev- dev is a "file system" of physical devices (cdrom, floppy, external disk, etc.)

Switch to new environment
chroot /mnt/gentoo /bin/bash- change root
env-update- create new environment vars
source /etc/profile- load new env vars into memory

Configure date/time related matters, for example
timezone:cp /usr/share/zoneinfo/Australia/Sydney /etc/localtime
time:date -s "-10 hours"
clock:in /etc/conf.d/clock set CLOCK="local" & TIMEZONE="Australia/Sydney"

Set locales by modifying /etc/locale.gen (read comments in that file for available locales), then do locale-gen. I got the locales I am interested in by grep "^ru" /usr/share/i18n/SUPPORTED (Russian/Ukrainian), then copied them into /etc/locale.gen:

ru_RU.KOI8-R KOI8-R
ru_RU.UTF-8 UTF-8
ru_RU ISO-8859-5
ru_UA.UTF-8 UTF-8
ru_UA KOI8-U
* NOTE: there is more to it, as I discovered later (see section "Multilanguage support" at the end)

Check current profile by eselect profile list (if required, choose a different one than the profile marked with *):

Available profile symlink targets:
[1]   default/linux/x86/10.0 *
[2]   default/linux/x86/10.0/desktop
[3]   default/linux/x86/10.0/desktop/gnome
[4]   default/linux/x86/10.0/desktop/kde
[5]   default/linux/x86/10.0/developer
[6]   default/linux/x86/10.0/server

Set root password by passwd

Network configuration

DHCP in my case means that /etc/conf.d/net can stay blank (or consisting of just the usage comments)

Add eth0 to default run-level by rc-update add net.eth0 default

Install required tools
emerge -av dhcpcdDHCP daemon
emerge -av pppPPP for non-ADSL, dial-up connections (e.g. I have a wireless USB modem broadband at home)
emerge -av syslog-ngsystem logger
emerge -av vixie-croncron daemon

 

Kernel & bootloader

Update /etc/fstab to auto-mount things at start-up. I made my file look something like this (/dev/shm is shared memory):

/dev/sda3     /boot         ext2     defaults,noatime       1 2
/dev/sda6     none          swap     sw                     0 0
/dev/sda5     /             ext3     noatime                0 1
/dev/cdrom    /mnt/cdrom    auto     noauto,user            0 0
proc          /proc         proc     defaults               0 0
shm           /dev/shm      tmpfs    nodev,nosuid,noexec    0 0

Compile and install kernel

emerge -av gentoo-sources
(for this I had to do export http_proxy="[ip]:[port]", variable name in small letters %-), otherwise I got no connection to Gentoo sources)

cd /usr/src/linux- go to kernel source
make menuconfig- configure kernel via set of dialogs
make && make modules_install- compile kernel and modules
cp arch/i386/boot/bzImage /boot/kernel-2.6.32-gentoo-r7- prepare kernel image for boot-loader

Bootloader (I use grub)

emerge -av grub

nano /boot/grub/grub.conf - after editing in my particular case the file looks as follows:

default 0
timeout 30
splashimage=(hd0,2)/grub/splash.xpm.gz

title Gentoo Linux 2.6.32-r7
root (hd0,2)
kernel /boot/kernel-2.6.32-gentoo-r7 root=/dev/sda6

title Windows 7
rootnoverify (hd0,0)
makeactive
chainloader +1
  • (hd0,0) refers to HDD #1, partition #1 (zero-indexed), i.e. /dev/sda1 (my Windows 7 boot partition)
  • (hd0,2) refers to HDD #1, partition #3 (zero-indexed), i.e. /dev/sda3 (my Linux boot partition)

grep -v rootfs /proc/mounts > /etc/mtab

grub-install --no-floppy /dev/sda

using fdisk

  • turn on bootable flag for partition /dev/sda3
  • turn off bootable flag for partition /dev/sda1

REBOOT. Find that it works :-)
(if not, use the minimal installation CD, mount /boot, and fix any /boot/grub/grub.conf errors)

 

Post-install tasks

Create non-root user

  • useradd -m -G users,wheel,audio,video,usb -s /bin/bash [non_root_user]
  • passwd [non_root_user]

Groups:
wheel- get ability to su as root
audio- get access to audio devices
video- get access to video capture devices and hardware acceleration capabilities
usb- get access to usb devices

* NOTE: later during the troubleshooting I discovered that a couple more groups are important to have as well (plugdev, uucp, cdrom -- read on :-))

Update portage & system

  • emerge --sync
  • emerge --update --deep --newuse --verbose --ask world

Install X Window System

Make sure evdev is enabled in kernel

    Device Drivers  --->
        Input device support  --->
            <*> Event interface

Update make.conf
VIDEO_CARDS="nvidia"in my case I want to use laptop's discrete nvidia card
INPUT_DEVICES="evdev synaptics keyboard mouse"synaptics -- since laptop has a touchpad

xorg-server

  • emerge -av xorg-server
  • env-update && source /etc/profile (update environment variables and export them)

HAL (hardware abstraction layer), emerge, start daemon & add to default run level

  • emerge -av hal
  • /etc/init.d/hald start
  • rc-update add hald default
* NOTE: I discovered later that I had no USE="... hal" flag set, if I had, I probably would not need to emerge HAL separately after xorg-server)

startx fails...

Making X work
Xorg -configureto generate an xorg.conf file (you need to do so if hal fails to run X without any config file)
X -config /root/xorg.conf.newtesting the newly generated configuration -- freezes the machine
cp /root/xorg.conf.new /etc/X11/xorg.confcopy it into the configuration directory anyway to attempt to start X
startxfails with the following: failed to initialise the GLX module (aha!)
eselect opengl listshows that xorg-x11's module is used instead of nvidia's
eselect opengl set nvidiaswitch to nvidia's opengl
startxfails with the following: failed to load modules dri, dri2 (though nvivia splash screen flickers, so must be just a warning)
added to /etc/X11/xorg.conf
  • Disable "dri"
  • Disable "dri2"
startxcomplaints about missing xterm and twm (from xinitrc) -- so we must be fine
just to prove it and see what difference it makes,
  • emerge -av twm
  • emerge -av xterm
startxworks, brigning up X with three xterm windows

* Note: if you build a new kernel, nvidia module needs to be reinstalled!
emerge -av module-rebuild- install utility to rebuild kernel modules (needs to be done only once)
module-rebuild list- list modules that may need to be rebuilt (re-emerged)
module-rebuild rebuild- rebuild modules

 

Further configuration and troubleshooting

Graphical Desktop Environment (in my case -- KDE)
emerge -av kde-meta- satisfy USE flags until emerge is happy
su [non_root_user]- login as non-root user
echo startkde > .xinitrc- in the user's home directory create the file required by X Windows start-up script
startx- I did not do anything else, since I prefer to start X manually

Play with desktop settings, styles, plasmoids, etc. until you choose the combination for your own liking

Sound

already working, since Advanced Linux Sound Architecture (ALSA) was enabled within the kernel by default

run alsamixer to unmute / adjust sound levels

Laptop Power Management

added non-root user to plugdev group by usermod -aG plugdev non_root_user -- this caused battery plasmoid (which shows how much battery is left) and removable devices plasmoid (which detects and on a mouse click auto-mounts removable media) to start working

File Systems

noticed /boot is not auto-mounted and NTFS partitions cannot be mounted

recompiled the kernel with ext2 and NTFS (module) support

    File systems  --->
        <M> Second extended fs support
        ...
	DOS/FAT/NT Filesystems  --->
            <M> NTFS file system support
                <M> NTFS write support 

/boot as well NTFS partitions are now fine, but NTFS is not writable!

emerge -av ntfs3g

enable in kernel

    File systems  --->
        <M> FUSE (Filesystem in Userspace) support

ntfs-3g /dev/sdb1 /mnt/windows -- mounts NTFS with desired permissios and the ability to write

* NOTE: so enabling NTFS support in the kernel is not necessary

Internet
(at home I have broadband with the USB modem Huawei E169)

To set it up, emerge -av wvdial, then run wvdialconf

It detects nothing, so enable in the kernel

    Device Drivers  --->
        USB support  --->
            USB Serial Converter support  --->
                <M> USB Serial Converter support
                    [*] USB Generic Serial Driver
                    <M> USB driver for GSM and CDMA modems

wvdialconf now detects /dev/ttyUSB0 and creates /etc/wvdial.conf
change there

  • Phone = *99#
  • Username = none
  • Password = none

wvdial -- carrier detected, but then fails with error code 4 (according to man pppd it means "The kernel does not support PPP")

Back to the kernel enabling

    Device Drivers --->
        Network device support --->
            <M> PPP (point-to-point protocol) support
                <M>   PPP support for async serial ports
                <M>   PPP support for sync tty ports

wvdial -- still not working, now with pppd error 16 ("The link was terminated by the modem hanging up"),
discovered by trial and error the missing line refuse-chap in pppd configuration (put it in /etc/ppp/peers/wvdial)

wvdial as non-root user -- produces "device busy" error,
noticed that /dev/ttyUSB0 has permissions 0660 root:uucp,
usermod -aG uucp [non_root_user] -- fixes the problem

Packages & applications
(emerge -av ...)
corefonts, freefonts     - fonts
mozilla-firefox- browser
kaffeine- media player
open-office- office suite
gimp- graphics editor
k3b- CD/DVD burn tool
k9copy- DVD rip/convert tool (MASKED - install anyway)
apache2- web server
whatever else...

Multimedia

kaffeine plays MP3 and AVI from hard drive, but refuses to play CDs and DVDs (btw the device is actually /dev/sr0, not /dev/cdrom)

mount /dev/sr0 /mnt/cdrom produces error "UDF file system is not recognised"

enable (modular) support for UDF CD-ROM file system in the kernel

    File systems  --->
            CD-ROM/DVD Filesystems  --->
		<M> UDF file system support

mounting works now and individual VOB files can be played (but not DVD as a whole)

libdvdcss2 is installed, as for the others (libdvdread, libdvdplay, and libdvdnav) emerge -s says "Not Installed", but they seem to come with kaffeine (part of xine-lib package?)

different approach: export DVDCSS_VERBOSE=2

kaffeine from command line (as non-root user) displays "libdvdcss debug: cannot open ///dev/sr0 (Permission denied)" -- aha!

ls -l /dev/sr* shows that permissions are 660, group cdrom

adding non-root user to cdrom group -- fixes DVD playback

* NOTE: to play DVDs from hard drive, simply run kaffeine "dvd://[path to dvd dir]"

Multilanguage support
added Russian language in KDE's System Settings can now switch keyboards and type Cyrillic characters
in /etc/conf.d/consolefont changed
CONSOLEFONT="UniCyrExt_8x16"
to enable Cyrillics within console
created file /etc/env.d/02locale with contents
LC_CTYPE="ru_RU.UTF-8"
setting LANG="ru_RU.UTF-8" would use the entire Russian locale, but I just want the character set
env-update && source /etc/profile to update environment without KDE restart

Cyrillics is now supported for console auto-completion, ls, less, NTFS Cyrillic filenames (which are UTF8), File->Open dialogs of various applications, and so on...

Apache

/etc/init.d/apache2 start attempts to start net.eth0 (what??? :-O)

To disable (as it turns out) the pre-condition, in /etc/conf.d/rc need to change the line RC_NET_STRICT_CHECKING="lo"

Add apache2 to default run-level by rc-update add apache2 default

DocumentRoot is specified in /etc/apache2/vhosts.d/default_vhost.include

To make sure index is treated as such, added the following to the above-mentioned file:

    AddType text/html .html
    DirectoryIndex index.html

To enable server-side includes, added the following to the same file:

    Options +Includes
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    DirectoryIndex index.shtml

To enable php,

emerge -av php (make sure apache2 USE flag is specified)

for index files

    AddType text/html .phtml
    DirectoryIndex index.phtml

 

Special thanks

Gentoo handbook and a million other little bits and pieces all over the Internet...

Valid HTML 4.01 Transitional

© sashka76 [at] hotmail.com ®
£ § ¡