Adding 2.6.28 kernel and ext4 support to Hardy Heron

8 02 2009

The ext4 filesystem recently was announced as stable and was introduced into the mainline 2.6.28 kernel.  2.6.28 also has some other performance enhancements, so I thought I’d turbocharge my 8.04 install with a custom 2.6.28 kernel with ext4.  This is how I did it, and what improvements I noticed afterwards.

(Note – if you have custom kernel modules installed in your current kernel, you will lose them.  They will need to be recompiled.  Also, if you are using the restricted drivers they will stop working as well.  You will need to compile whatever modules you will need into your fresh kernel.  Simply installing the apt packages for nvidia-glx or whatever will not work, as 2.6.28 is NOT supported by Ubuntu.)

Step One:

Download the latest kernel source from www.kernel.org and put it into /usr/src.  Just change dirs to /usr/src, and wget the 2.6.28.4 tarball source from the kernel site.  Run a tar xvf on it, and then cd to the /usr/src/linux-2.6.28.4 directory.

Copy your current kernel config to .config.  Just type cp /boot/config-`uname -r` ./.config

Run make menuconfig.  Now, for additional performance as a desktop machine, go to enable preemption for low latency.   This will be under “Processor Type and Features> Preemptiton Model (Preemtible Kernel(Low-Latency Desktop))”

Make sure you add ALSA to the kernel.  This will be under sound devices – hit “Y” to install ALSA as a module.  Under the ALSA submenu, make sure you include the drivers for whatever soundcard you have/like/want/etc.

Exit and save your config file.

Step 2 – build the kernel

Okay, if you’re using a multiprocessor (or multicore) system you’ll want to enable concurrency during the build to speed it up.  This is just an environment variable that you’ll need to export prior to building.  Simply type export CONCURRENCY_LEVEL=4.  (4 is for 4 processors, 2 for 2, etc).

Now, while in /usr/src/linux-2.6.28.4, run fakeroot make-kpkg clean

Once done, run fakeroot make-kpkg –initrd –append-to-version=-barbarian kernel_image kernel_headers

(“barbarian” can be changed for whatever you want – this will show as a suffix to your kernel version after it is built)

After it builds, you will be left with 2 .deb packages.  One is the kernel image, another is the kernel headers.  These will be in /usr/src.

Step 3 – install the new kernel

cd to /usr/src and run dkpg -i linux-image-2.6.28.4-barbarian.deb (or whatever the deb package is named)

run dkpg -i linux-headers-2.6.28.4-barbarian.deb (or whatever the deb package is named)

Step 4 – boot the new kernel

Your new kernel should now come up.  If you have an nvidia card or an ATI card, you will now need to install the driver modules for them.  I am currently running nvidia on this box, so I just went to the nvidia site, downloaded the .run script for the driver, and installed it no problem.

Yay!  You’re now using the 2.6.28 kernel.  Now it’s time to run ext4.

Step 5 – ext4

First, you’ll have to install the new util-linux patches from ftp://ftp.kernel.org/pub/linux/kernel/people/tytso/ubuntu-fixed-util-linux – just install the .deb packages.

Compile and install the latest version of e2fsprogs from http://sourceforge.net/project/showfiles.php?group_id=2406

Okay, if you just want to create a new ext4 filesystem, you can just run

mke2fs -t ext4 /dev/DEV   and have a fresh new ext4 partition.

If you would like to convert an existing ext3 filesystem to ext4 – you’ll want to convert any partition except for /boot which will NOT work since GRUB cannot yet read ext4 filesystems.  If you convert /boot to ext4 – you will not be able to boot.

Anway, to convert an existing ext3 system, run

tune2fs -O extents,uninit_bg,dir_index /dev/DEV

Right after that you’ll need to fsck it – so run

fsck -pf /dev/DEV

Make sure you update your /etc/fstab entries to mount the partitions as ext4 instead of ext3.

What have I noticed so far?  Overall responsiveness on the desktop has improved.  The main headache that I’ve seen go away is the high i/o latency problem that many Hardy users complain about during heavy file i/o.  My boot time is now 3 seconds faster than before.  Copying large files to/from ext4 partitions appears to have less impact on other system processes, and foreground apps and processes appear to respond better during copies.  All in all I’m happy with the results.