Tuesday 7 November 2017

Intel Clear Linux on Udoo X86 How-To

The Intel Clear Linux Project is a Linux distribution built for cloud and IoT use cases.


The aim is to showcase the best of Intel architecture technology and performance, from low-level kernel features to complex applications that span across the entire OS stack. The focus is on Power and Performance optimizations throughout the operating system as a whole.

The distribution is quite recent and Intel is also focusing on docker containers.




Phoronix website already highlighted the improvements it can carry over other common distributions (see also here).

How do we start? The Intel website offers a light tutorial you can find at this page.

The first step is to verify the Udoo X86 is equipped as a compatible processor.
You can validate it with the script clear-linux-check-config.sh.

You'll get this output:

luca@udoox86 ~ $ ./clear-linux-check-config.sh host
Checking if host is capable of running Clear Linux* OS for Intel® Architecture

SUCCESS: Intel CPU
SUCCESS: 64-bit CPU (lm)
SUCCESS: Streaming SIMD Extensions v4.1 (sse4_1)
SUCCESS: EFI firmware

Follow the tutorial to prepare the USB drive. Nothing uncommon compared to other distros.

But...
You'll get a surprise when rebooting and selecting the USB drive as primary boot. You will be able to proceed and get to the partitioning setup page... A wild Python backtrace will appear!
An error saying the command "fdisk -l on /dev/mmcblk0rpmb" returned an error.

The device is a Replay Protected Memory Block. I am not an expert and I could be totally wrong, but it should be a way to provide a separate trusted store, which usually an OEM could store IP to protect. The access is enforced by a secure API. This document about TEE OS should clarify some detail.

We're lucky the installer is written in Python.
Reboot and plug the USB drive on your favorite device running Linux.

Identify the following file /usr/bin/ister_gui.py and open it for editing.
We need to modify the function get_list_of_disks().
The function consists in running a lsblk and extracting all the devices which are not the current root device, generating a list.

In order to exclude the unwanted devices, add the following line:

    for part in parts:
        part = part.strip()
        if 'boot' in part or 'rpm' in part:
            continue

        if 'disk' in part:
            disks.append(part.split()[0])
        elif part.endswith('/'):
            root_disk = part.split()[0]


There are more elegant ways to do so, but it just works™.

Once done, you can unmount the USB drive and reboot. If everything is fine, you'll be able to get past the partition setup page and you'll be able to properly finalize the installation.
It's a network installation, so be patient (even on a Gigabit fiber connection, if you're writing to the emmc).

In case you do not want to install on the emmc, it should be possible to even disable the device through the UEFI and this "fix" should not be necessary. I'll update once I can confim that.

After rebooting and selecting the internal emmc as boot device, you should be able to boot for the first time on the Clear Linux distro!

You'll notice an error at kernel boot, still related to the RPMB device. It should be something like:

systemd-gpt-auto-generator[1765]: Failed to dissect: Input/output error

As the distribution is quite recent, it includes the workaround detailed at this issue on systemd. A fix has been integrated in master, but probably not yet released. The workaround is to pass the following kernel boot parameter:

systemd.gpt_auto=0

Clear Linux uses clr-boot-manager. It is a Kernel & Boot loader manager.
It has been also integrated in Solus OS.
It's actually thanks to the Solus OS webpage that I understood how to add the flag no matter the kernel in use.

Become root and create a new file /etc/kernel/cmdline and add the previous systemd boot parameter. Save the file, clr-boot-manager update and reboot. The message at boot should disappear!



Remember, if you choose to install Linux on the emmc, disable the swap as the device will probably suffer from intense usage.

Feel free to comment and suggest corrections!

Have a nice day!

No comments: