Your custom kernel in MeeGo

In my last post I covered the steps needed to create custom MeeGo images and play with them.

One of the things you may also want to do is to try new or modified kernels in your MeeGo images. You can do this either installing RPMs or directly compiling the kernel yourself. The following steps will cover this last case.

1. Where to compile the kernel

No, do not try to compile the kernel directly in a raw image launched within KVM/QEMU.

The easiest way to compile your own kernel is to prepare a loop image and chroot into it (See section “6. Create a loop image and chroot into it” in Your custom MeeGo builds).

Note: In order to completely compile the kernel, you will need quite a lot of empty space in the chroot. In order to easily get this, just use a big enough root partition size (given in MBytes) in the Kickstart file used to create the loop image.

2. Get into the chroot

Assuming meego-core-ia32.img is a loop image created, just:

$> sudo mic-chroot meego-core-ia32.img

3. Ensure only one kernel is available

The MeeGo Image Creation tools will expect to have exactly only one kernel available. Therefore, if you just created the loop image, you will need to remove the default kernel RPM installed.

# rpm -e kernel

4. Install the MeeGo kernel source and build dependencies

You will need to enable the source repositories in zypper first:
First, list the available repositories in zypper:

# zypper lr -u

Note that these repositories were initially configured in the Kickstart file used to create the loop image.

Then, enable the source repositories if not already done.

# zypper mr -e 1.2.0-non-oss-source
# zypper mr -e 1.2.0-oss-source
# zypper mr -e 1.2.0-updates-non-oss-source
# zypper mr -e 1.2.0-updates-oss-source

Once you have these enabled, you can install the kernel source, and all the build dependencies will also get installed:

# zypper si kernel

Install additional required packages which were not listed in the build dependencies (not sure why not listed).

# zypper in gcc

5. Get your new kernel, configure, compile and install

First, download the tarball and decompress it:

# cd /root
# wget
# tar -jxvf linux-3.0.4.tar.bz2 -C /usr/src

Prepare the kernel configuration file, based on the one from the MeeGo kernel packaging. In this case we’re using a newer kernel version, so you will be prompted for the values of the new configuration parameters. You can just try use the default ones if you don’t know what they mean.

# cd /usr/src/linux-3.0.4
# cat /root/rpmbuild/SOURCES/config-generic /root/rpmbuild/SOURCES/config-x86 > .config
# make oldconfig

Note: Of course, you can fully skip using the MeeGo kernel configuration file and fully configure it yourself with, for example, make menuconfig.

Then, compile the new kernel and the kernel modules, and install them.

# make -j8
# make -j8 modules
# make modules_install
# make install

Note: In addition to the specific kernel configuration, MeeGo packaging also provides several kernel patches. In this case, we are not including them.

6. Make the kernel bootable

In order to make the kernel bootable in the image, you will need to create an initial ramdisk under /boot. But you shouldn’t use mkinitrd for that, use the provided mkliveinitrd instead:

# /usr/libexec/mkliveinitrd -f /boot/initrd.img-3.0.4 3.0.4

Once done, just exit the chroot:

# exit

7. Create a LiveUSB image to test the new kernel

The steps to convert a loop image to a LiveUSB image and write it into an external USB disk are explained in my previous post about Your custom MeeGo builds, so I won’t explain much more about it.

Just a warning: always make sure that you have ONLY ONE kernel available under /boot. If you happen to have more than one, for example when make install-ing twice (old ones get renamed with a .old extension), mic-image-convertor won’t like it and will exit with an error message like this one:

Error: Unable to copy valid kernels or initrds, please check the repo

Posted on September 2, 2011, in Operating Systems, Planets and tagged , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: