April 27, 2011

LDR: The birth of a Linux distro - Part 1

So I've always been a huge fan of Arch Linux. For many years it has been my weapon of choice for pretty much anything from web servers to development environments. It's incredibly lightweight, fast, stable yet up-to-date, and highly customizable.

Sure it doesn't have all the bells and whistles of other distros, nor does it take the responsibility of configuring complex areas such as Sound support or Network hot-swapping; but I think this is quite healthy... I spent years swearing at Microsoft products because they feel they have to do everything for you (no matter how complex) and then things just didn't work. Ironically if they have left things lite and transparent and left the responsibility of getting it working to best suit my requirements to me, then I wouldn't have held them responsible when something wouldn't work.

Thankfully I am out of that world now, and am taking what I have learnt from it with me.

My biggest issue with Arch was that it would take an entire evening to get everything I need installed and configured the way I like it. So I eventually decided to invest some time into creating my own derivative.

This derivative included my own custom repository, so I can install my packages I have acquired from various places (or written myself) from a single command.

It also contains configuration changes to the core platform, so it behaves the way I want it to (and sports my own branding!)

Hunting around the Arch forums, looking for people who have done something similar, I stumbled upon a set of script files called archiso. Unfortunately I couldn't get archiso working straight away, as there was some problems with the Makefile included on the Arch wiki. I began to edit it, adding my own parts so it could do extra things like branding.

To be able to create a derivative, I first needed to brush up on how a Live CD works. The best way to do this is to break the boot sequence into logical chunks:

The Boot Loader

The boot loader is the first component to be loaded. Arch CDs use the ISO version of SYSLINUX (ISOLINUX) which lives in the /boot folder. It loads up and reads the config file /boot/syslinux/syslinux.cfg which gives it a list of boot configurations (eg. which partition, initrd, kernel, kernel boot options etc..) that can be loaded. Once one of these is chosen, the kernel is executed using the chosen options.

Initial Ram Disk

Also known as "early user space", the initial ram disk is an image which contains the kernel and a super lite root filesystem which is just enough to prepare the system for the real root system to be mounted. This involves running kernel hooks and hardware detection.

You can create an initrd by using mkinitcpio with a config file which contains a list of the kernel hooks that need to be run during this early boot stage.

One of the hooks for Arch's Live CDs reads a file on the root of the CD called isomounts. This is an fstab file for the CD. It mounts the root file system and the Init scripts gets run.

Init scripts

The init scripts begin with inittab. This is a file which determines which runlevel should be ran (these tend to be different for each distribution, but 3 generally means a multi-user environment with networking, which is the default for arch). 5 means the same, but with a desktop manager (eg. GNOME, KDE, OpenBox, FLuxbox, wmii, dwm etc..). inittab is also the script which is responsible for respawning the login manager if you kill Xorg.

Arch also has a load more init scripts for various purposes, you can read more about them here. rc.sysinit runs on boot; it does more hardware configuration, logs to dmesg, starts the daemons etc.. Followed by rc.multi and rc.local which contains any finish up code before the login is displayed.

LDR Linux

So I now have a working Arch derivative with all these steps configured. You can check it out at: http://www.tommed.co.uk/ldr. Obviously, as Arch is GPL based, I have open sourced by build scripts and packages here. I hope it is of good use to people who want to do the same, or use as a learning tool!

I released LDR recently as an ISO image, but didn't quite realise the impact of doing so... I was added to Distrowatch and quickly started receiving thousands or hits per day, which quickly destroyed my little home web server! :(

I managed to get the ISO mirrored (BIG thanks to Neil Bright of Georgia Tech) which deferred the bandwidth load from my home server, which runs quite happily again now! 

I didn't released LDR Linux planning on turning it into the next big distro, it was more about being able to quickly install Arch with all my custom trimmings in less than 1hr and also  sharing my code and my work to inspire others, but from the feedback I have received, it's plain to see that others want LDR on their machines + they want it supported too!

I am happy to do this, but could use a bit of help from anyone in any capacity (even if it's just spell checking on the wiki, or general testing) any help or donations would be greatly appreciated!

Google Chrome, wmii, OSDBattery (run battery-status or Mod4+B), Adobe Flash, and PulseAudio all work out-of-the-box when testing in VirtualBox!

LDR Linux 1.06


Click Here!