New User? Register here - Existing Users: Username: Password: [Advanced Login]

 

 

Current Poll

Your preferred Interactive shell?









( 1358 votes ~ 15 comments )

 

Weblog entry #1 for jonesy

32-bit debian with 64-bit kernel
Posted by jonesy on Tue 7 Nov 2006 at 05:22
Tags: none.
had to install 32bit Debian GNU/Linux on an AMD Opteron 64bit system recently, and it was not quite as straightforward as it may seem to get it running with a custom 64-bit kernel, so hopefully these instructions will save you some time and mucking about.

The reason I needed the 64-bit kernel was that I had 8GB of memory which I wanted MySQL to be able to use.

Had all my hardware been supported by the stock debian amd64 kernel, this article would be very short and consist of two steps;

apt-get install kernel-image-2.6-amd64-k8 amd64-libs
shutdown -r now

Unfortunately my MegaRAID RAID controller isn't supported by the stock debian amd64 kernel, so it seemed a recompile was necessary. I could have used the standard kernel built process, but as I'm a debian user, I wanted to compile the kernel the debian way.

Since my system was currently running a 32bit 2.4 kernel, I had to cross-compile the 2.6 kernel for 64-bit.

These steps may not be exact, as it's a while since I actually did the compile, so feel free to leave a comment if I've got something wrong and I'll correct it.

First of all, you'll need to apt-get some packages:

apt-get install amd64-libs kernel-packages libncurses5-dev lib64gcc1 lib64stdc++6 bzip2 gcc-3.4

Say yes to any dependencies.

Next download the latest kernel sources to /usr/src, extract them and copy the current config if desired;

cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.2.tar.bz2
tar jxvf linux-2.6.18.2.tar.bz2
ln -s linux-2.6.18.2 linux
cd linux
cp /boot/config-2.4.27-bf24 .config

Now you can run the configuration gui (I choose to use the ncurses gui, but you could just as easily use the standard make config - it's much more fiddly). The ARCH=x86_64 is very important, this is what says what architecture we will be compiling for.

make menuconfig ARCH=x86_64

Go through and change any kernel options you need to (in my case enabling MegaRAID). Make sure you enable IA32 emulation or your 32-bit userland will not run!

Now comes the actual compile, and to use make-kpkg you will need some wrapper scripts which pass the flags to the compiler and linker which specify 64-bit, you can get the wrappers from my site http://www.haqthegibson.com/files.php or extract them out of the debian 64bit kernel source package yourself. unzip the archive and copy the files inside to somewhere on the path, eg /usr/bin, make sure that they're executable. Then run this, to compile your new kernel.

make-kpkg --arch amd64 --append-to-version custom_amd64 --initrd kernel_image

The compile will take a while, so go and make a coffee.

Once the compile is done, it's time to install the package you've created:

cd /usr/src
dpkg -i kernel-image-2.6.18.2_custom_amd64.0.1_amd64.deb

Now you should be able to reboot into your new 64 bit kernel. After the reboot, if all has gone well, uname -a should produce something like this

Linux db6 2.6.18.2 #1 SMP Mon Oct 16 14:31:52 GMT 2006 x86_64 GNU/Linux.

Congratulations, you now are running a 64-bit kernel!

 

Comments on this Entry

Posted by dkg (216.254.xx.xx) on Thu 9 Nov 2006 at 11:52
[ Send Message | View dkg's Scratchpad | View Weblogs ]
Thanks for the writeup! if i have no compelling reason to use a vanilla kernel, i tend to prefer starting with the debian sources, and just modifying the .config file in whatever small way i need. the key here is:
apt-get install linux-source-2.6.18
(or, if you are running sarge or earlier:
apt-get install kernel-source-2.6.18
That will get you the debian kernel source with all debian-specific patches.

If all you really need is a specific module, you might be able to just build the module itself against the debian kernel sources, and install it by hand.

Out of curiousity, what megaraid module did you need? megaraid modules appear to present in sarge:

[0 dkg@grunt dkg]$ grep -i megaraid /boot/config-2.6.8-3-686 
CONFIG_SCSI_MEGARAID=m
[0 dkg@grunt dkg]$ 
and in etch:
[0 dkg@squeak ~]$ grep -i megaraid /boot/config-2.6.17-2-686 
CONFIG_MEGARAID_NEWGEN=y
CONFIG_MEGARAID_MM=m
CONFIG_MEGARAID_MAILBOX=m
CONFIG_MEGARAID_LEGACY=m
CONFIG_MEGARAID_SAS=m
[0 dkg@squeak ~]$ 
(these are admittedly the 686 kernels, and not the amd64 kernels; if the two flavors are built to support different hardware, i'd find that surprising)

What kernel configuration change did you find you needed to make, specifically? can you do a diff of the two different kernel configurations?

[ Parent | Reply to this comment ]

Posted by Steve (62.30.xx.xx) on Sat 23 Dec 2006 at 14:15
[ Send Message | View Steve's Scratchpad | View Weblogs ]

Thanks a lot for the recipe. I'm currently compiling my first 64 bit kernel on my new machine.

Only error I could see was you said "kernel-packages" not "kernel-package", otherwise it seems to be going well. (I'm using a more recent kernel too)

Steve

[ Parent | Reply to this comment ]

Posted by Anonymous (81.5.xx.xx) on Wed 9 Apr 2008 at 23:20
the gcc script needs $ARGS wrapping in quotes otherwise it can break (2.6.24).

In fact, I changed it a little to:

#!/bin/sh

# This is a little wrapper script for building 64 bit kernels on i386 Debian
# (sarge). Taken from Debian source package for kernel-image-2.6.8-amd64.

#echo >&2 cc "$@"
M64="-m64"

for arg in "$@"; do
if [ "$arg" = "-m32" ]; then
M64=""
break;
fi
done

gcc $M64 "$@"

[ Parent | Reply to this comment ]

 

 

Flattr