Create a custom distro: Choice of the right base (P.1)

233

Intro

I’m still following base directives for creating a custom live distro for a special appliance, you’ve certainly read my previous considerations related to hardware and initial planning requirements. For this particular home server I’ve decided to stay with a common x86 device, power consumption could be a big issue if compared to low power CPU boards (MIPS and ARM devices for example) but at least I’ve an huge choice and many different Linux distributions.

I’ve decided to use an Atom based motherboard with an Intel NM10 chipset, an Atom N450 CPU is big enough (even too big…) for my designed tasks but I’ve decided to install a tailored Linux distro instead of installing a full blown stock distro. If you’ve read my previous considerations and constraints I’d like to achieve these tasks:

  • No further modifications are needed on this appliance after initial installation

  • I’ve already decided basic services this appliance should provide to my home network

  • It’s not a desktop, there’s no mouse, keyboard, screen or whatever, it has to work on a LAN, no direct user interaction

  • It must run unmanaged or without an IT specialist around for a long period, I often spend a lot of time away from where this machine is, I don’t have a skilled user and I don’t even need it to run this device.

  • It’s just a stupid appliance, no frills

  • To avoid HW failures I’d like to reduce breaking parts, no fans, no hard drives, no SDD. This board needs to be attached to a common (and cheaper and easily replaceable) ATX PSU. Again: no moving parts or fan around. I’ve few power supply units with low specs and low power consumptions, I’ve just used one of them

  • Hard drives may fail, to replace them easily I’ve decided to run everything without an hard drive, I’ve decided to use a cheap and common USB Key as primary root disk. To avoid troubles with cheap USB keys I’ve decided to use one of them and have at least a backup of it elsewhere, if I need to replace my “main USB root disk” I only need to throw away the bad one and use a new one

  • To avoid troubles with USB sticks and possible breakage in the long term I’ve decided that my root disk has to be read only, USB sticks are excellent devices when you only need to read them, you may corrupt them easily in the long term if you write data on it (it’s still a flash…, it has limited write cycles)

  • It has to be a thin distro so I can use cheap USB sticks, I don’t need a 4Gb USB stick just for running an OS with few basic services. In my case I’ve decided to stay under 128Mb, there are plenty of sticks around with 128/256/512Mb and they’re so cheap…

  • I don’t want to keep basic distro behavior and I obviously need some customizations on services, networking and some special personal needs

  • I want to build my personal toolchain to be able to reproduce the same image and do more customizations on it

If you’ve carefully read my specs and you tend to keep a small footprint on tailored machines like me you’ve probably understood why I haven’t even considered to install mainstream distributions like Ubuntu/Fedora Core/Mint/… I’m not against them but these are for a common desktop user and full of unused utilities (even bloatware sometimes…) and not really optimized for my special task so I’ve started to consider other distros I already use, here are my thoughts:

 

LFS (Linux From Scratch)

This is definitively my first choice and the approach I prefer with my personal computers, it’s not even a distro (it’s just a series of books). THIS IS LINUX AND GNU, nothing more. You’ve the GNU operating system and a Linux kernel, this is the approach (not even a distro) for the definitive geek. You can do everything you want with it: you may customize scripts, dependencies, packages makefiles, your toolchain and build scripts as well. It takes a while (!!!) to compile everything but at the end you have your own Linux system with LSB compliance as well. This is what we all need to use all the time… but…. in this case this is not what I’ve used, that’s why:

  • x86 support for LFS is excellent and the base book is really something to read at least once in a lifetime. I’ve my own build script (a set of bash scripts and makefiles) to automate the whole process, even with this magical script my installation procedure after some changes takes at least: 6-8 hours for building the base toolchain, 4-6 hours to build my basic system. When you test it or when you make some trials to adjust your internal requirements you may spend a week on it just to make some tests, that’s definitively what I don’t want to do

  • An LFS installation process gives you a full blown GNU OS with a Linux kernel, installation takes across 300-400 Mb (for a bare bone system) or more probably around 500-600 Mb (samba, httpd server, php, DLNA, torrent, …). You may tweak it with a busybox but it requires extra steps, even binary stripping is required but this is not so easy, you may even cut unnecessary man pages as well as other things (you already have manuals somewhere…). More extra steps, more time to realize the project

  • It’s not aimed to be a read only system, you obviously have the Live CD and some scripts but if you tend to recreate your system frequently you need extra time (again), live cd scripts (www.linux-live.org) are impressive but LFS needs a lot of care

  • There’s no automatic HW recognition (it’s not so important BTW)

  • Your live image it’s not compressed (like knoppix or stuff like that), you may do it because you’ve “the father of every Linux distro” but again: it requires a lot of extra time

  • UnionFS, and aufs may be attached to it to support some sort of changes in a read-only environment but it’s a slow process if you need to implement them

Conclusions:

This is my best choice and my first attempt but unfortunately I’ll be able to build my own system in a month or maybe more and there are even things I don’t even know how to realize. I really appreciate LFS books and it’s still one of my favorite “distros” (even if it’s not a distro !) but I cannot use it in this moment

 

Gentoo

I’ve started with Gentoo in 2000-2001 when it was a young distribution, I was looking for a distribution with these requirements:

  • It has to be really close to LFS approach, in the beginning I’ve started with it because it was something like “LFS with steroids”: an LFS install with an automated build script

  • I’d like to have a “super-build-and-do-everything-for-me” script to create a running installation without worrying about copying and pasting instructions from the book. I don’t want to read the same paragraph 100 times to discover after few hours what kind of instruction I’ve missed before

  • I’ve been an happy BSD user and I really love it, one of the best things about BSD is their makefile approach. When you need a program you just need to enter in their package structure, locate your favorite program (just use “find” utility), and install it with make (make clean, make, make install). Even better: you want to upgrade your whole system to current stable BSD ? Just issue “make world” and your machine will upgrade itself and install everything needed (well, it’s not so simple but this is the approach). I respect monthly scheduled released distro (6 month for SuSe, Ubuntu, Fedora, …) but I’d like to have “the latest one” just with a simple upgrade command.

  • Gentoo and Arch are rolling update distributions, there’s no version vX.xx, there’s “the distribution you’re using” and “current distribution”, with a simple command you switch from “your old one” to “current”. I really love rolling updates distros

Even more: do you want to make your favorite customizations to every package because you want or don’t want that particular feature (doc, man pages, Xorg, Lang, …) ? Are you looking for a special patch or an optimization for your particular CPU ? Gentoo is the way to go. This is my first distribution and what I use more at work (my main desktop) and at home, it was obvious for me to test it and adapt it to my appliance. But even if I still prefer Gentoo I’ve discarded it, that’s why:

  • If you need to create a system with a limited space (my USB stick) you need to drop portage directory structure and create a system without it. There’s a way to do it (read excellent Gentoo docs) but it’s not so easy if you want to make frequent changes to it or do minor upgrades

  • You need a “build machine” with a full Gentoo installation and a special portage structure for creating your target machine, cross compilation it’s one of the Gentoo specialties but it’s not aimed to machine creation

  • There are tools like Catalyst or tools/docs for creating “stage 4” steps but these are a little bit cryptic and sometimes aimed to create other Gentoo tipical installations, most of the times you’ve excellent results when you need to deal with a LiveCD but it takes a lot of time. I’ve used catalyst a while but it’s not so easy to create a live image under 200Mb ! It requires lots more

  • There are Live-USB methods, something with AUFS or UnionFS but it requires a lot to reproduce them all and there’s no root disk compression (like Knoppix for example). You obviously may do it but it’s like LFS, it takes a lot of time to do it

  • If you upgrade your “build station” and “toolchain” frequently you always need to make few adjustments to the build system if you’ve modified startup scripts for your target machine

Sadly I’ve discarded it due to some problems: available time, overall image size, readonly unavailability and live cd/usb compression. It’s still my favorite choice for a full blown desktop or server but this time I’ve used something else for my installation

 

Arch

I really like it because it has the same rolling update approach like Gentoo, there are no “major versions” there’s just the version you’re using and the current stable, current stable changes every hour (depending on project activities…). Even more: it’s definitively binary based so you don’t have to wait ages to get something compiled (emerge, emerge, emerge, …), you may loose 0,00001% optimizations from your particular HW but someone still lives without it. But my poor Arch knowledge drove me to nothing, I’m an happy Arch user, I use it for building tailored servers for example and it’s nice but it seems it’s not really oriented to LiveUSB/CD creation like others (read below). You may use Arch for Servers or Desktop installations but in my particular case I’ve chosen to use something else

 

continues on the next page…

 

 

Previous chapters:
Creating a live distro for target appliance
Choosing the hardware