Monthly Archives: September 2011

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


Your custom MeeGo builds

NOTE! For the long and detailed explanation on how to create custom MeeGo images, just jump to the MeeGo wiki:

These steps shown here are the minimum set required in an Ubuntu 11.04 host to be able to create MeeGo images easily. They do not try to be extensive, or very explanatory, these are just my personal notes on how to do it 🙂

1. Install MeeGo Image Creator

Include the MeeGo tools and SDK repositories to your APT configuration, by adding the following lines to your /etc/apt/sources.list:

deb /
deb /

Add the MeeGo repository key:

$> gpg --keyserver --recv 0BC7BEC479FC1F8A
$> gpg --export --armor 0BC7BEC479FC1F8A | sudo apt-key add -

Update the APT cache:

$> sudo apt-get update

Install the mic2 package:

$> sudo apt-get install mic2

Note: ‘mic2’ is also in natty/universe, just not the latest version.

2. Prepare a MIC bootstrap

In order to be able to create images from within your Ubuntu 11.04, you will need to use a MIC bootstrap. If you’re using one of the supported platforms (Ubuntu 10.10 for example), you can possibly skip using it. The generated bootstrap will be a chroot-able location which contains MIC and all its exact dependencies.

$> sudo mic-create-bootstrap \
-n trunk \
-k /opt/meego/repo-cache \
-r \
-o /opt/meego/ia32-bootstrap

This previous command will create a trunk named bootstrap in /opt/meego/ia32-bootstrap using /opt/meego/repo-cache as path to store cached packages.

3. Prepare a kickstart file

Kickstart files are the ones defining the contents of the image to be built. Not only what packages will be installed, but also which default users will be created, the default root password, the default locale settings, the default keyboard layout…

Preparing a new kickstart file is best done by taking an officially used one, and modifying it as you like (a.k.a. the autotools way):

The kickstart files I’ve been using are based on the upstream official ones, but with updated repo URLs and bigger root partition sizes. You can find them here:

Note: If you want to know more about the format of kickstart files, what they do and such, just check the Fedora wiki.

4. Create a raw image and launch it under KVM

The MeeGo Image Creator can build ‘raw’ images which can be then launched under QEMU/KVM. The following command will build one of such ‘raw’ images, using the previously created bootstrap and one of the kickstart files we prepared. Note that the command also defines a cache path, where the RPMs downloaded from the MeeGo online repos will be stored (and therefore available for new images created afterwards).

$> sudo mic-image-creator \
--bootstrap=/opt/meego/ia32-bootstrap \
--format=raw \
--config=meego-core-ia32-1.2.0.ks \

You can then use mic-vm-launcher as follows to launch the image under QEMU/KVM:

$> sudo mic-vm-launcher meego-core-ia32-raw/meego-core-ia32-sda.raw

Or call kvm directly and tweak the parameters used to launch the image:

$> sudo kvm \
-s \
-m 1024 \
-hda meego-core-ia32-raw/meego-core-ia32-sda.raw \
-vga std

Note: Ensure that virtualization is enabled in your BIOS, or KVM won’t be able to work properly. You can use ‘$> sudo kvm-ok‘ to check whether it is enabled or not.

5. Create a LiveUSB image and write it to a USB dongle

You will probably want to test your MeeGo build in the real hardware, and for that using LiveUSB images is one of the best options. The MeeGo Image Creator also allows building LiveCD and LiveUSB images directly from kickstart files; again, just changing the ‘format‘ argument:

$> sudo mic-image-creator \
--bootstrap=/opt/meego/ia32-bootstrap \
--format=liveusb \
--config=meego-core-ia32-1.2.0.ks \

Once you get the image, you can use ‘mic-image-writer‘ to directly copy it to a connected USB disk. This tool will scan all available external disks, and prompt a menu to select the one where you want to write the image to. The ‘-c‘ switch (--console) just tells the tool to avoid launching any GUI, and present the menu directly in the console. During this step, the USB disk is also prepared with sysconfig/isolinux to boot the newly written image.

$> sudo mic-image-writer -c meego-core-ia32.usbimg

Now you’re ready to boot your hardware with the LiveUSB image.

6. Create a loop image and chroot into it

With the MeeGo Image Creator, you can also build loop images, just changing the ‘format‘ parameter in the call to mic-image-creator:

$> sudo mic-image-creator \
--bootstrap=/opt/meego/ia32-bootstrap \
--format=loop \
--config=meego-core-ia32-1.2.0.ks \

Once you have the loop image built, you can chroot into it:

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

While in the chroot, you can remove or update existing packages, and even add new ones. When you are done, just type $> exit to leave the chroot.

Note: If you want to use zypper inside the chroot, ensure that you included ‘@MeeGo Base Development’ group of packages in your kickstart file.

7. Convert loop images to LiveUSB images

Once you have your loop image modified as you wanted, you can then convert it to a LiveUSB image so that it can be written to an external USB disk, as in the previous step. Converting between image types is done with the ‘mic-image-convertor‘ tool:

$> sudo mic-image-convertor \
--source-image=meego-core-ia32.img \

Additional notes

  • Be careful with mic-chroot.
  • The Meego Image Creation set of tools make a hard use of disk space under /var/tmp. If you (like me) usually don’t have much space left in your root partition, you’d better symlink that path to a partition without disk space worries.
  • I’ve found several times that when I try to build new images, the tools tell me that the packages downloaded in the cache are corrupted, and need to be re-downloaded. Just make sure you have a good connection 🙂
  • Again, visit if you want to have further details on these tools.