Monthly Archives: August 2008

Upgrading to linux-2.6.27-rc3

rc3 is another solid release.  Follow the same procedure documented in upgrading to linux-2.6.27-rc2.

The catalyst patch works with this release.

Advertisements

Automatically logout after X is killed

Simply alias startx to ‘exec startx’.  For added convience, place it in /etc/bashrc, /etc/zshrc, or /etc/profile.  Note, that if you run ‘startx 2>&1 | tee startx.log’, this trick will fail.

Upgrading to catalyst-8.7

Choosing to run the latest kernel means choosing to deal with errors. Luckily, my mileage with 2.6.27-rc2 has been pretty good. Here are a few pointers (and an experimental patch) to use when setting up catalyst-8.7 kernel 2.6.27-rc2.

I created the patch from various components incl.:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=485793

Also, note that I do not have any working knowledge of C nor do I take credit for this patch.

Changes to Kernel API (that I’m aware of, at least)

  • smp_call_function.  See commit 5e374fb62621aca9522f76c2317c9acda75a8e88 by Jens Axboe to the file arch/x86/kernel/smp.c
  • find_task_by_pid.  See commit 5cd204550b1a006f2b0c986b0e0f53220ebfd391 by Pavel Emelyanov to the file kernel/pid.c
  • NOPAGE_SIGBUS.  See commit 3c18ddd160d1fcd46d1131d9ad6c594dd8e9af99 by Nick Piggin to the file include/linux/mm.h

Other things to be aware of

  • If you have paravirtualised guest support enabled in the kernel, the compilation will fail with FATAL: modpost: GPL-incompatible module fglrx.ko uses GPL-only symbol ‘pv_lock_ops’. Disable it: PARAVIRT_GUEST=n
  • The catalyst-8.7 driver uses deprecated symbols so if they kernel does not export them (in particular init_mm) the compilation will fail.  Enable them: UNUSED_SYMBOLS=y
  • catalyst-utils-8.7 needs to be installed with this driver

The commands (to set up catalyst-8.7, I’m sure you can setup catalyst-utils by yourself).  Note: If you’re not using the kernel that will be running with the drivers, then replace `uname -r` with the correct kernel version/name.

~ %   mkdir proj/catalyst
~ %   cd proj/catalyst
catalyst %   wget www2.ati.com/drivers/linux/ati-driver-installer-8-7-x86.x86_64.run -O catalyst-8.7.run
catalyst %   wget http://antonyat.googlepages.com/firegl_public.diff
catalyst %   /bin/sh ./catalyst-8.7.run --extract archive_files
I use x86.  x86_64 users should substitute x86 with x86_64 and x710 with x710_64a respectively.
catalyst %   cp archive_files/arch/x86/* ./
catalyst %   cp archive_files/common/* ./
catalyst %   cp archive_files/x710/* ./
catalyst %   cp firegl_public.diff lib/modules/fglrx/build_mod/
catalyst %   cd lib/modules/fglrx/build_mod/
catalyst %   patch -p1 < firegl_public.diff
catalyst %   cp 2.6.x/Makefile .
catalyst %   make -C /lib/modules/`uname -r`/build SUBDIRS="`pwd`" ARCH=i386 modules
catalyst %   su
pts/3:root@GENTOO /home/antony/proj/catalyst/lib/modules/fglrx/build_mod # install -m 644 -D fglrx.ko /lib/modules/`uname -r`/video/fglrx.ko

You should also copy the licenses (in archive_files to /usr/share/licenses)

As usual, your mileage may vary.

Upgrading to linux-2.6.27-rc2

git makes it incredibly easy to upgrade my kernel to the latest (but not necessarily greatest). I’ve decided that I’ll stick to tagged releases instead of the latest git pull.

I’ll skip the prologue and just show the commands.

Download the latest commits.

linux-git %   git pull  (Note:  Make sure you are in the master branch 🙂 [git checkout master].)

Download the latest tags.

linux-git % git fetch –tags git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

List the current tags.

linux-git % git tag -l “v2.6.27*”

Duplicate the 2.6.27-rc2 branch, call it aj2.6.27-rc2, and switch to it.

linux-git % git checkout -b aj2.6.27-rc2 v2.6.27-rc2

Copy the current config to the kernel directory.

linux-git % zcat /proc/config > .config

Configure any options that changed in the latest version.

linux-git % make oldconfig

Go through the usual compilation steps. See my post on upgrading to 2.6.27-rc1 for more information.

linux-git % make | tee make.log
linux-git % su
pts/2:root@GENTOO /home/antony/proj/linux-git # make modules_install | tee modules.log
pts/2:root@GENTOO /home/antony/proj/linux-git # mkinitcpio -k `make kernelrelease` -g /boot/kernel-2.6.27-rc2.img
pts/2:root@GENTOO /home/antony/proj/linux-git # cp System.map /boot/System.map-2.6.27-rc2
pts/2:root@GENTOO /home/antony/proj/linux-git # cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.27-rc2
pts/2:root@GENTOO /home/antony/proj/linux-git # install -D -m644 .config /boot/kconfig-2.6.27-rc2
pts/2:root@GENTOO /home/antony/proj/linux-git # /sbin/depmod -A -v `make kernelrelease`
pts/2:root@GENTOO /home/antony/proj/linux-git # vim /boot/grub/menu.lst
pts/2:root@GENTOO /home/antony/proj/linux-git # reboot

Problems

Difficulty in setting up catalyst-8.7. See my post on upgrading to catalyst-8.7.

Notes: My kernel config

kconfig-2.6.27-rc2

Upgrading to linux-2.6.27-rc1

I recently upgraded my kernel to linux-2.6.27-rc1.

This was the first time I compiled a kernel on this distro (but not the first time I have compiled one).  Thankfully, the compilation had no problematic errors.  This write up is more for my benefit than for yours; nevertheless, I hope it will help you out.

What works

ipw3945->iwl3945, catalyst, usb, sound, cpufreq (with new cpufreq stats output)

Extra features (that I choose to compile in)

watchdog, 9p filesystem support

Errors

none

lspci

00:00.0 Host bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub (rev 03)
00:01.0 PCI bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express PCI Express Root Port (rev 03)
00:1b.0 Audio device: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller (rev 01)
00:1c.0 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 1 (rev 01)
00:1c.3 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 4 (rev 01)
00:1d.0 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #1 (rev 01)
00:1d.1 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #2 (rev 01)
00:1d.2 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #3 (rev 01)
00:1d.3 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #4 (rev 01)
00:1d.7 USB Controller: Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller (rev 01)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e1)
00:1f.0 ISA bridge: Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge (rev 01)
00:1f.2 IDE interface: Intel Corporation 82801GBM/GHM (ICH7 Family) SATA IDE Controller (rev 01)
00:1f.3 SMBus: Intel Corporation 82801G (ICH7 Family) SMBus Controller (rev 01)
01:00.0 VGA compatible controller: ATI Technologies Inc Radeon Mobility X1400
03:00.0 Ethernet controller: Broadcom Corporation BCM4401-B0 100Base-TX (rev 02)
03:01.0 FireWire (IEEE 1394): Ricoh Co Ltd R5C832 IEEE 1394 Controller
03:01.1 SD Host controller: Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter (rev 19)
03:01.2 System peripheral: Ricoh Co Ltd R5C592 Memory Stick Bus Host Adapter (rev 0a)
03:01.3 System peripheral: Ricoh Co Ltd xD-Picture Card Controller (rev 05)
0b:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG Network Connection (rev 02)

Steps

(If you haven’t) Clone the current stable git repository.

proj %   git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-2-6

Initialise git variables / configuration (set username, email, enable colour, and improve performance for multicore systems)

proj %   git config --global user.name "Antony Jepson"
proj %   git git config --global user.email "email@gmail.com"
proj %   git config --global color.ui "auto"
proj %   git config --global pack.threads "0"
proj %   cd linux-2-6

Update local tree and make note of which changeset you are using.

linux-2-6 %   git pull
Already up-to-date.
linux-2-6 %  git whatchanged

I’m using commit 9cb7117fa4858468014f76bd996076985111e955.

Clean the tree.

linux-2-6 %   make mrproper && make clean

****
If you make a mistake it’s best to start fresh:

linux-2-6 %   git reset --hard origin/master

HEAD is now at 8f616cd Merge branch ‘for_linus’ of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
****

Configure compilation options.

linux-2-6 %   vim Makefile
 223 HOSTCXX      = g++
 224 HOSTCFLAGS   = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -march=prescott -mtune=generic -pipe
 225 HOSTCXXFLAGS = -O2

Configure the kernel

linux-2-6 %   zcat /proc/config.gz > .config
linux-2-6 %   make menuconfig

Apply patches and add them to git.

<apply patches, change files, etc.>

linux-2-6 %   git add <changed file(s)>
linux-2-6 %   git commit -a

Compile the kernel, install modules, build ramdisk, copy the new Systemmap, kernel, and .config, and rebuild module dependencies.

linux-2-6 %  make | tee 27rc1.log
linux-2-6 %  su
pts/4:root@GENTOO /home/antony/proj/linux-2-6 # make modules_install | tee 27rc1mod.log

Compilations within a git checkout will generate a long kernel versionstring, use `make kernelrelease` to make it easier.

mkinitcpio is distro specific (for Arch Linux).  Substitute your distro’s program here.

pts/4:root@GENTOO /home/antony/proj/linux-2-6 # mkinitcpio -k `make kernelrelease` -g /boot/kernel-2.6.27-rc1.img

See http://dirac.org/linux/system.map/ for more info.

pts/4:root@GENTOO /home/antony/proj/linux-2-6 # cp System.map /boot/System.map-2.6.27-rc1
pts/4:root@GENTOO /home/antony/proj/linux-2-6 # cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.27-rc1

The next step (copying the config) is optional as you should enable the option to create a copy at /proc/config.gz (IKCONFIG=y and IKCONFIG_PROC=y).

pts/4:root@GENTOO /home/antony/proj/linux-2-6 # install -D -m644 .config /boot/kconfig-2.6.27-rc1
pts/4:root@GENTOO /home/antony/proj/linux-2-6 # /sbin/depmod -A -v `make kernelrelease`

Configuring X.org.

Although Catalyst (8.5) worked out of the box, you may need to adjust your /etc/X11/xorg.conf.  I recommend using Xorg -configure and working from there.

pts/4:root@GENTOO /home/antony # mv /etc/X11/xorg.conf /etc/X11/xorg.conf_bak
pts/4:root@GENTOO /home/antony # Xorg -configure > /etc/X11/xorg.conf

Configuring Grub.

pts/4:root@GENTOO /home/antony/proj/linux-2-6 # vim /boot/grub/menu.lst
 36 title Arch Linux (2.6.27-rc1)
 37 root   (hd0,4)
 38 kernel /vmlinuz-2.6.27-rc1 root=/dev/sda7 ro vga=771
 39 initrd /kernel-2.6.27-rc1.img

Testing the kernel.

After you have copied the kernel to /boot, reboot and test it.  If it does not work, just boot your fallback kernel (you have one, right?) and try to identify the cause of the problem.

If the kernel works (well, might I add), clean the tree then commit your changes to the git repository.

linux-2-6 %   make clean
linux-2-6 %   git add .
linux-2-6 %   git commit -a

Notes

After a while, the flashing LED indicator for the iwlwifi driver becomes annoying.  Stop the blinking with:

pts/1:root@GENTOO /sys/class/leds 17:09 # echo 0 > iwl-phy0:{RX,TX,assoc}/brightness

Customising Email Signatures with Fortune

When I look at someone’s email signature and see a thought-provoking quote like “Violence is the last refuge of the incompetent” (Salvor Hardin), I add it to my mental list of quotes, which, of course, is soon forgotten. Now, with a bit of pipe magic, I can use Mutt and fortune to make my signatures a bit more creative.

Preparing the database

1. Create a .fortune file in your home directory and insert your quotes.  Separate each quote/phrase with a % (percentage sign).

~ %   touch ~/fortune
~ %   vim ~/fortune
  1 De duobus malis minus est semper eligendum.
  2   -- Thomas a Kempis
  3 %
  4 Sic transit gloria mundi.
  5   -- Thomas a Kempis
  6 %

2. Randomise access to the strings with strfile.

~ %   strfile -r ~/fortune ~/fortune.dat
"/home/antony/fortune.dat" created
There were 2 strings
Longest string: 65 bytes
Shortest string: 47 bytes

To save yourself embarrassment in the future, keep your quotes short and SFW.

Integrating the database with Mutt

3. Create a simple script to use with Mutt.

~ %   touch bin/signature.sh
~ %   vim bin/signature.sh
  1 #!/bin/bash
  2
  3 cat ~/.signature
  4 fortune ~/fortune
~ %   chmod +x bin/signature.sh

4. Finally, set the script as Mutt’s default signature.

~ %   vim ~/.mutt/muttrc
17 set signature="~/bin/signature.sh |"

Now you can enjoy creative, original signatures in your emails.

After a bit of thought, I came up with a heavily customised signature script that will: print the contents of ~/.signature, append a justified fortune quote from my database and right justify the attributed author.  Of course, it needs some work because the last line is right justified regardless of if there is an attributed author or not.

1 #!/bin/bash
2
3 fortune ~/fortune | sed -e 's/^/++ /' -e 's/$/ ++/' > /tmp/signature.1
4 sed -n '$!p' /tmp/signature.1 | par -58s3p3 > /tmp/signature.2
5 tail -n1 /tmp/signature.1 | sed -e :a -e 's/^.\{1,56\}$/ &/;ta' -e 's/++/\ \ /' -e 's/^./++/' >> /tmp/signature.2
6 cat ~/.signature
7 cat /tmp/signature.2

outputting something similar to:

Antony Jepson / <aaaaaaaa@gmail.com> / GPG Key: 0x00000000
++ Sapere aude! (Dare to be wise!)                      ++
++                          -- Quintus Horatius Flaccus ++