Yearly Archives: 2010

Update system time using ntp and NetworkManager (Gentoo)

On my laptop I use NetworkManager to control network interfaces (LAN/WLAN).

Here is a simple script that will sync your clock with Internet time when LAN or WLAN interface is up and stop ntp-client when the interface is down. Put the script in /etc/NetworkManager/dispatcher.d and make it executable (chmod +x ).

#!/bin/bash
IF=$1;
STATE=$2;
 
if [ "$IF" = "eth0" ] || [ "$IF" = "wlan0" ] && [ "$STATE" = "up" ]; then
        /etc/init.d/ntp-client start
else
        /etc/init.d/ntp-client stop
fi

In order for the script to work you need net-misc/ntp package.

Using OpenSSL with Apache Tomcat 6

First we need Apache Portable Runtime (APR) in order to enable OpenSSL support and generally optimize Tomcat performance. It you are running Gentoo:

emerge -v tomcat-native

To enable APR edit your server.xml file and add the following line:

<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

Depending on your configuration APR listener may be enabled by default.

Next on the Open SSL part. Back in your server.xml file, add an SSL connector:

<connector port="8443" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               SSLEngine="on" 
               SSLCertificateFile="/path/to/your/certificate.crt"
               SSLCertificateKeyFile="/path/to/your/certificate.key">
</connector>

If you need an intermediate crt file add the following in your connector directive:

SSLCertificateChainFile="/path/to/your/intermediate.crt"

Restart Tomcat and you should be up and running with OpenSSL support. APR complete documentation is available here.

Gentoo GNU/Linux on Acer Extensa 5620Z

This guide will explain the procedures involved in the installation and configuration of Gentoo GNU/Linux on Acer Extensa 5620Z Laptop.

Why Gentoo GNU/Linux?

Gentoo is my favorite GNU/Linux distribution, because it has great package management system a.k.a “Portage” and it gives you the ability to optimize the system for your machine. There is also great community build around it.

More information about Gentoo it’s ideology and the features it provides, is available on Gentoo website.

Hardware Information

Component Description
CPU Intel Pentium dual-core processor T2330 (1.6Ghz, 533MHz FSB, 1MB L2 cache) – 64bit
RAM 2GB SODIMM DDR2 Synchronous 533 MHz (1.9 ns)
SMBus Intel Corporation 82801H (ICH8 Family) SMBus Controller
HDD 160 GB WDC WD1600BEVS-2
SATA controller Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller
Video Intel Mobile GM965/GL960 Integrated Graphics Controller
Audio Intel Corporation 82801H (ICH8 Family) HD Audio Controller
Ethernet controller Broadcom Corporation NetLink BCM5787M Gigabit Ethernet PCI Express
Ethernet controller Atheros Communications Inc. AR5001 Wireless Network Adapter
FireWare Texas Instruments PCIxx12 OHCI Compliant IEEE 1394 Host Controller
SD Host controller Texas Instruments PCIxx12 SDA Standard Compliant SD Host Controller
Card Reader Texas Instruments 5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD)
Web Cam SuYin Acer CrystalEye web c

The laptop also provides 2x PCMCIA slots, TV Out and DVD-RW drive.

Gentoo installation notes

The installation was preformed using Gentoo amd64 minimal CD (install-amd64-minimal-20101111.iso). After booting the minimal CD all devices needed for a successful installation were recognized.

Please note that to be able to download stage3 and portage-snapshot or to have an active Internet connection during the installation process you need to configure your LAN interface ( usually eth0 ). The wireless card is recognized by the minimal CD but you will need some tools to configure it, not available in the environment provided by the CD.

For complete installation instructions consult Gentoo Handbook available here.

Kernel configuration

This configuration is based on kernel 2.6.34. You can download my config file here.

Code Listing: Using the config file
cp config.txt /usr/src/linux/.config

Note: I use LZO compression method for my kernel image, so if you decide to use my config file, emerge lzop or change the compression method to Bzip2 or other.

Provided config file includes support for all the hardware available on the machine, temperature and other sensors, CPU frequency scalling, ACPI sleep/hibernate, ext2, ext3, ext4, NTFS (read/write support), vfat, nfs client, synaptics, etc… For complete feature overview run make menuconfig.

Every option is compiled in the kernel.

Code Listing: Compiling and installing the kernel
make && make modules_install
cp arch/x86_64/boot/bzImage /boot/kernel-2.6.34-gentoo-r12

Nice terminal resolution

In order to improve the terminal resolution append the lines below to the kernel parameter of your grub.conf.

Code Listing: Setting nice terminal resolution by editing grub.conf
video=vesafb:1280x1024-24@60 vga=9

Function keys

In order to make the Fn key combinations and multimedia keys work copy following HAL policy file 10-laptop-panel-mgmt-policy.fdi from /usr/share/hal/fdi/policy/10osvendor to /etc/hal/fdi/policy.

Restart HAL.

Code Listing: copying HAL policy file for laptop panel managment
cp /usr/share/hal/fdi/policy/10osvendor/10-laptop-panel-mgmt-policy.fdi /etc/hal/fdi/policy

X Server configuration

In your /etc/make.conf add VIDEO_CARDS=”intel” and INPUT_DEVICES=”evdev synaptics” then emerge xorg-server.

Synaptics configuration

Configuration of the touchpad is simple, copy HAL policy file 11-x11-synaptics.fdi from /usr/share/hal/fdi/policy/10osvendor
to /etc/hal/fdi/policy open the file in your favorite text editor and remove the comments surrounding the match tag.

Code Listing: copying HAL policy file for synaptics touchpad
cp /usr/share/hal/fdi/policy/10osvendor/11-x11-synaptics.fdi /etc/hal/fdi/policy/99-x11-synaptics.fdi

To enable tapping ( mouse clicks using the touchpad ) add the following line to your 99-x11-synaptics.fdi policy file:<merge key=”input.x11_options.TapButton1″ type=”string”>1</merge>

Restart HAL.

If you want to disable your touchpad while typing make syndaemon start’s with X, by adding exec syndaemon to your .xinitrc or by a desktop specific way. For KDE 4 see below:

Code Listing: Autostart syndaemon when KDE starts
cd .kde4/Autostart
vim (or editor of your choice) syndaemon

*** SYNDAEMON SCRIPT CONTENT BEGIN ***

#!/bin/bash
exec syndaemon

*** SYNDAEMON SCRIPT CONTENT END ***

chmod +x syndaemon

Type man synaptics for additional configuration options and help.

Power management

Most of the laptop power management is preformed by HAL, but additional steps are required for CPU frequency scaling and suspend / hibernate.

CPU frequency scaling

In order to enable CPU frequency scaling one should emerge cpufreqd and add it to the default runlevel. More information about CPU freq scaling is available in Gentoo power management guide.

Suspend / hibernate

Suspend and hibernate are handled by HAL, but in order to use them you should add yourself to the plugdev group and emerge pm_utils.

Code Listing: Adding a user to plugdev group
gpasswd -a <user> plugdev

Resuming from hibernation

In order to resume the system to it’s pre hibernated state ( I assume that you are using my kernel config file, if not enable hibernation in the kernel, if you haven’t done so ) append the following line to your grub.conf file:

Code Listing: Enabling hibernation
resume=/dev/<SWAP>

NOTE: <SWAP> is the location of your SWAP partition

Misc Configuration

KDE 4 Lag on Gentoo

I was experiencing a fair amount of lag during my interaction with the KDE desktop. To fix this I unmasked the latest hard masked nVidia drivers available in portage ( wich are also the latest upstream drivers provided by nVidia. )

echo “x11-drivers/nvidia-drivers ~amd64″ >> /etc/portage/package.keywords
echo “=x11-drivers/nvidia-drivers-260.19.12″ >> /etc/portage/package.unmask

After emerging them, reloading the module and starting X again. The lag was gone. Now I have fast and pleasant to work with KDE desktop. Also my FPS is up to 10344.223.