Building a 64studio alike kernel...

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
studio32

Building a 64studio alike kernel...

Post by studio32 »

I think here is some useful information:
Though 64Studio has a very good kernel by default, it is sometimes needed to compile a new kernel from source. Here is my lengthy post, copy and paste - but remember, no warranty.. comments are welcome!

This writing is about my experiences with configuring a kernel for realtime and compiling ALSA to go with the new kernel. The latest source for Linux (aka. kernel - duh..) is available at http://www.linux.org, downloadable as a bzipped (.bz2) tar-file. Also required are the latest sources for ALSA from alsa-project.org, now at version 1.0-16. My distribution is 64Studio, which uses Ingo Molnars realtime patch in the kernel. Molnars patches are available at http://www.kernel.org/pub/linux/kernel/projects/rt. Make sure the number of the patch is the same with the version of kernel source you have downloaded. If the numbers are incompatible, the patch will not work. Using a realtime configured distro as a base makes sense because you can use a reliable kernel configuration from where to start modifying your kernel. Also required are some tools, that can be installed via apt-get. They are ncurses5-devel and kernel-package. The kernel will be compiled "Debian-way" to an installable .deb-package with make-kpkg. Ncurses-devel is required for a menu based version of "make config" - that is, "make menuconfig". Usually kernel source is downloaded and unzipped to the directory /usr/src, but I prefer doing it in my home directory and there in a subdirectory called kernel. ALSA sources will be downloaded and compiled there too, in a directory kernel/alsa. All work from now on will be done in a terminal. After downloading is complete, I bunzip the sources.

cd kernel; tar xjvf linux-(latest-version).tar.bz2

It is customary to create a symbolic link named linux to the kernel source directory.

ln -s linux-(version-number) linux

Then unzip ALSA.

cd alsa; for i in alsa-*.bz2;do tar xjvf $i; done

Change to your kernel source directory.

cd ../linux

Copy your running kernel configuration to new kernel source directory, naming it to ".config".

cp /boot/config-(your running kernel version) .config

Now patch the kernel.

bzcat ../your-molnar-patch-number.bz2 | patch -p1

Now start the configuring and compiling process.

make menuconfig

This is the stage, where you can alter things as you wish regarding your kernel. First of all I changed the setting in "Processor type" to match my processor. My machine is an old 1.2GHz Duron, so the processor architecture changed to "Athlon/Duron". Considering that I am going to compile the latest ALSA source for my new kernel, I remove all alsa driver modules from the kernel, but I make sure alsa and OSS support are present. This is done by moving with arrow keys to the line "Device drivers/Sound" and choosing and unchoosing with the spacebar. So, all said and done, I exit and save the new configuration as prompted. It is time to compile.

make all

This stage takes a lot of time depending on your machine power. Make a cup of your preferable bewerage and perhaps read something - it's not a bad idea anyways.. Check up every now and then whether your terminal has returned to the prompt. If so, you can start making the kernel package.

make-kpkg -initrd kernel_image kernel_headers

Kernel headers are needed to make sure ALSA will compile cleanly - just to be sure. Also those who use display drivers distributed by Nvidia will need kernel headers, because the Nvidia drivers will not move to the new kernel without recompiling and reconfiguring. I recommend configuring your system to use the generic nvidia driver (nv) with

dpkg-reconfigure xserver-xorg

before rebooting. This will make sure you have some type of graphic display after installing and rebooting to the new self compiled kernel. After make-kpkg finishes you have new kernel package in the parent directory linux, aka. /home/username/kernel. The package is recognised by the filename ending with .deb. Now you can install both the kernel and kernel headers as root.

su - (The - option changes path to the /root directory and takes roots path variables into action) dpkg -i /home/username/kernel/new-kernel-version.deb new-kernel-version-headers.deb

Using dpkg is a good idea, because it finds your current GRUB configuration and adds your working kernel to the new bootloader configuration. This way you'll have fallback plan available if something goes wrong. It shouldn't because you merely copied your old (working) kernel configuration to new kernel - for the most part. The new kernel does not need alsa driver modules to boot. Now reboot.

sudo shutdown -r now

At the bootloader I choose single user (root) option as to be sure the kernel will boot. Once the system up and running I change to the alsa source directory, /home/username/kernel/alsa. The first to be compiled are the drivers - so:

cd /home/yourusername/kernel/alsa/alsa-driver-xxx ./configure --with-sequencer=yes --with-oss=yes --with-cards= && make && make install

Then the libraries.

cd ../alsa-lib-xxx ./configure && make && make install

The most important alsa software to install are the drivers, libraries and alsa utilities. Depending on your system you will have to check for other alsa software to install. The directory alsa-tools-xxx contains some soundcard spesific tools such as envy24control for users with envy24-chipset based cards (M-Audio Delta series) or for users with RME cards; hdspmixer, hdspconf.. Configure, compile and install as before. Once all alsa software is installed, configure your alsa system.

alsaconf

After this program has finished give the commands:

/etc/init.d/alsa restart alsactl store

Reboot and start using your new kernel. Users of Nvidias drivers will have to compile and install their drivers once again before rebooting - remember what I said about the kernel headers..? If the new kernel doesn't work you'll always have your default kernel available through the GRUB bootloader, so no harm done.

TIP: To avoid the hassle of rebooting you can use dropping your system to single user mode. This is done by changing to a virtual terminal with ctrl+alt+F1 and issuing the command: init 1. A reboot is necessary only after installing a new kernel. Single user mode in Linux requires root users password, so don't do it unless you know that. Normal running mode in Debian based systems is: init 2 (GDM,X-display, hald etc. will start).
Check this topic with also some comments http://64studio.com/node/504

edit: this is the config file of the kernel:
http://pastebin.com/f2731c136
Last edited by studio32 on Thu Dec 04, 2008 5:39 pm, edited 1 time in total.
studio32

Re: Building a 64studio alike kernel...

Post by studio32 »

In the message above, that guy is talking about

'compiling ALSA to go with the new kernel'

I didn't read it before when someone was building a rt kernel...

Is this step needed, why or why not?
studio32

Re: Building a 64studio alike kernel...

Post by studio32 »

studio32 wrote:In the message above, that guy is talking about

'compiling ALSA to go with the new kernel'

I didn't read it before when someone was building a rt kernel...

Is this step needed, why or why not?
anyone please?
thorgal
Established Member
Posts: 739
Joined: Mon Apr 07, 2008 6:04 pm

Re: Building a 64studio alike kernel...

Post by thorgal »

studio32, you sound desparate :lol:

OK, 64studio is debian, so a simple google on debian + realtime kernel gives you this useful forum thread :

http://forums.debian.net/viewtopic.php?t=17035

it's the debian RT kernel quickie recipe. It is updated, as you can see in the post. It's been there for a long time ;)

I suggest you stick to 2.6.25 or 2.6.24 (2.6.25 was not a success for me).
Good luck :)
studio32

Re: Building a 64studio alike kernel...

Post by studio32 »

Thanks, but the question was about the ALSA part... (check first message)..

If I'm right I don't see the need of building ALSA against the kernel in the Debian thread...

And about the kernel versions, the people of 64studio say that kernels from 2.6.22... doing pretty bad when it comes to realtime...
thorgal
Established Member
Posts: 739
Joined: Mon Apr 07, 2008 6:04 pm

Re: Building a 64studio alike kernel...

Post by thorgal »

ok, the alsa compilation is only optional. The kernel comes with a certain version. If you want to try out the latest alsa, do as described.

By the way, the description is a bit lengthy. Here is what I do (as root):

download kernel package
untar/uncompresse kernel package somewhere
go to kernel source dir
patch with RT patch corresponding to kernel version
copy old kernel config file /boot/config-blabla to a file called .config (you need the .) to kernel source dir
make oldconfig (if you have already full preemption in old kernel, there's not much to do, just see if the new options that pop up during make oldconfig are needed, usually no)
then, build kernel the debian way:
make-kpkg --append-to-version -rt --initrd kernel_image kernel_headers

wait a bit

you will get 2 packages, linux-image and linux-headers outside the kernel source dir (cd ..)
install them :

dpkg -i linux-image-blabla linux-headers-blabla

for the ALSA part, just do as the guy says. But only if you do need the latest ALSA.

If you want to use the closed source nvidia driver, just download from the nvidia website,
and as root, run the installer. It will build the kernel driver against the your newly compiled kernel (after you had rebooted with it). Otherwise, if you are not yet rebooted, just add -k new-kernel-version to the nvidia installer command line.
Post Reply