About / Gentoo Linux on a Thinkpad X61s

Installation Notes

Here is a record of my steps taken to install and configure Gentoo Linux on a Thinkpad X61s, Intel Core2 Duo CPU @ 1.80 Ghz, as well as some general tweaks to make life a little nicer using GNU/Linux. I currently run openbox as my window manager inside a minimal KDE installation. Collected from various online sources, I find it helpful to have this consolidated at one location.

X61s Tech Specs (PDF 255KB)


Booting over the Network

Since the X61s does not have an optical drive, I installed over the network using a bootable:
Live Knoppix system on CD.

PXE (PXE stands for 'Preboot Execution Environment') quick howto using Knoppix linux.

Networking

Kernel module iwl4965 works out-of-the-box.

Be sure to also install this firmware from portage.
emerge net-wireless/iwl4965-ucode

I found I need to sometimes stop the wifi card, before it can be started. Below is the network start up script I call from /etc/conf.d/local.start

wifi_start.sh
Located at /usr/local/bin
#!/bin/sh

echo "network startup"
	/etc/init.d/net.wlan0 stop && iwconfig wlan0 txpower on && /etc/init.d/net.wlan0 start

# power management for wireless lan card,  which dramatically reduces heat 
# under the right palm rest.
	
	for i in `echo /sys/bus/pci/drivers/iwl4965/*/power_level`; do
		echo 5 > $i
	done

echo "network startup complete"


Baselayout and OpenRC Migration Guide

I updated the Baselayout and OpenRC using the Baselayout and OpenRC Migration Guide
This decreased my start up time from 39.6 seconds to 26.4 seconds.

CPU Frequency

Works out-of-the-box, but I had to manually load the module acpi-cpufreq.

Power Management

I followed the Gentoo Power Management guide.

To make suspend to ram work add "acpi_sleep=s3_bios" to the kernel command line in grub configuration.

To stop power drain during suspend to disk place the following command in /etc/conf.d/local.start
echo "shutdown" > /sys/power/disk

I also chose to not have a battery runlevel as suggested in the gentoo power management guide, and instead use the following two scripts below.

default.sh
Located at /etc/acpi/default.sh
#!/bin/sh
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Default acpi script that takes an entry for all actions
set $*
group=${1/\/*/}
action=${1/*\//}
case "$group" in
        button)
                case "$action" in
                         lid)
                                        /etc/acpi/events/lid
                                ;;
                        power)
                                 init 0
                                ;;
                        *)
                #               logger "ACPI button action $action is not defined"
                                ;;
                esac
                ;;
        ac_adapter)
                /etc/acpi/ac_adapter.sh
                ;;
        *)
                logger "$* : $group/$action not defined"
                ;;
esac

ac_adapter.sh
Located at /etc/acpi/ac_adapter.sh
This script not only changes the CPU frequency, but it also adjusts the brightness of the LCD.
#!/bin/bash
############################################################
# ac_adapter.sh: Will detect the status of the ac adapter. #
# Requires acpi support in the kernel. Which is also a     #
# requirement for acpid, which this script was written for #
# adapted from neucode.org script                          #
############################################################
. /etc/conf.d/acpid
#Choose the governor you want to use when laptop is running on ac power
#(performance or ondemand recommended)
ONAC_GOVERNOR="ondemand"
BATT_GOVERNOR="conservative"
acstate=`grep state /proc/acpi/ac_adapter/AC/state | gawk '{print $2}'`;
logger "Executing ac-adapter script adapted from neucode.org";

for cpu in `ls /sys/devices/system/cpu/ | grep cpu `; do
        case "$acstate" in
                on-line)
                        echo 0 > /sys/devices/system/cpu/sched_mc_power_savings
                        #Do stuff when the ac adapter is plugged in
                        cpufreq-set -g ${ONAC_GOVERNOR}
                        # set LCD brightness to 100%
                        echo 100 > /proc/acpi/video/VID1/LCD0/brightness
                        logger "AC Adapter is plugged in. Governor to $ONAC_GOVERNOR";
                        ;;
                off-line)
                        echo 1 > /sys/devices/system/cpu/sched_mc_power_savings
                        #Do stuff when the ac adapter is un-plugged
                        cpufreq-set -g ${BATT_GOVERNOR}
                        # set LCD brightness to 50%
                        echo 50 > /proc/acpi/video/VID1/LCD0/brightness
                        logger "AC Adapter is un-plugged. Governor to $BATT_GOVERNOR";
                        ;;
        esac
done

Here are the two scripts I use for the acpi event of closing the lid.

lid
Located here /etc/acpi/events/lid
event=button/lid
action=/etc/acpi/actions/suspend.sh %e

suspend.sh
Located here /etc/acpi/actions/suspend.sh
#!/bin/sh
# if launched through a lid event and lid is open, do nothing
	echo "$1" | grep "button/lid" && grep -q open /proc/acpi/button/lid/LID/state &&  exit 0
# stop wifi
	/etc/init.d/net.wlan0 stop
# remove wifi module
	rmmod iwl4965
# go to sleep
	sleep 3 &&  echo -n "mem" > /sys/power/state
# reload wifi module
	modprobe iwl4965
sleep 1
# restart the wifi
/etc/init.d/net.wlan0 stop && iwconfig wlan0 txpower on && /etc/init.d/net.wlan0 start

for i in `echo /sys/bus/pci/drivers/iwl4965/*/power_level`; do
	echo 5 > $i
done

Secure Digital Card Reader

Works out-of-the-box and automounts using Hal and Dbus, or can be manually mounted at /dev/mmcblk0p1

Desktop Beautification

Screenshots:
Screenshot #1 (minimal)
Screenshot #2 (gtk app with qt look)

Get your fonts looking nice:
Gentoo: HOWTO Xorg and Fonts

Have your GTK apps look unified with your QT apps:
emerge x11-themes/gtk-engines-qt

Replaced the silly kde dragon image on the logout dialog box:
/usr/kde/3.5/share/apps/ksmserver/pics/shutdownkonq.png

Conky:
conkyrc file

Openbox Theme:
openbox theme called Steel

Openbox Menu:
Openbox XML menu file


SSH Filesystem

I now mount network drives over ssh, rather than samba.
emerge sys-fs/fuse

modprobe fuse

to mount:
sshfs user@host:/dir/mount/point/ /local/mount/point/
to unmount:
fusermount -u /local/mount/point/


lspci Output

00:00.0 Host bridge: Intel Corporation Mobile Memory Controller Hub (rev 0c)
00:02.0 VGA compatible controller: Intel Corporation Mobile Integrated Graphics Controller (rev 0c)
00:02.1 Display controller: Intel Corporation Mobile Integrated Graphics Controller (rev 0c)
00:19.0 Ethernet controller: Intel Corporation 82566MM Gigabit Network Connection (rev 03)
00:1a.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Contoller #4 (rev 03)
00:1a.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5 (rev 03)
00:1a.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2 (rev 03)
00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 03)
00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1 (rev 03)
00:1c.1 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 2 (rev 03)
00:1d.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1 (rev 03)
00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 03)
00:1d.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1 (rev 03)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev f3)
00:1f.0 ISA bridge: Intel Corporation Mobile LPC Interface Controller (rev 03)
00:1f.1 IDE interface: Intel Corporation Mobile IDE Controller (rev 03)
00:1f.2 SATA controller: Intel Corporation Mobile SATA AHCI Controller (rev 03)
00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller (rev 03)
03:00.0 Network controller: Intel Corporation Unknown device 4230 (rev 61)
05:00.0 CardBus bridge: Ricoh Co Ltd RL5c476 II (rev ba)
05:00.1 FireWire (IEEE 1394): Ricoh Co Ltd R5C832 IEEE 1394 Controller (rev 04)
05:00.2 SD Host controller: Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter (rev 21)

make.conf

# Please consult /etc/make.conf.example for a more detailed example.
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
# 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="i686-pc-linux-gnu"
LDFLAGS="-Wl,-O1 -Wl,-as-needed"
#
MAKEOPTS="-j3"
#
#
#
USE="bindist cdparanoia css dvdnav v4l v4l2 a52 aac acpi alsa apache2 \ 
apm ati avi bash-completion bluetooth bzip2 cdparanoia cddb cjk cups \ 
dbus dri encode -esd -eds fame flac flash ftp freetype gif gimp glibc \ 
-omitfp -gnome -gphoto2 gpm -gstreamer gtk gtk2 hal history icq ieee1394 \ 
imagemagick imap ipod jabber -java javascript jpeg laptop libg++ lm_sensers \ 
libwww libnotify  mime mmx  mozilla mp3 mpeg mbox  mysql ncurses \ 
 nptlonly nsplugin ogg oggvorbis opengl oscar oss pcmcia \ 
pam pdf perl php pmu posix png ppds quicktime samba spell sse sse2 svg \ 
sysfs tiff truetype unicode usb vim vim-syntax vhosts vorbis wifi \ 
win32codecs X xine xml xml2 xpm xvid yahoo -arts -fortran -joystick kde \ 
-motif -htdocs  -esound qt3 qt4 -berkdb xcomposite xinerama"
#
INPUT_DEVICES="keyboard mouse"
VIDEO_CARDS="i810 vesa"
FRITZCAPI_CARDS="fcpcmcia"
FEATURES="parallel-fetch ccache"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
GENTOO_MIRRORS="http://gentoo.osuosl.org/  \
http://gentoo.chem.wisc.edu/gentoo/   \
http://gentoo.cites.uiuc.edu/pub/gentoo/"

# Portage
# # NICENESS sets system priority.  10 is a reasonable value.
PORTAGE_TMPDIR=/var/tmp
PORTDIR=/usr/portage
PORT_LOGDIR=/var/log/portage
PORTAGE_NICENESS=10
AUTOCLEAN="yes"
#PORTDIR_OVERLAY=/usr/local/portage
#
# #FEATURES="distlocks userpriv sandbox"
#FEATURES="ccache"
CCACHE_DIR="/var/tmp/ccache/"
CCACHE_SIZE="2G"

# Needed form some applications including Open-Office:
LINGUAS="en"
APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd \
authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile \
authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs \
dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache \
filter headers ident imagemap include info log_config logio mem_cache \
mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect \
proxy_http rewrite setenvif so speling status unique_id userdir usertrack \
vhost_alias"

Kernel Config

Here is my config file for kernel 2.6.24-gentoo.r8


X11 Config

Here is my xorg.conf


Connecting Motorola Razr V3 using USB cable with moto4lin

added 07/07/08

emerge moto4lin

Steps to connect to the RAZR v3:

  1.  1. Boot the computer
  2.  2. Connect the v3 (using usb)
  3.  3. Start moto4lin
  4.  4. Click on preferences
  5.  5. Set ACM Device: /dev/ttyACM0
         AT Vendor ID: 22b8
         AT Product ID: 4164
         PK Vendor ID: 22b8
         PK Product ID: 4901
  6.  6. Click on Update List
  7.  7. Select phone from device list
  8.  8. Click "Set as p2k Device"
  9.  9. Click "Switch to p2k"
  10. 10. Click ok
  11. 11. Back in moto4lin window, click on Update List
  12. 12. Select phone from Directory Pane
  13. 13. Click the Connect/Disconnect button

Note: I must be logged in as root to connect to the phone.

Flashing RAZR v3

Source of flashing information: http://moto4lin.sourceforge.net/wiki/Flashing

Downloaded and compiled this flasher program.

Program should be launched as root. It can flash any shx file.

USE: flasher [-d DEVICE] [-e ERASEARG] SHXFILE

DEVICE - ACM device, like /dev/ttyACM0

ERASEARG - ERASE argument. Originally 2 values were used for it:

1) 0x80 - for code reflashing. Just erases the ranges specified.

2) 0x2 - for DRM&Language package reflashing. Erases the ranges specified and also the 0xB1 magic in the MEM_MAP, which is restored with RBRK command. RBRK is normally sent after flashing is complete. This program doesn't send RBRK anyway, so only the default value should be used.

SHXFILE - SHX file to flash.

It's recommended to switch phone manually to FLASH mode by turning it off and then pressing the buttons "*", "#" and Power simultaneously on phone.

Program will create temporary files in current directory. So it's should be RW. Note it doesn't cleanup automatically.

Dissembly of the RAZR v3

Guide to disassembly of the RAZR v3

Kmobiletools

ToDo List



Resources

(thanks to these very helpful resources)



Last updated on 07/07/08