Mittwoch, 29. April 2015

TinyCore Linux


After some experiences running Lubuntu (14.04 LTS and 14.10 – 64 Bit) on my recently build thinclient, I search for a more lightweight system. Don't get me wrong, Lubuntu is fine, has a good hardware detection and configuration– everything (dual-head X, Sound) is running out of the box, but the distribution is too large to install on the build-in DOM (1 GB) of my HP-T 5730. Therefore I do a USB stick installation, which works but has a really bad IO performance. A startup time from about 2 minutes is really bad. However, some month ago, when I started using docker, I installed Boot2Docker on my MacBook Air. Boot2Docker starts a headless virtualbox instance running a tiny core linux with installed docker engine to provide Docker services on OSX. The base image used for such a 'boot2docker' instance is incredible small, about 20 Mbytes of size, which is an impressive value for kernel + ssh + docker. Nowadays, when waiting that Lubuntu finished booting, I remembered Tiny Core Linux and google for it.
TinyCore Linux is a very small linux distribution and comes in three basis flavors :
  1. Micro Core (kernel + core.gz) - 9MB
  2. Tiny Core (Micro Core + X) – 15 MB
  3. Tiny Core Plus (Tiny Core + WLAN driver + Installer) – 75 MB
TinyCore has very small hardware requirements (a 486er and a minimum of 48 MB of RAM is needed) and run completely from RAM and is therefor subjectively much faster than other distributions. So called extensions can be installed from an online repository using tce-ab (cmdline), which is a kind package system similar to apt on debian based systems.



Tiny Core is different than other distributions, because users are not encouraged to perform a 'traditional', hard-drive installation of the operating system. Sure, a hard drive installation is possible, but Tiny Core is designed to run from a RAM copy created at boot time. Besides being fast, this protects system files from changes and ensures a pristine system on every reboot. Easy, fast, and simple renew-ability and stability is a principle goal of Tiny Core.
(from TinyCore concepts)

I used a TinyCore 32 Bit image as base for my current installation. Startup to X from an USB stick is done in about 10 seconds – what a big different to Lubuntu. After a frugal installation in default mode to my 1GB 'hard-disk', the startup time decreases to only a few seconds. After the base installation is done I just had to do some configuration work to have a perfect thin client ... :-) ... well, it was not as easy as writing this sentence, but not so complicated – the Tiny Core team/community have done really good work here. Thanks!



Configure X

The greatest challenge was to configure my dual head graphics configuration. Remember my hardware configuration? I have a Nividia Quadro NV 290 connected to two monitors. Since this configuration work out of the box with Lubuntu, it is a bit complicated to get it running with TinyCore. First I need to install Xorg instead of Xvesa and a suitable driver for my graphics card. The extension Xorg-7.7 (Meta package for all the necessary Xorg stuff) and xf86-nouveau should do the work, but in fact Xorg uses only a slow VESA and not the better fitting nouveau driver. I create a minimal /etc/X11/xorg.conf to force using the nouveau driver:

Section "Device"
  Identifier "Card0"
  Driver "nouveau"
  BusID "PCI:1:0:0"
EndSection


Running X with this configuration fails. In the corresponding log file I found that KMS (which is mandatory when using nouveau) can't be used because its not enabled. Loading the graphics-XXX-tinycore extension should help but this packages doesn't contain the necessary nouveau kernel module.I decided to compile the missing module by myself and package it into a nouveau_kms package.
Building the neccessary kernel modules are much easier than expected. I need the following packages compiletc.tcz, linux-kernel-source-env.tcz and optional ncurses.tcz for a more comfortable kernel configuration ;-). I build and package the following kernel modules into nouveau_kms.tcz :
  • drivers/i2c/algos/i2c-algo-bit.ko
  • drivers/gpu/drm/ttm/ttm.ko
  • drivers/gpu/drm/drm_kms_helper.ko
  • drivers/gpu/drm/drm.ko
  • drivers/gpu/drm/nouveau/nouveau.ko
  • drivers/char/agp/nvidia-agp.ko (possible unnecessary)
  • drivers/char/agp/agpgart.ko (possible unnecessary)
After adding it to the onboot list (/mnt/[boot drive]/tce/onboot.lst) and a reboot (minimal xorg.conf still exists) X comes up with both screens mirrored. I use xrandr to expand the desktop over both screens.

xrandr --output DVI-I-2 --auto --right-of DVI-I-1

I add a small script named xrandr.sh containing the above xrandr command to the tc users .X.d directory. Every script inside this directory is run after X is started. In my case X comes up so fast that the second monitor is still sleeping and is not yet available, I just add a sleep 2 before calling xrandr.
There is still a problem existing. The console gets blank when loading my noveau_kms package, but X is working fine (with nouveau). If someone has an idea what the problems solves, please let me know. For now a running X without console is fine for me.
If you have a similar problem and want to use my nouvaue kms module, let me know - I can provide you my nouveau_kms.tcz package (build for Tiny Core version 6.1).


Enable Sound

Enable sound is easy and straightforward. I just have to add two extension (alsa.tcz and alsa-config.tcz) and it works out of box. The default alsa.tcz extension comes with a textual ncurse based mixer, which is fine for me. If you a like a more graphical interface just install the corresponding extension (alsa-mixer.tcz).


Setup SSHD

For some reasons (e.g. the console isn't available :-) )it is sometimes useful to provide ssh access. After installing the openssh.tcz package I have to create the host ssh-keys :
sudo ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ""
sudo ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ""
sudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ""
and start the sshd:
/usr/local/bin/sshd -D
Mostly for security reason I only want to use ssh-public-key access. So, I just copy my public ssh key to the tc users authority file and everything works like expected (By default the tc user doesn't have a password).


Persistent Configuration

Since all configuration work is lost when rebooting the system, I have to persist it.
  • add /etc/X11 (xorg.conf) and /etc/ssh (ssh-keys) to backup list
  • add xrandr.sh to ~/.X.d
  • add /usr/local/bin/sshd -D to /opt/startup.sh
An installation on a portable media like an USB storage device that is used on different hardware should possibly not persist the ssh-keys, but create new ones during startup.






Keine Kommentare:

Kommentar veröffentlichen