Categories
Uncategorized

Building a new Linux kernel for your Utilite Computer.

The Utilite computer comes with an aging Ubuntu 12.04. If you try to upgrade it to to 14.04 or later, you will end up with a broken system because of their dependency, either fully or partially, on the systemd init system. The problem is that the stock kernel does not support cgroups which is a mandatory dependency for systemd. Type these commands on your Utilite, to verify the missing feature:

$ sudo mount /dev/sda1 /boot
$ /usr/src/linux-kernel/scripts/extract-ikconfig /boot/uImage-cm-fx6 | grep CGROUPS
# CONFIG_CGROUPS is not set

There is also another important feature: fhandle. A systemd Linux system without an fhandle enabled kernel, will fail to enable the swap space during boot.

Most modern distros, with a few notable exceptions, have switched to this new initialization system. So if we want to use a recent version of Ubuntu, Debian or most other distros, we need to recompile the kernel with cgroups support.

Prerequisites

  • A standard x86-based PC with Linux installed (I use Ubuntu 15.04 at present). This is going to be our build station.
  • A Utilite ARM Computer. This is our target.

Prepare the cross-compile toolchain

The necessary packages are available on recent Ubuntu releases and Debian unstable.

First let’s install all necessary and optional packages on our build station:

$ sudo apt-get -y install build-essential gcc-arm-none-eabi gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf libncurses5 libncurses5-dev libncursesw5 libncursesw5-dev lzop git u-boot-tools pkg-config

Download the kernel sources

  1. You can download the sources from here:
    $ wget https://github.com/utilite-computer/linux-kernel-3.0/archive/master.tar.gz
    
  2. Then extract the tarball and change into the kernel source root:
    $ tar xvzf master.tar.gz
    $ cd linux-kernel-3.0-master/
    

Building the kernel

  1. Prepare the environment:
    $ export ARCH=arm
    $ export CROSS_COMPILE=arm-linux-gnueabihf-
    
  2. Prepare the configuration for utilite:
    $ make utilite_defconfig
    
  • Check if cgroups and fhandle are enabled:
    $ grep CGROUPS .config
    # CONFIG_CGROUPS is not set
    $ grep FHANDLE .config
    # CONFIG_FHANDLE is not set
    
  • Since cgroups and fhandle, are not enabled we need to enter menuconfig to enable it:
    $ make menuconfig
    

    Navigate to General Setup and go down to Control Group support. Press the space bar and you will see an asterisk ([*]). That means the Control Group support feature is enabled to be compiled in the kernel. Now do the same with the open by fhandle syscalls option. Press exit and Yes to save your new configuration.

  • Make sure cgroups and fhandle are now enabled:

    $ grep CGROUPS .config
    CONFIG_CGROUPS=y
    $ grep FHANDLE .config
    CONFIG_FHANDLE=y
    

    Good. Let’s proceed with the build.

  1. Build the kernel and prepare a U-boot compatible image (uImage):

    $ make
    $ make uImage
    

    This will take some time depending on how powerful your build station is. Go for coffee, watch some movie, read a comic

Prepare the tarball

Now we need to package the kernel and modules together.

  1. Install the modules in the rootfs directory:
    $ mkdir -p rootfs/boot
    $ INSTALL_MOD_PATH=./rootfs make modules_install
    

    Ignore this error after make modules_install:

    make[1]: *** No rule to make target 'rootfs/lib/firmware/./', needed by 'rootfs/lib/firmware/ti_3410.fw'.  Stop.
    Makefile:1130: recipe for target '_modinst_post' failed
    make: *** [_modinst_post] Error 2
    
  2. Copy the image and prepare the tarball:
    $ cp arch/arm/boot/uImage rootfs/boot/uImage-cm-fx6
    $ cp arch/arm/boot/zImage rootfs/boot/zImage-cm-fx6
    $ cd rootfs
    $ tar cvzf ../linux-utilite-kernel-3.0.tar.gz .
    $ cd ..
    

Deploy the tarball

Now we are ready to deploy the kernel to the Utilite computer.

  1. Copy the kernel to the Utilite computer:
    $ scp linux-utilite-kernel-3.0.tar.gz utilite@utilite-desktop:
    
  2. Now connect to the Utilite and mount the boot partition:
    $ sudo mount /dev/sda1 /boot
    
  3. Backup the existing files and remove the old image and modules:
    $ tar cvzf linux-utilite-original-kernel.tar.gz /boot/ /lib/modules/3.0.35-cm-fx6-6.3/
    $ sudo rm /boot/uImage-cm-fx6
    $ sudo rm -fr /lib/modules/3.0.35-cm-fx6-6.3
    

    If something goes wrong you can boot from a microSD or a USB drive and restore the original kernel.

  • Deploy the kernel:

    Note
    Make sure the /boot directory is mounted on the /dev/sda1 filesystem before running the following command.

    $ sudo tar xvzf linux-utilite-kernel-3.0.tar.gz -C /
    $ sudo chown -R root:root /lib/modules/3.0.35-cm-fx6-6.4
    $ sudo depmod 3.0.35-cm-fx6-6.4
    

    The errors caused by tar are produced because FAT filesystem like /dev/sda1, do not support the ownership attribute. You can safely ignore them. chown is used to set the owneship of the modules to the root user, since the tarball was packaged under a normal user account and inherited its permissions.

  • You can now reboot the Utilite and see if everything works as expected. If not, you can boot with a microSD or a USB flash drive and restore the original kernel and modules.

    After we have successfully prepared a cgroups enabled kernel, we can move on to setup a new Ubuntu or Debian system on the Utilite.

    References

    • [1] http://www.compulab.co.il/utilite-computer/wiki/index.php/Utilite_Linux_Kernel_3.0

    By Theodotos Andreou

    An old school Linux guy, a founding member of Ubuntucy and a founding member of Cyprus FOSS community. Currently working as sysadmin in the Cyprus University of Technology.

    https://www.ubuntucy.org

    https://ellak.org.cy

    Leave a Reply

    Your email address will not be published. Required fields are marked *