Showing posts with label Kernel. Show all posts
Showing posts with label Kernel. Show all posts

Tuesday, 22 November 2011

How to Recompile your Kubuntu 11.10 Kernel

This quick and simple guide will help you to recompile your Kubuntu 11.10 Kernel. Modify where appropriate, eg amd64 / i386.

1. Install these packages

sudo apt-get install fakeroot dpkg-dev libncurses5-dev kernel-package

2. Create your source directory

mkdir ~/src

cd ~/src

3. Download the Kernel source

apt-get source linux-image-$(uname -r)

4. Configure your Kernel

cd linux-3.0.0

make menuconfig

5. Speed up the build

export CONCURRENCY_LEVEL=3

General rule, concurrency level = number of processor cores + 1

6. Clean up temp files from a previous compile attempt (skip if necessary)

make-kpkg clean

7 Compile your Kernel

time fakeroot make-kpkg --initrd --append-to-version=-tweak kernel-image kernel-headers

You can change -tweak to anything you wish

8. Install your Kernel

cd ~/src

sudo dpkg -i linux-image-3.0.6-tweak_3.0.6-tweak-10.00.Custom_amd64.deb

sudo dpkg -i linux-headers-3.0.6-tweak_3.0.6-tweak-10.00.Custom_amd64.deb

9. Reboot

Your recompiled Kernel should automatically load.

Wednesday, 18 May 2011

Kernel bloat, the responsibility lies with the distribution vendor

It seems as time goes by the Linux Kernel is supporting more hardware and delivering more functionality. This is great but it introduces the problem of bloat. Bloat is bad but the fact of the matter is bloat cannot be avoided although it can be reduced.

Distribution vendors are the ones responsible for including more or less bloat in their Kernels and unfortunately the current trend is to simply include as much as possible without any thought whatsoever.

I was tinkering with Ubuntu 10.04 LTS (64-bit) a few days ago and found it very amusing that support for an S3 Trio graphics card was included in the 64-bit Kernel.

And a Voodoo 5, Cirrus Logic, Riva TNT....

Canonical Ltd has included support for various hardware (not just old ancient video cards) that no longer exists or even if it did, would no longer work on modern systems.

Even though most of these are compiled as Kernel modules and the impact on the core Kernel code size is minimal, there is no reason to include its support.

I can therefore only conclude that the reason why Canonical Ltd continue to include support for ancient unusable hardware and various other Kernel functionality that is deprecated is because they are lazy.

When was the last time a Kernel clean up exercise was performed?

But is it just Canonical Ltd who continue to bloat their Kernels unnecessarily with ancient hardware support and unused Kernel functionality?

Equally as time goes by hardware becomes obsolete and certain functionality unused but distribution vendors continue to include such support in their Kernels.

Saturday, 26 March 2011

Debian 6 - does it get the credit it deserves? Absolutely not!

Since becoming interested in Linux I haven't really paid much attention to Debian. My first ever encounter with Debian was with Debian 5 and on a very old Mitac Laptop with an AMD Athlon Mobile processor. That was a positive experience because unlike the releases of Fedora, openSUSE and Ubuntu at that time it was the only distribution that worked on this laptop. However, it was a very brief experience.

So here we are with Debian 6 which I have been waiting to try for a long time.


Debian is a 100% community project, there are no corporate sponsors with their own agenda behind Debian. Just volunteers giving up their time to make a free operating system. Therefore unlike Fedora, openSUSE and Ubuntu, Debian can genuinely claim to put the priorities of their users first.

Debian has a reputation for creating very stable distributions which is often attributed to their long testing periods, strict requirements for labelling software packages as stable and the fact that they avoid using the latest and greatest software.

Their distribution is also being used by a number of vendors as a base for their own distribution, most notably by Canonical Ltd who use Debian as a base for Ubuntu. Had Canonical Ltd used something else would they have been as successful as they are today?

Canonical Ltd's choice to use Debian has undoubtedly benefited the Debian Project but I think Debian are where they are today because they produce a good solid 'no nonsense' distribution with the user in mind.

Many of the other big distributions have further goals which in turn have a detrimental effect on the users needs. As a user I want stability, a well supported product, something that is easy to use and well documented.

Compare that to Fedora, its very nature to be a show case for the latest and greatest can affect stability, it rapidly changes in order to meet that aim and therefore lacks long term support and is hard to maintain documentation due to its continually changing nature.

Fedora is a great product that strives to lead the advancement of FOSS and does a superb job but the Fedora Project have to be careful on how they portray Fedora. With the release of Fedora 14 I noted a change in Fedora's marketing which is very appealing to new users. I understand the need for Fedora to attract new users but they have to be careful not to attract the wrong type of user or at least prevent certain expectations from occurring.

Back to Debian 6...

As with all operating systems, the starting point is to install it and on that note Debian has a very easy to use step-by-step installer that gets the job done. It is a good example of how simplicity can be effective.

Having a working internet connection does help when installing Debian but since Debian decided to remove firmware that may pose an inconvenience for some users. Personally I like the stance Debian have taken concerning the removal of non-free firmware.

During the install I was quite impressed with the fact that Debian explicitly asks the user whether or not they want to install grub, most distributions make the assumption that you do. For me this is a clear example highlighting the very fact that Debian places an emphasis on its users and understands that some have different requirements.

Initially I was disappointed with the lack of ability the Debian installer has to customize what software packages are to be installed. Instead Debian allows you to select from a list of software categories which include desktop, laptop, web server and others. I say initially because after booting into Debian I was very happy with the default packages installed. It seems like the categories available to select during the install provide a good choice of common and essential packages.

What really got my attention immediately after booting into Debian 6 was the font rendering. Out of the box Debian 6's font rendering is not only excellent but has to be one of the best I have seen. I take my font rendering very seriously and Debian tops my list for providing great font rendering.

When using the system, viewing files, folders and opening programs, the system response in Debian 6 could be better. This may be due to several reasons, Debian 6 uses kernel 2.6.32 and Gnome 2.30 which are many versions behind the latest. The significance being newer versions often include bug fixes and performance increases but also looking at the kernel config for the Debian 2.6.32 kernel reveals a timer frequency of 250Hz.

As an experiment I recompiled the kernel with the timer frequency at 1000Hz and did notice an improvement to the system response. I further compiled a more recent kernel, 2.6.38 which improved the system response even more and I would put this down mainly to the more recent nouveau driver.

So there are drawbacks to using older software, has Debian got the balance between software version and stability too much towards older software?

Overall if you are familiar with Ubuntu then you should be quite comfortable with Debian, enabling all the non-free repositories and installing multimedia codes is straightforward but not on the same level of ease as Ubuntu.

Iceweasel Annoyance

Due to branding issues Debian uses a version of Firefox with different branding. Essentially it is Firefox but because the browser identifies itself as Iceweasel to websites this can cause problems.

The fix is easy and documented by the Debian project, other annoyances include Gnash, an open source flash plugin installed by default that doesn't work well. Remove, install Adobe Flash, done.

I want a new version of OpenOffice

Keeping with tradition, Debian 6 has an older version of OpenOffice. I attempted to remove it but apt-get was automatically pulling in Abiword as a replacement. After going through synaptic I found the culprit,  a package called gnome-office. Once that was erased I could successfully remove OpenOffice without Abiword being pulled in as a replacement.

Debian 6 for a desktop user?

After using Debian 6, I can only conclude what others have already. There is no point using it over Ubuntu if you are a desktop user who wants something that requires minimum effort out of the box. Many users are not confident enough to setup the multimedia codecs or compile a kernel a more recent kernel to improve hardware support.

That said, I do not like some of the customizations Ubuntu provide. Apparmor, the social integration to Gnome, the kernel supports more hardware (more bloat), the font rendering is slightly different.

Debain in many ways reminds me of Fedora, out of the box it is very simple. I like that. I also do not mind taking the time to setup Debian. So for those reasons I personally would use Debian 6 over Ubuntu, with a tweaked and more recent kernel of course :-)

"Don't be afraid to try compiling the kernel. It's fun and profitable"

8.6.1. Kernel Image Management - http://www.debian.org/releases/stable/i386/ch08s06.html.en


Debian is a true community project that lerks in the shadows of Ubuntu and Mint, does it get the credit it deserves? Absolutely not!

Thursday, 17 February 2011

Linux Kernel will soon provide better Samsung Laptop support

As posted by Greg Kroah-Hartman on his blog,

Finally, after many years of people asking for this, Linux can now properly support all known Samsung laptop devices. This means we can now handle backlight control, wifi button issues,and the weird "performance mode" keys as well as some of the other function keys.

If you have a Samsung laptop, I suggest looking at the driver in this post on the linux-kernel mailing list, and letting me know if you have any problems with it or not. If your laptop is not listed in the DMI table, please feel free to send me a patch to add it so we can properly support it.

Many thanks to Samsung oh so long ago for providing some of the needed information to get this to work, and to Ingmar Steen for putting all of the pieces together properly to handle the devices that were not being handled by the old in-kernel driver.

http://www.kroah.com/log/linux/samsung_laptop.html posted Wed, 09 Feb 2011 in [/linux]

As a Samsung Laptop user I think this is great news but reading the mailing list and the kernel patch file I saw something interesting.

Some Samsung laptops have different "performance levels"
+ that are can be modified by a function key, and by this
+ sysfs file. These values don't always make a whole lot
+ of sense, but some users like to modify them to keep
+ their fans quiet at all costs. Reading from this file
+ will show the current performance level. Writing to the
+ file can change this value.
+ Valid options:
+ "silent"
+ "normal"
+ "overclock"
+ Note that not all laptops support all of these options.
+ Specifically, not all support the "overclock" option,
+ and it's still unknown if this value even changes
+ anything, other than making the user feel a bit better.

So it seems like there is some confusion as to what the performance levels should do. Well, based on my observations in Windows,

Silent

Set CPU frequency scaling to [Power Saver] + deactivate fan. But if temperature > [Active Fan Trip Point] activate fan on until temp < [Active Fan Trip Point + 10]

Or some other variable

[Active Fan Trip Point] is a BIOS set value which varies according to model/processor. On a Samsung R510 it is set to 71c

Normal 

Set CPU frequency scaling to [Balanced] + Activate BIOS fan control

Overclock
 
Set CPU frequency scaling to [Performance] + Activate BIOS fan control

A more appropriate label for 'Overclock' should be 'Performance'. In fact in Windows this performance level is referred to as 'Performance'

It is important that the Silent mode activates the fan if the [Active Fan Trip Point] has been reached, failing to do so will cause the processor temperature to continue rising until it reaches the critical shutdown temperature.

And not to mention the potential of causing many unhappy Samsung users, claiming Linux killed their laptop.

Sunday, 6 February 2011

How to compile a kernel from kernel.org in Ubuntu 10.04 LTS

This quick how-to is based on http://linuxtweaking.blogspot.com/2010/05/how-to-compile-kernel-on-ubuntu-1004.html

Open a terminal and work through the following set of commands.

Install these packages

sudo apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package libncurses5 libncurses5-dev

Run this

sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)

Create your source directory

mkdir ~/src
cd ~/src

Download and extract your kernel


You can browse for kernels at http://www.kernel.org/pub/linux/kernel/v2.6/ This guide is using kernel 2.6.37.

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.37.tar.gz
tar xvf linux-2.6.37.tar.gz
cd linux-2.6.37

Configure your Kernel

make menuconfig

Build your Kernel

export CONCURRENCY_LEVEL=3
make-kpkg clean
time fakeroot make-kpkg --initrd kernel-image kernel-headers

General rule, concurrency level = number of processor cores + 1


Install your kernel

cd ~/src

dir        
sudo dpkg -i linux-image-2.6.37_2.6.37-10.00.Custom_amd64.deb
sudo dpkg -i linux-headers-2.6.37_2.6.37-10.00.Custom_amd64.deb

Create the initramfs image

sudo update-initramfs -c -k 2.6.37

Update your grub.cfg

sudo update-grub

Reboot your system


Enjoy your new kernel.

Thursday, 3 February 2011

openSUSE 11.3 with KDE 4.6 (mini review)

Despite the troubles in Novell / Attachmate land, openSUSE remains strong and focused with the availability of KDE 4.6.


Another update to KDE, it's now on version 4.6. Thinking back to the very first KDE 4.x release, there is no doubt that the KDE team have made a lot of progress to this date.

As a desktop environment KDE provides a modern looking and stylish desktop that feels fast and has plenty of eye candy.

Being a KDE fan I decided to give KDE 4.6 a go with openSUSE 11.3 since openSUSE provides the most polished user experience with KDE. By default openSUSE 11.3 ships with KDE 4.4.4 but the team have provided a stable KDE 4.5 repository which I highly recommend.

I believe plans for a stable KDE 4.6 repository are underway but at the moment openSUSE users have the option of using the Factory openSUSE KDE 4.6 repo. Essentially this provides an upstream version of KDE with openSUSE patches which is in the progress of being tested.

So after upgrading openSUSE 11.3 to KDE 4.6, in comparison to KDE 4.5.x there really isnt much difference apart from the odd visual and application tweaks here and there.

Disappointing?

Far from it, under the hood KDE 4.6 has undergone significant changes, such as the removal of HAL and shift to udev, upower and udisks. Improvements to kwin have resulted in a better performance. Overall I am more happy with the lack of obvious changes because I feel it illustrates KDE 4.x is starting to stabilise and mature into a rock solid desktop environment,

End users such as myself are starting to get tired of drastic changes with each update of KDE, the release of 4.6 makes a nice change and hopefully marks a new stage for KDE. A stage that will perhaps focus a bit more on the end user.

So if you are serious about KDE, get openSUSE 11.3.

Smoke some Tumbleweed

If the excitement of KDE 4.6 isn't enough, then why not try the openSUSE Tumbleweed repository?

As announced not so long ago, openSUSE is looking into the possibility of becoming a rolling release.Simply add their Tumbleweed repository to your system to benefit from more up to date and stable packages.Currently this includes kernel 2.6.37.

openSUSE 11.3, KDE 4.6 and Kernel 2.6.37 at more or less at the click of a button!

Tuesday, 25 January 2011

How to compile a kernel from kernel.org in Fedora 14

This quick guide will show you how to compile and install a kernel from kernel.org in Fedora 14.

Start


Open a terminal and work through the below list of commands. Modify where appropriate.


Install the following packages

su -c 'yum install rpmdevtools yum-utils gcc make ncurses-devel'

Setup your build environment

rpmdev-setuptree

Download and extract your Kernel source

cd ~/rpmbuild/SOURCES

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.37.tar.gz

tar -xf linux-2.6.37.tar.gz

Configure and Compile it

cd linux-2.6.37

make menuconfig

export CONCURRENCY_LEVEL=3

time make rpm

General rule for concurrency level = number of processor cores + 1


Install it

cd ~/rpmbuild/RPMS/x86_64

su -c 'rpm -ivh --force kernel-2.6.37-1.x86_64.rpm'

cd /boot

su -c 'mkinitrd initramfs-2.6.37.img 2.6.37'

su -c 'vi grub/grub.conf'

Fedora 32-bit users replace x86_64 with i386

Edit your grub.conf file and add an entry for your new kernel. Just copy your first kernel entry and modify it.

Note: Please do not copy this grub.conf, it is for illustrative purposes only.

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/sda1
#          initrd /boot/initrd-[generic-]version.img
#boot=/dev/sda1
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu

title Fedora (2.6.37)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.37 ro root=UUID=162b11c2-d9a1-4487-86d5-6ade5c5ee055 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=uk rhgb quiet
        initrd /boot/initramfs-2.6.37.img

title Fedora (2.6.35.10-74.fc14.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.35.10-74.fc14.x86_64 ro root=UUID=162b11c2-d9a1-4487-86d5-6ade5c5ee055 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=uk rhgb quiet
        initrd /boot/initramfs-2.6.35.10-74.fc14.x86_64.img

title Fedora (2.6.35.6-45.fc14.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.35.6-45.fc14.x86_64 ro root=UUID=162b11c2-d9a1-4487-86d5-6ade5c5ee055 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=uk rhgb quiet
        initrd /boot/initramfs-2.6.35.6-45.fc14.x86_64.img

title Other
        rootnoverify (hd0,4)
        chainloader +1

Boot from your new kernel


Restart your system and enjoy your new kernel.

Saturday, 18 December 2010

Realtek gigabit network performance in Linux sucks

Recently I have been doing a lot of network file transfers between a few PCs but the very slow transfer speed of a 100Mbps connection has been making things too time consuming.

This equates to a maximum theoretical speed of 12.5 MB/s.

How did I work that out?

Since there are 8 bits in 1 byte, 100 Megabits / 8 = 12.5 Megabytes

Any modern system should easily achieve up to 12 MB/s.

So I decided to get a gigabit switch and upgrade my home network for as cheap as possible :-)

A gigabit connection is 10 times the speed of 100Mbps and therefore has  a maximum theoretical speed of 125MB/s.

All my systems feature gigabit NICs, so no additional expense required on that part at least for now. As for the switch, you do have to be careful when buying a cheap gigabit switch, many claim to be gigabit but suffer from poor performance.

A quick look on www.ebuyer.com revealed a Tenda 8 port Gigabit switch for £24.99 which looked promising, customer feedback on Ebuyer was positive.

The switch itself has a very solid feel and construction with a quality finish, made in China of course.



The instruction manual was also very encouraging.




How did it perform?

Many people are often under the impression that with a gigabit connection you will automatically be able to send or receive at near gigabit speeds, this is not quite the case.

Other hardware components in your PC will have an effect on the transfer speeds and your gigabit network transfer rate will be reduced by the slowest influential component in your PC.

For example if your hard drive can only read at 70MB/s then it would be impossible for this PC to send data at a faster speed than it is physically capable of.

Lets build on this example, if the PC receiving the data has a hard drive with a write speed of 40MB/s, this further bottleneck will limit the transfer speed even more.

Overall the speed of every network file transfer transaction is determined by the PCs taking part in the transaction.

With a 100Mbps (aka 12.5MB/s) network connection it is easy to over look how other hardware components can impact performance since most systems are able to handle data at speeds well beyond 12.5MB/s.

The test setup

System A

AMD Athlon II X2 250
ASUS M4A785TD-V EVO
4GB Patriot Gamer Series 1600Mhz DDR3 7-7-7-20
500GB Samsung SpinPoint F3 Hard Drive
Realtek RTL8112L Gigabit LAN controller
Windows 7 HP x64 / Ubuntu 10.04 x64

System B

AMD Athlon II X2 240
ASUS M3A78-T
4GB G.Skill PQ Series PC2-8000 5-5-5-15
500GB Samsung SpinPoint F3 Hard Drive
Marvell 88E8056 Gigabit LAN controller
Ubuntu 10.04 x64 / Windows 7 HP x64

Notes
Both systems have a 500GB Samsung SpinPoint F3 hard drive which is capable of read/write speeds of about 125MB/s - 140MB/s
System A was also tested with Fedora 14, openSUSE 11.3 and Ubuntu 10.10
Cat5e UTP Cable, 8 meters and 12 meters

Results 

1. System A (Windows 7 x64) / System B (Ubuntu 10.04 x64)

Copying a 17GB compressed file from System B to System A produced speeds of 109MB/s to 110MB/s
Copying the same file back from System A to System B produced identical speeds.

Not bad given a 1000Mbps is theoretically possible of delivering 125MB/s.

2. System A (Windows 7 x64) / System B (Windows 7 x64)

Same speeds as test 1.

3. System A (Ubuntu 10.04 x64) / System B (Ubuntu 10.04 x64)

Copying a 17GB compressed file from System B to System A produced speeds of  37MB/s to 40MB/s
Copying the same file back from System A to System B also produced speeds of 37MB/s to 40MB/s.

Very disappointing.

4. System A (Ubuntu 10.04 x64) / System B (Windows 7 x64)

Same speeds as test 3

Conclusion

System A was able to deliver good speeds only with Windows 7.
System B was able to deliver good speeds with Windows 7 and Linux.

System A suffered from a performance hit when using a Linux operating system.

Clearly Linux does not suffer from poor gigabit network performance, if this were true System B would have displayed similar results to System A, i.e. poor performance in Linux.
 
Why does System A perform poor with Linux?

The answer lies with the pathetic Linux drivers (r8169.ko) Realtek have provided for the Realtek RTL8112L Gigabit LAN controller featured in System A.

Even using drivers from Realtek's slow loading website (r8168.ko) resulted in the same miserable performance.

Does this apply to all Realtek Gigabit controllers that rely on the r8169 kernel driver or is it only the Realtek RTL8112L Gigabit LAN controller that is affected?

Searching on Google implies its a widespread issue with Realtek Gigabit controllers that use the r8169.ko.

But wait there's more..

I am also experiencing another issue with the Realtek network controller on System A.

Restarting Windows then booting into Linux causes the Realtek network controller to cease working.

The solution to get the Realtek back up and running is to power the system completely off including the mains or PSU switch, wait for a few minutes then boot directly into Linux.

In future I will try to avoid purchasing motherboards with Realtek Gigabit network controllers or alternatively purchase a Network card such as the Intel Gigabit PRO/ 1000CT PCIe adapter.

Realtek = POS

Monday, 3 May 2010

How to compile a kernel on Ubuntu 10.04

The Ubuntu wiki does provide the necessary documentation to allow users to build their own Linux kernel but in a rather disorganised way.

They should restructure it and provide clear detailed steps for each release and not the current mish-mash of old and new.

How about giving each release their own dedicated wiki page?

Original Ubuntu wiki: https://help.ubuntu.com/community/Kernel/Compile

First steps

Install the required tools and packages.

Open a terminal and type the following,

sudo apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package libncurses5 libncurses5-dev

Then run the following command,

sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)

And finally type,

mkdir ~/src
cd ~/src
apt-get source linux-image-$(uname -r)
cd linux-2.6.32

At the time of writing 2.6.32 was the current kernel source, it should remain at this version throughout the life of Ubuntu 10.04

It is a good idea to start with the same .config as the currently running kernel, so type the following,

cp -vi /boot/config-`uname -r` .config

Now we are ready to customize the build and kernel options.

make menuconfig

Once you have finished, save and exit. It is now time to compile. However to speed up the build if you have a dual core processor type,

export CONCURRENCY_LEVEL=3

The general rule is 1 + the number of processor cores.

make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-some-string-here kernel-image kernel-headers

Remember to substitute the writing in green for something else, for example -alpha

After a few minutes or hours your kernel compile will be complete. The next step is to install it.

The kernel package will be created in the parent directory of ~/src/linux-2.6.32 (i.e. ~/src)

cd ~/src
sudo dpkg -i linux-image-2.6.32.11+drm33.2-alpha_2.6.32.11+drm33.2-alpha-10.00.Custom_amd64.deb
sudo dpkg -i linux-headers-2.6.32.11+drm33.2-alpha_2.6.32.11+drm33.2-alpha-10.00.Custom_amd64.deb

Please note the text in green must be changed to reflect your version.

We are almost ready, prior to 10.04 the initramfs kernel image was automatically created. The Ubuntu wiki suggests using the scripts to create the image but I have been unsuccessful in using this method, hence the manual approach.

sudo update-initramfs -c -k all

BUG:  Please use the alternate method described below as this command fails to create an image for your new kernel. Special thanks to Helios38. - 16/06/2010


Alternatively if you know the kernel version, substitute the word all with the kernel version.

Example, sudo update-initramfs -c -k 2.6.32.11+drm33.2-alpha

Finally we need to add the initramfs image to the grub.cfg file located at /boot/grub/grub.cfg.

For the easy and automatic method as oppose to manually editing the grub.cfg file, just type the following,

sudo update-grub

Now just reboot and your new kernel should automatically load.

How to remove your  kernel

sudo dpkg -r linux-headers-2.6.32.11+drm33.2-alpha
sudo dpkg -r linux-image-2.6.32.11+drm33.2-alpha
sudo rm /boot/initrd.img-2.6.32.11+drm33.2-alpha

Enjoy compiling your own kernels.

Monday, 12 April 2010

OpenSUSE 11.2 - How to compile a Kernel for Newbies

There are many reasons to compile your own kernel, for example adding hardware support, improving system performance or just for educational purposes.

Methods vary across distributions and within distributions there are also different ways to compile the kernel.

I am going to show you how I compile a kernel on OpenSUSE 11.2.

Important: It is assumed proprietary ATi or Nvidia drivers are not installed. If you have such drivers installed and boot into your new kernel, X will crash!

Here we go...

First we need the kernel source and various development tools such as GCC.

Yast > Software Management > View patterns > tick 'Linux Kernel Development' > Accept

This will download and install what you need. At the time of writing the current OpenSUSE Kernel source was version 2.6.31.12-0.2.1, reference to such has been made throughout.

Open a terminal and type the following

su -
cd /usr/src/linux

We are now into our Linux source directory with root privileges and must create a config file for our kernel.

It is a good idea to use the same config that is being used by the OpenSUSE kernel which you are using right now, then fine tune it to your needs later on.

To use the same config file type the following,

make cloneconfig

With our config file we can now start editing the kernel by typing the following,

make menuconfig

This is the fun part, you can go through all the kernel options and change whatever you wish. I won't tell you what to change, that is completely down to you.

Changing some options may cause a broken kernel and / or Kernel Panic!

Tip: Highlight any option and press h. This will show information about the selected option.

When you have finished playing around, exit and save your changes.

Remember to give your kernel a different name, edit the following kernel option

General Setup ---> Local version - append to kernel release

Type anything you wish, for example

-modified

Building the Kernel

This part can take a while depending on your processor. Compiling also puts a high load on your processor as well as stressing the system, causing temperatures and power consumption to increase.

If you are unable to successfully compile a 100% default and unchanged kernel due to a compilation error, there is a high possibility your system has a weakness.

It could be due to many things, for example a hot running processor, motherboard chipset, PWM circuitry, memory, combination of all these, faulty memory, poor power supply.

To build your kernel as an RPM package type the following,

make rpm

You can watch the compile if you wish, maybe have a cup of tea...and biscuits!

When the compile has finished, the new kernel needs to be installed.

cd /usr/src/packages/RPMS/x86_64

If you are using the 32-bit OpenSUSE the new kernel will be located in the i386 folder.

cd /usr/src/linux/packages/i386

If you type in dir, you will see an rpm file, for example kernel-2.6.31.120.2modified-1.x86_64.rpm

To install it type the following,

zypper install NAME_OF_FILE.rpm

example, zypper install kernel-2.6.31.120.2modified-1.x86_64.rpm

Once it has been installed, type

cd /boot
mkinitrd

Now if you type dir whilst still in the /boot directory you should have the following 2 files,

vmlinuz-2.6.31.12-0.2-modified
initrd-2.6.31.12-0.2-modified

The NAME_OF_KERNEL in this example is 2.6.31.12-0.2-modified

The final part, is to edit the grub loader (using your favourite editor) to add our new kernel.

gedit /boot/grub/menu.lst

Example menu.lst

# Modified by YaST2. Last modification on Thu Apr  8 16:21:47 BST 2010
# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
# Configure custom boot parameters for updated kernels in /etc/sysconfig/bootloader

default 0
timeout 8
##YaST - generic_mbr
gfxmenu (hd0,0)/boot/message
##YaST - activate

###Don't change this comment - YaST2 identifier: Original name: linux###
title Desktop -- openSUSE 11.2 - 2.6.31.12-0.2
root (hd0,0)
kernel /boot/vmlinuz-2.6.31.12-0.2-desktop root=/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ1KSB14195-part1 resume=/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ1KSB14195-part2 splash=silent quiet showopts vga=0x31a
initrd /boot/initrd-2.6.31.12-0.2-desktop


###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 11.2 - 2.6.31.12-0.2
root (hd0,0)
kernel /boot/vmlinuz-2.6.31.12-0.2-desktop root=/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ1KSB14195-part1 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 x11failsafe vga=0x31a
initrd /boot/initrd-2.6.31.12-0.2-desktop

Use the default OpenSUSE kernel entry as a template. In the above example menu.lst the green text will be our template.

Modify it to suit your needs.

###Don't change this comment - YaST2 identifier: Original name: linux###
title Desktop -- openSUSE 11.2 -
2.6.31.12-0.2
root (hd0,0)
kernel /boot/vmlinuz-NAME_OF_KERNEL root=/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ1KSB14195-part1 resume=/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ1KSB14195-part2 splash=silent quiet showopts vga=0x31a
initrd /boot/initrd-NAME_OF_KERNEL

The red parts must be changed with the exact name of your kernel.

For example, 2.6.31.12-0.2-modified

The orange bits can be left alone but to avoid confusion I suggest you change them. It can be anything you wish.

Then add the new entry to the menu.lst file.

# Modified by YaST2. Last modification on Thu Apr  8 16:21:47 BST 2010
# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
# Configure custom boot parameters for updated kernels in /etc/sysconfig/bootloader


default 0
timeout 8
##YaST - generic_mbr
gfxmenu (hd0,0)/boot/message
##YaST - activate

###Don't change this comment - YaST2 identifier: Original name: linux###
title Desktop -- openSUSE 11.2 - 2.6.31.12-0.2
root (hd0,0)
kernel /boot/vmlinuz-2.6.31.12-0.2-desktop root=/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ1KSB14195-part1 resume=/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ1KSB14195-part2 splash=silent quiet showopts vga=0x31a
initrd /boot/initrd-2.6.31.12-0.2-desktop


###Don't change this comment - YaST2 identifier: Original name: My custom kernel###
title Desktop -- openSUSE 11.2 - 2.6.31.12-0.2-modified
root (hd0,0)
kernel /boot/vmlinuz-2.6.31.12-0.2-modified root=/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ1KSB14195-part1 resume=/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ1KSB14195-part2 splash=silent quiet showopts vga=0x31a initrd /boot/initrd-2.6.31.12-0.2-modified

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 11.2 - 2.6.31.12-0.2
root (hd0,0)
kernel /boot/vmlinuz-2.6.31.12-0.2-desktop root=/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ1KSB14195-part1 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 x11failsafe vga=0x31a
initrd /boot/initrd-2.6.31.12-0.2-desktop

Exit the editor, reboot your machine.

When you see the grub menu, select your new kernel. If you want it to load by default, change the default option in the menu.lst file to 1.

I have highlighted the default option in purple.

0 corresponds to the 1st entry, 1 will correspond to the 2nd entry and so on.

Before recompiling another Kernel

If you wish to compile again, issue the following command whilst in the /usr/src/linux directory

make mrproper

This will clear any rubbish left from the previous compile and is necessary to prevent a make error.

How to remove your custom Kernels

You can use zypper to remove your kernel by typing,

zypper remove NAME_OF_PACKAGE

example, zypper remove kernel-2.6.31.120.2modified-1.x86_64

The .rpm at the end is not required and will result in a package not found error.

Next delete the initrd file created when we issued the mkinitrd command,

rm /boot/2.6.31.12-0.2-modified

And finally delete the now obsolete entry in the /boot/grub/menu.lst file.

Enjoy compiling your own Kernels!