01 March 2012

89. Compiling kernel 3.2.8 on Debian Testing -- example using kernel-packages and kernel.org source

For kernel 3.2.9, see here: http://verahill.blogspot.com.au/2012/03/debian-testing-kernel-329.html

Following: http://www.linuxplanet.com/linuxplanet/tutorials/6853/1 and http://www.sysdesign.ca/guides/linux_kernel.html  and very much http://old-releases.ubuntu.com/ubuntu/dists/hoary/main/installer-ia64/current/doc/manual/en/ch08s04.html

Update: added kernel_headers

I've added very litte to the guides, except proving that yes, the above tutorial works for the current stable kernel version (3.2.8) and the current debian testing (29/12/2012).

Here's what's new in 3.2.8 -- https://lwn.net/Articles/484042/
Here's what will be new in 3.3 -- http://www.h-online.com/open/features/Kernel-Log-Linux-3-3-goes-into-testing-1418516.html

Everything between SAFE START and END are ok -- they won't change anything serious on your system. If you're building on a 32 bit system, have a look at the end of the post before launching the make.

--  SAFE START --
Install tools:
sudo apt-get install kernel-package fakeroot
(if you use apt-bugs you may get a warning about an lguest bug. Ignore it. Look at the bottom of the post for 32 bit issues and a simple solution.)


Get the latest STABLE release from http://kernel.org/
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.8.tar.bz2
It's 75 M and will take a wee while.
tar -xvf linux-3.2.8.tar.bz2
cd linux-3.2.8/

To get a head-start on a configuration file, see if you have one for your current kernel:
ls /boot/config-`uname -r`

If so (I know this is clunky, but the obvious solutions didn't work...)
echo "/boot/config-`uname -r` "|xargs cat > .config

I'm running 3.2.0-1.

Alright. Here's the thing. You shouldn't edit .config unless you know what you're doing. But then how will you ever learn? I don't yet know what I'm doing, so won't lead you into kernel-configuration related temptation.

Instead, we'll just learn how to build.

First
make oldconfig
which uses the .config

But it's not completely automatic -- when it comes to new features you'll have to provide input. Hitting enter i.e. accepting the default option is probably a good idea unless you think otherwise.

Alternatively, you do
make menuconfig
and pick everything you want


Here are the new features in 3.2.8 vs 3.2.0-1: 
  Cirrus Logic (Sound Fusion) New DSP support (SND_CS46XX_NEW_DSP) [Y/n/?] (NEW)
Agere Systems HERMES II Wireless PC Card Model 0110 (WLAGS49_H2) [N/m/?] (NEW)
 Linksys HERMES II.5 WCF54G_Wireless-G_CompactFlash_Card (WLAGS49_H25) [N/m/?] (NEW) 
Y means compile into kernel, m makes a loadable module and no means no.

Now build!
make-kpkg clean
The next step takes forever, in particular if you only use one core (>1 h). It takes ca 50 minutes on an i5 with the -j5 switch. You'll also need around 6.5 Gb of free space for the compilation.
fakeroot make-kpkg -j4 --initrd --revision=3.2.8 kernel_image kernel_headers

where as usual 4 is the number of cores(3)+1. Adjust as necessary.

--SAFE END--

This really isn't dangerous, although you may not want to do it remotely without a back-up plan.

Install with
sudo dpkg -i ../linux-image-3.2.8_3.2.8_amd64.deb
sudo dpkg -i ../linux-headers-3.2.8_3.2.8_amd64.deb

That's it! You don't even have to bother with update-grub.

Reboot at your convenience and admire your handiwork:
uname -a

Linux boron 3.2.8 #2 SMP Wed Feb 29 19:27:04 EST 2012 x86_64 GNU/Lin

The deb built this way is ca 33 M, while the stock debian 3.2.0--1 is a slim 23 M.

Once you're confident that you can compile and install a kernel without mishap you can start to remove kernel modules to make it slimmer -- or start including modules of your own choosing.


Tried and tested on:
AMD Athlon II X3 (64 bit)
2 x AMD Phenom II X6 (64 bit)
Intel i5-2400 (64 bit)
Intel core 2  duo T5870 (laptop, 64 bit)
Intel Celeron 1.6 GHz (32 bit)
-- all running debian testing.


Building on 32 bit

I had some issues on an Intel Celeron 1.6 GHz 32 bit due to a bug:
make[1]: Leaving directory `/home/me/tmp/linux-3.2.8'
/usr/bin/make    ARCH=i386 \
    -C Documentation/lguest
make: *** Documentation/lguest: No such file or directory.  Stop.
make: *** [debian/stamp/build/kernel] Error 2

The failure was pretty annoying...
real 157m58.192s
user 132m27.049s
sys 12m5.589s
There's a simple solution in a forum post at http://billy.com.mx/archives/660:

"I solved it by creating a symlink Documentation/lguest to Documentation/virtual/lguest"
that means (on one line)
ln -s /home/me/tmp/linux-3.2.8/Documentation/virtual/lguest  Documentation/lguest


That's all.


Check:
ls Documentation/lguest -lah
Documentation/lguest -> /home/me/tmp/linux-3.2.8/Documentation/virtual/lguest

ls Documentation/lguest/
extract  lguest.c  lguest.txt  Makefile

And once it's installed:
uname -a
Linux kookaburra 3.2.8 #3 SMP Thu Mar 1 14:43:45 EST 2012 i686 GNU/Linu


Modules
To get a list over the modules in use on your current system:
lsmod | gawk '{printf("%s ",$1)}'| sed 's/Module//g'

zlib_deflate crc32c libcrc32c ufs qnx4 hfsplus hfs minix ntfs vfat msdos fat jfs xfs reiserfs ext3 jbd ext2 pci_stub vbok8 mperf cpufreq_stats cpufreq_conservative cpufreq_powersave cpufreq_userspace ppdev bnep rfcomm bluetooth binfmt_misc as nfs_acl sunrpc kvm_amd kvm xt_state ipt_REJECT ipt_LOG xt_limit xt_tcpudp xt_conntrack iptable_mangle ipt_MASQUERADE ip
le_filter ip_tables x_tables hwmon_vid lp loop snd_hda_codec_hdmi arc4 rt2800usb rt2800lib crc_ccitt rt2x00usb rt2x00lib xer_oss snd_usb_audio snd_pcm snd_hwdep snd_usbmidi_lib nvidia hid_logitech_dj mac80211 joydev snd_seq_midi cfg80211 rfki5100_tco snd_timer snd_seq_device edac_core edac_mce_amd parport_pc parport snd i2c_piix4 soundcore pcspkr k10temp i2c_combcache jbd2 crc16 usb_storage uas sd_mod crc_t10dif ata_generic pata_atiixp ohci_hcd thermal thermal_sys floppy ahci lib
You can use that as a source of inspiration for what to keep and what to trim.


88. Building Apache 2.4.1 on Debian Testing

WARNING:
Don't remove your existing installation of apache2 without thinking. gnome-core depends on it.

Updated 1 March 2012. Added missing information which prevented building and now provide information about auto-start using an /etc/init.d/ script. Original post at 2012-02-23

Building
 A new version of apache is kind of a big deal. Here's how to build it.

sudo apt-get install libapr1-dev uuid-dev libaprutil1-dev libmysqlclient-dev libpq-dev libsqlite3-dev rcconf
wget http://apache.mirror.aussiehq.net.au//httpd/httpd-2.4.1.tar.gz
tar -xvf httpd-2.4.1.tar.gz
cd httpd-2.4.1/
./configure
make -j5

where 5 is the number of cores+1. Four-core i5 => 4+1=5.

To install run
sudo make install
or
sudo checkinstall
sudo dpkg -i *.deb


Done.


sudo checkinstall won't work unless you first
sudo mkdir -p /usr/local/apache2/modules
(see comment below by Y&S who pointed this out)

If you don't create the directory first, you get
/usr/share/apr-1.0/build/libtool --silent --mode=install install mod_allowmethods.la /usr/local/apache2/modules/
ranlib: could not create temporary file whilst writing archive: No more archived files
make[3]: *** [install-modules-yes] Error 1
make[3]: Leaving directory `/home/me/tmp/httpd-2.4.1/modules/aaa'
make[2]: *** [install-recursive] Error 1
make[2]: Leaving directory `/home/me/tmp/httpd-2.4.1/modules/aaa'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/home/me/tmp/httpd-2.4.1/modules'
make: *** [install-recursive] Error 1
****  Installation failed. Aborting package creation.

Anyway, your compiled httpd is now in /usr/local/apache2/bin/httpd
In my case /usr/local/apache2/bin is not in my PATH -- whether you want to add it or not is a matter of choice.

In order for you to bind your own httpd to port 80 you need to stop apache2 if it is running
sudo service apache2 stop


Test your build:
me@tantalum:~$ /usr/local/apache2/bin/httpd -v
Server version: Apache/2.4.1 (Unix)
Server built:   Feb 23 2012 11:51:26
So far, very easy.

I've tried it on amd64 and i386 debian testing machines.

Replacing old version of apache2
Don't try to remove apache2.2-bin since gnome-core depends on it:
http://www.linuxformat.com/forums/viewtopic.php?p=101538

The easiest way to deal with this is to do
sudo rcconf 
and de-select apache2. This way it's still installed, but won't run as a rc service.

Making it boot -- init.d script
I had a look at this: http://www.cyberciti.biz/tips/linux-write-sys-v-init-script-to-start-stop-service.html

And here's my /etc/init.d/httpd script

#!/bin/bash
# description: apache2 httpd 2.4.1 server
# Start the service httpd
start() {
        /usr/local/apache2/bin/httpd &
        echo "Up and running"
}
# Restart the service httpd
stop() {
        killall httpd
        echo "Killing httpd"
}
### main logic ###
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  *)
        echo $"Usage: $0 {start|stop}"
        exit 1
esac
exit 0
Don't forget to chmod+x


Finally,
sudo rcconf
and select httpd (it'll be at the bottom of the list)

It's not the prettiest of scripts, and you can probably do better by editing /etc/init.d/apache2

87. Polyoxometalate Molecules - povray images

Here's a bunch of povray generated figures of polyoxometalates. I've spent too much time on them not to share them. You may use them freely in posters, websites or talks.
Leave a comment if you want the original POV files.


alpha-Mo8

alpha-Mo8 -- octamolybdate

alpha Mo8 -- octamolybdate

beta-Mo8 -- octamolybdate

beta-Mo8 -- octamolybdate




Hexamolybdate -- Mo6O19

Decaniobate -- [Nb10O28]6-

Decaniobate -- [Nb10O28]6-

Eicosaniobate -- dodecaniobate --[Nb20O54]

Eicosaniobate -- dodecaniobate --[Nb20O54]

Hexaniobate -- lindqvist ion -- [Nb6O19]8-

Hexaniobate -- lindqvist ion -- [Nb6O19]8-

Peroxo- hexaniobate --[Nb6O13(O2)6]8-

Para-Mo7 -- para hepta molybdate

Para-Mo7 -- para hepta molybdate

Para-W7 -- para hepta tungstate

Para-W7 -- para hepta tungstate

Tetrasiliconiobate -- Si4Nb16

Tetrasiliconiobate -- Si4Nb16

Siliconiobate -- SiNb12 -- keggin ion

Siliconiobate -- SiNb12 -- keggin ion

Hexatantalate - [Ta6O19]8-

Superlindqvist -- [Ti12Nb6O44]10- 
Superlindqvist -- [Ti12Nb6O44]10- 

[Ti2Nb8O28]8- -- dititanoniobate

[Ti2Nb8O28]8- -- dititanoniobate

[TiNb9O28]7- -- monotitanoniobate

[TiNb9O28]7- -- monotitanoniobate

W10 - decatungstate

W10 - decatungstate

W12 -- dodecatungstate

W12 -- dodecatungstate

W12 -- dodecatungstate

Hexamolybdate -- lindqvist ion -- [Mo6O19]8-