COMP 3000 2011 Report: ttylinux

From Soma-notes

Part 1

Background

The distribution I chose to discuss is called ttylinux, and its named after its initial orientation towards TeleTYpewriter (or TTY serial) interfaces. It caters to an audience of users looking to get older hardware running on the web or lightweight systems they can boot from USB, and to developers who are looking for an OS they can base their own variant of Linux on, including possibly one modified to run on embedded systems. It was initially developed in 2001 by Pascal Schmidt, who focused on getting it running on serial interfaces over networks, but when Douglas Jerome took his place in 2008, the focus of the project moved away from connecting to serial interfaces and towards its intended purpose of being "one of the smallest up-to-date Linux systems that is similar to a larger distribution", as stated on the website.

You can download ttylinux from the [project website] or one of a number of the mirrors listed there. Derived from scratch, the smallest variant of ttylinux called 'em' has a mere ~8 megabyte filesystem, and it only takes up ~12 megabytes including the kernel. That said, the smallest variant available for i686 called 'ut' uses ~25 megabytes, and this is what I've used to test with for this report.

Installation/Startup

Installation

Figure 1 Initial boot of the ttylinux installer
Figure 2 Login prompt in the ttylinux installer

To test this distribution, I used Oracle VM VirtualBox Version 4.1.0r73009 and created a new VM using the Linux 2.6 presets and 2 gigabytes of storage, I configured it to have 16 megabytes of video memory, 64 megabytes ram and a bridged Ethernet device to connect directly through my network's router. I then used the virtual media manager in VirtualBox to mount the ~35 megabyte ut-ttylinux-i686-12.6.iso, which is an image of the most recent version (12.6) of the smallest i686 variant 'ut', and booted the virtual machine.

The ttylinux installer initially greeted me with some boot options that allowed a number of settings and services available during the installation to be tweaked, and not needing any of these things to be changed, I pressed enter to begin the installation. It loaded into a live ttylinux environment that wasn't too different from the final installed version, and it presented a shell prompt that I was able use to login as 'root' with the password 'password'. The decidedly out of date [ttylinux User Guide] explained a method of installation that appeared to be a somewhat manual process, but when I discovered a file named 'install.conf' in my user's home directory explaining a much more automated process, I decided to leave the ttylinux User Guide behind.

To install ttylinux using 'install.conf', I needed to use fdisk to partition the VM's disk first, and I used a similar configuration to the one in the sample that the default 'install.conf' provides. I then used 'vi' to edit the 'fstab' section in 'install.conf' to reflect the the partitions I created, and to test ttylinux's claim of being up to date, I set the filesystems of everything (except for swap, of course) to ext4, resulting in the following configuration:

 /	P /dev/sda1 512M	    Linux	ext4
 swap	P /dev/sda2 128M	    Linux Swap	swap
 /boot	P /dev/sda3 24M	  *Bootable Linux	ext4
 /home	E /dev/sda5 1128M	    Linux	ext4
 /tmp	E /dev/sda6 128M	    Linux	ext4
 /var	E /dev/sda7 111M	    Linux	ext4

The rest of the configuration was taken care of entirely within 'install.conf', and it involved setting the desired hostname and host address to 'ttylinux' and 127.0.0.1 respectively, the local timezone to 'EST', configuring some basic network settings to connect ttylinux to to my network, and some options for the boot loader that included where it should be installed. At this point, I ran 'ttylinux-installer --config=install.conf /dev/hdc' and 'ttylinux-installer' then used the configuration in the file 'install.conf' to install ttylinux to the paritions I'd specified using the installation media on '/dev/hdc', and a moment later it was done!

Once the installation was complete, I used VirtualBox's virtual media manager to remove ut-ttylinux-i686-12.6.iso from the VM's virtual cdrom drive, and rebooted into the new system.

  • I'd initially tried playing around with an optional section in 'install.conf' that lets you install specific packages rather than the entire system; however, 'ttylinux-installer' kept failing with errors about missing files when I'd attempt to run it this way, and after a few attempts at some more creative solutions to the problem, I realized that I'd needed to use a full install when I discovered that the files the installer was looking for were in the few packages I'd been comfortable setting it to skip.

Startup

Figure 3 ttylinux booting after installation

Booting the VM for the first time after installing ttylinux, I was presented with a creatively themed lilo bootloader with a single option to start ttylinux that it selected automatically after a brief countdown. The installed ttylinux system loaded very similar to the install when it booted up, the only major difference I noticed as the text whipped by being that it also checked and mounted the partitions I'd defined in 'install.conf'. Once it had finished loading, I logged in with the same credentials as I had in the installer before promptly using 'passwd' to give the root user a more secure password, and then used 'vi' to edit '/etc/issue' and '/etc/issue.tty' to remove the line that explained the default username and password above each login prompt.

I quickly discovered that I couldn't seem to access the web, and when I checked 'ifconfig' to see that I appeared to have a functional network connection, I used my host OS to find the ip associated with 'www.google.com' and found that my VM was able to ping that, which meant that the problem was likely with '/etc/resolv.conf'. Sure enough, when I checked to see what was wrong with '/etc/resolv.conf' I found that it didn't exist, and after running the command "# echo 'nameserver 192.168.0.1' > /etc/resolv.conf" to create a new one that would use my router's local address to lookup URLs, I tried pinging 'www.google.com' and found that my problem had been fixed.

Everything seemed to be working at this point, and I decided to play around with the system to see what it was like...

Basic Operation

Figure 4 Using ttylinux to show some info about the system

As I stated earlier, the intended purpose of ttylinux is to "make one of the smallest up-to-date Linux systems that is similar to a larger distribution", and while it is small, I decided to take a look at what it was made of to see just how up to date and similar to a larger distribution it was...

I began by taking a look around the file system to see what makes ttylinux tick, and noticed that the '/dev' folder uses udev to manage devices just like nearly all modern distributions of linux; I changed 'SYMLINK+="cdrom"' in '/etc/udev/rules.d/70-persistent-cd.rules' to SYMLINK+="ccdrom"' to see whether rules would work, and sure enough, the link to the cdrom device '/dev/ccdrom' existed in place of '/dev/cdrom' when udev was restarted.

Being up to date means being able to do essential tasks over networks too, so I attempted to download a file with wget, use scp to copy a file to a remote server and log into a remote host using ssh to see if it met those basic networking requirements, and I was pleased to find myself successful in each case. When I noticed that ttylinux has ncurses, I found myself wondering if 'lynks' or 'links' would be available to browse the web, but it turns out that they're both too large to be reasonably considered for inclusion, and that a much more lightweight console-based web browser called 'retawq' was included instead, which albeit much less user friendly, does still seem to get the job done.

Curious how system services worked in ttylinux, I took a look and found that the files in /etc/sysconfig/ each allow for disabling or enabling a service on boot with a variable set to 'yes' or 'no', while some of them also include a variable containing command-line arguments as well. A combination of the 'rc.*' files in '/etc/rc.d/' then appear to be hard-coded to read the values of these variables and decide which services to start and what arguments to give them when they are.

There isn't a huge amount to play with in ttylinux beyond your typical command-line functionality, but its interesting to explore the system and imagine how it could be used to build a port that would be able to meet a set of requirements. Once you've gotten it installed, ttylinux appears to be a solid little system, and aside from needing to add '/etc/resolv.conf' manually, the system started up stable and fully functional straight from the first boot.

Usage Evaluation

To see if ttylinux would really live up to its name, I ran the command "# du -c -m /" and was impressed to find that the full i686 install only took up ~25 megabytes. The ttylinux [project website] reports on its front page that it "has an 8 MB file system and runs on i486 computers within 28 MB of RAM, but provides a complete command line environment and is ready for internet access", but digging a bit deeper I found that this is only true for the 'sm' version that uses a static '/dev' environment and uClib instead of Glibc, unlike the 'ut' version I installed, which the website states that it should have a 24 megabyte filesystem, just like the one I installed.

Command line programs that are typically included in distributions of Linux like 'file', 'man' and 'tree', are left out of ttylinux to conserve space, and while it did take some getting used to initially, not having them in the end slowed me down at times, but it never prevented me from doing what I'd intended to. I was sad to find 'vi' in my $PATH instead of 'vim', which brings much more to the table than a tailing 'm', but in the same respect as the command line applications that weren't included, the decision to choose 'vi' instead is understandable if you consider how much more space 'vim' would have taken up. Taking a look at what ttylinux does include on the other hand, I discovered that it actually has a fairly respectable array of functionality packed in its ~25 megabytes. It uses Busybox to provide a basic structure and set of Unix utilities, then includes a carefully selected collection of programs like 'adduser', 'wget' and 'fuser', which all seem to perform a commonly required task that would either be difficult or impossible to do without. There are also [add-ons] available to provide support for ntfs, the calc utility and an http server, and a [source distribution] exists that includes a build system if additional functionality is required.

Being minimalist by design, ttylinux is a lean OS that does an excellent job at providing an up-to-date, functional distribution that still manages to be one of the smallest on the block. I can't really fault it for what it doesn't include, and if anyone with a bit more space might want to use ttylinux as a basis to work from, the 'ws' variant available on the [downloads] page includes Alsa and more importantly GCC, so new applications can be built. Thinking back on my experience with ttylinux, the only real critique I can make at this point is for including the package selection feature in the non-beta ttylinux-installer script when it's clearly not yet stable, but overall I really do feel like it does a good job of accomplishing what it set out to do, and that it does it well.

Part 2

Software Packaging

Packages for ttylinux follow a naming convention that looks like <software_name>-<software_version>-<system_architecture>.tbz, and they consist of a file structure containing the files and folders to be installed, stored in a tar archive and compressed with bzip2. They can be manipulated by the ttylinux package manager ‘pacman’, which shares its name with the one used by Arch Linux despite appearing to be unique. The following are examples of how you can use pacman to list the packages currently installed on the system, install a package locally and delete packages:

  1. pacman -qa || # pacman --query-all (list all installed packages)
  2. pacman -i <package_file> || # pacman --install <package_file> (install a package locally)
  3. pacman -e <package_name> || # pacman --erase <package_name> (remove a package)

The ‘software catalogue’ ttylinux is extremely minimal. The 'ut' installation image I'm using only contains 17 packages by default, and the installer even allows for those to be deselected (although this ended up breaking the install in v12.6 for me, as mentioned earlier). While 'pacman' is a relatively powerful package manager, capable of generating its own packages as well as using a remote repository; this functionality seems intended mostly in support of ttylinux's aim to be convenient to build new distributions around, and ttylinux itself both lacks a repository of its own and only has 3 official packages offered as add-ons from the ttylinux site. Since ttylinux is so small, I feel each package plays a pivotal point in building it, and should therefore spend less time on each so all of them can be covered...

Major package versions

BASE PACKAGES

The following table is the collection of packages included in the base 'ut' installation. Each package is identified before comparing its ttylinux version to the version of the latest stable release (including how long its been since the out of date version came out), and then discussed briefly about what it does and why it might have been included in ttylinux.

Package Latest stable version Version in ttylinux Details
bash 4.2 4.1 (23 months old) Contributing 1.2 megabytes of the total ~26 that make up the whole system, BASH wouldn't have been included in ttylinux if it wasn't such an important piece, and while choosing a good shell is always important, it's even more so in cases like this where it's the exclusive user interface. BASH is a solid shell environment with a fairly well rounded way of working that manages to keep most people happy most of the time; it's also stood the test of time along with the rest of GNU, so it's become a bit of a standard in some respects, and therefore makes it the best choice for ttylinux since it can only choose one. BASH is nearly a year out of date in ttylinux, however, this is fair since with its slow release cycle, an update from the version 23 months ago has only just recently come out.
busybox 1.19.3 1.18.4 (8 months old) BusyBox is similar to GNU in that it provides a toolkit similar to the one in Unix, except instead of focusing on trying to have the best tools like GNU already does; it attempts to remain small and portable so it can be installed on virtually anything. All the versions of ttylinux use Busybox except the larger one, which I assume is at least in part so it can also use gcc as well as possibly because storage space is less of an issue for those who go this route.
Dropbear 54 52 (3 years old) SSH is an important tool on a network, both for remote management and for interacting with files (using scp). OpenSSH is the current standard for ssh clients and servers, however Dropbear is still quite respectable and leaves a much smaller footprint in comparison, which therefore makes it the ideal choice for ttylinux. It is running a 3 year old version, but the first update in three years was made this month, so you can't really blame ttylinux, and I'm sure the next version that comes out will have this updated
e2fsprogs 1.41.14 1.41.12 (6 months old) The ext2 file systems (including ext3 and ext4) have always been popular in Linux, but have been especially so since ReiserFS fell off the map when its developer went to jail for killing his wife; e2fsprogs are the utilities that allow these file systems to be created (using mkfs*), repaired (using fsck*) and an assortment of other administrative capabilities. Including this package in ttylinux wasn't just necessary, but required for setting initially setting the harddrives up, and still remains important after the fact so proper hard drive maintenance can occur.
glibc 12.14.1 2.12.1 (15 months old) A C library is required for providing various core functions and calls that programs can then interact with and while uClib, which the smallest ttylinux install of ttylinux: 'em' uses, is smaller and more lightweight, it also has reduced capabilities which it was likely decided glibc was worth the space to regain if it's available. In this package, there was still a much newer version than the one installed at the time of this ttylinux release, and I can only guess that it would have been for stability reasons that an older version would have been used here.
gpm 1.20.6 1.20.6 (latest) GPM provides mouse support to the console, which is a useful capability to have when ttylinux doesn't use a GUI at any point, and since it takes up less than 200kb of space, it appears to be a reasonable choice to include.
iptables 1.4.12.1 1.4.9.1 (15 months old) ttylinux is designed with the intent of being used to access the internet on older hardware in mind, and iptables offers a secure networking backend through any security an admin might setup through the kernel rather than simply providing what some might lookat as direct access with older and more basic technologies. Including this package seems as much of a no brainers as including glibc considering ttylinux's intended networking purposes. It is curious however, that a more recent package isn't being used here, which I assume would only be the case for stability reasons via a core component of the OS, like I assume for glibc.
kmodules 2003-01-01 2.6.38.1 (5 months old) The kernel itself doesn't belong to a package, but all its associated modules are packed in kmodules, which of course shares the same version number. Its 5 months out of date, which is about the same amount of time since the last version of ttylinux came out, and it seems likely that each release would include the most recent stable kernel. As far as why this package might have been included in distribution goes; kernel modules are key to hardware support and keeping the required memory use at a minimum thanks to their ability to be loaded/unloaded, and while they make senses to be included in pretty well any distribution, they're particularly relevant in a distribution that tries to keep itself as lightweight as ttylinux (at least until a kernel recompile can be done).
lilo 23.2 23.1 (12 months old) The system needs a bootloader, and lilo is one of the two trusted ways to go (the other being grub), both of which are relatively small if you clean up the unnecessary stuff. The most recent version after the included one that came out 12 months ago was released around the time of ttylinux's latest release, and it therefore likely wasn't ready to be thrown in for the release.
module-init-tools 3.12 3.12 (latest) This package is required for manipulating modules, and is therefore important for all the same reasons as the kmodule package.
ncurses 5.9 5.7 (3 years old) Ncurses offers about as close to a GUI as you can get in a terminal session without switching to a framebuffer device, which isn't inherently a best practice thing todo, not to mention that it isn't supported by ttylinux best I can tell (it's definitely not on the system I have running). Having Ncurses allows for things like application menus, progress bars and for text based web browsers (like retawq) to format their content among many other capabilities; although ncurses was likely installed as a dependency, it seems capable of improving the experience of a purely console environment enough to make it worth while including either way. I'm not sure why its using such an old version, but it is a library and if the issue's a dependency being incompatible with a newer version then that would be reasonable enough for me.
ppp 2002-04-05 2.4.5 (latest) PPP handles the protocol the internet travels over, and as an OS designed for networking, this package is a must.
retawq 0.2.6c 0.2.6c (latest) Not the most user friendly text based web browser, retawq is the smallest I'm aware of, and is therefore perfect to add to ttylinux in that it helps fulfil its goal of being able to get old hardware onto the internet, while not being counter productive to its other goal, which is to be the smallest modern and reasonably up to date distribution.
ttylinux-basefs 1.0 1.0 (latest) This package is nothing but a basic initial layout of folders and empty files, which I would suspect is done in this way so upgrades from the default layout can be made by upgrading this package; smart thinking!
ttylinux-utils 1.3 1.3 (latest) This package contains the programs and install.conf for installing ttylinux, as well as to init scripts: '/etc/rc.d/init.d/context' and '/etc/rc.d/init.d/rnd-pwd', and the package manager 'pacman' itself. It seems to include all the packages that I'm assuming were exclusively developed by ttylinux, and they only take up 174kb together.
udev 175 163 (13 months old) udev isn't included in the smaller builds of ttylinux, and it does increase the overall size a fair bit to have it, but at this point managing devices on a machine becomes much easier due to the ability to assign rules for how the kernel will behave when they connect or disconnect, and also because of built in rules that handle common devices like usb sticks already.
util-linux-ng 2.20.1 2.18 (16 months old) This package includes a single tiny utility that's capable of setting up and managing loop devices, which of course are the devices in /dev/ used when mounting an image with 'mount -o loop', and which I would consider quite important to providing a full repertoire of functionality.


ADD-ON PACKAGES

None of the additional packages are available through the installation, and each provides a less than critical function that to some could still be quite useful.

Package Latest stable version Version in ttylinux Details
thttpd 2.25b 2.25b (latest) This is a tiny web browser, which seems like it would be handy for turning old PCs into a personal use web server and takes up very little room doing so; its choice seems appropriate.
ntfs-3g 2011-04-12 2010.10.2 (6 months old) This package contains the tools required for interacting with an ntfs file system by both reading and writing, and since its not a supported file system for Linux, it doesn't make sense to full up previous disk space if it might not be used, but having it available as an option to install after the fact is definitely a good idea.
calc 2.12.4.4 2.12.4.2 (14 months old) This is a simple command line calculator program that can come in handy for quick calculations, when attempting to reduce the space taken up by the distribution however, leaving this as an optional add for after the fact is a good call.

Initialization

Most GNU/Linux environments (including ttylinux) execute a program called 'init' when they begin to load, and this program uses the configuration in a file called 'inittab' to then load the system. I took a look through ttylinux's rather brief '/etc/inittab', and found that it invokes '/etc/rc.d/rc.sysinit' almost immediately.

The script in '/etc/rc.d/rc.sysinit' begins by configuring the the shell to avoid closing when it receives a keyboard interrupt, a non-zero exit status, or the use of unset variables. It then includes '/etc/rc.d/rc.functions', which exports $PATH='/bin:/sbin:/usr/bin:/usr/sbin' and the values of a number of other environment variables too before defining a collection of functions that get used later on. When '/etc/rc.d/rc.functions' returns, '/etc/rc.d/rc.sysinit' exports $PATH='/bin:/sbin' before proceeding to set the console loglevel to 1, mounting the pseudo file-systems 'sys', 'proc' and '/proc/bus/usb', and finally remounting the Root filesystem as read-write before setting up '/etc/mtab' so the boot process can really start.

Next, '/etc/rc.d/rc.sysinit' defines a number of local variables with empty default values, and it uses '/proc/cmdline' to give them the value supplied as a command line argument if one was given. The script checks to see if the kernel was passed a hostname, and updates both '/etc/HOSTNAME' and '/etc/hosts' if it was. It then uses '/etc/HOSTNAME' to provide a value for $HOSTNAME if it contains one, or exports $HOSTNAME='localhost' if it doesn't. The kernel parameters are then set by '/sbin/sysctl' using the values provided by '/etc/sysctl.conf', and the kernel log level is then defined before any modules that haven't already been loaded by udev or the init script are now loaded from the list of modules defined in '/etc/modtab'.

Udev is then started by '/etc/rc.d/rc.sysinit', and '/dev', 'tmpfs' and '/dev/root' are all initialized before the script enables some low level features such as swapping, and the clock's time-zone is configured using '/etc/sysconfig/clock'. The root filesystem is remounted read-only before the script runs 'fsck' to check/fix any errors, and it's then remounted again back to read-write. The script attempts to mount a filesystem on /tmp, and then uses 'fsck' to check/fix the other filesystems before finally mounting them as well. With '/usr' available now, the script then exports $PATH='/bin:/sbin:/usr/bin:/usr/sbin' and initializes console fonts and keyboard interactivity before attempting to load any scsi drives that may exist too and tidying up temporary files left behind. Now that the system is almost finished starting, the script attempts to load any module dependencies that might still be required by running 'depmod.

The next part of '/etc/rc.d/rc.sysinit' loads a collection of optional features such as networking support, whether logins are allowed etc, and these use the values in the local variables defined earlier using '/proc/cmdline'. It then executes a hack to prevent ssh from generating keys if the cpu is too slow, and includes '/etc/rc.d/rc.local' to run any user-supplied scripts it might include. Any system services placed in '/etc/rc.d/rc.startup/' (context, crond, firewall, gpm, inetd, network, random, rnd-pwd, sshd, syslog) will now load, and what follows is a series of checks to see what state the computer is in (first boot?), so it can provide the appropriate clean-up and/or fixes required before finally returning to '/etc/inittab' to finish initializing the system.

Six tty consoles are now loaded thanks to '/etc/inittab', which then sets the key combination ctrl-alt-del to launch '/sbin/reboot' and the shutdown script '/etc/rc.d/rc.sysdone' to run as the computer shuts itself down. The greeting above the login prompt is generated from the file '/etc/issue', and the the login prompt below it allows you to login and finally use the system!

References

"ttylinux Homepage" Minimal Linux. Web. 19 Oct, 2011. <http://ttylinux.net>

"ttylinux User Guide" Minimal Linux. Web. 18 Nov, 2011. <http://ttylinux.net/Documents/single/temp.html>

"Dropbear SSH server and client" Matt Johnston. Web. 5 Dec, 2011. <https://matt.ucc.asn.au/dropbear/dropbear.html>

"BUSYBOX" Erik Andersen. Web. 5 Dec, 2011. <http://busybox.net/>

"uClibc" Erik Andersen. Web. 5 Dec, 2011. <http://uclibc.org/FAQ.html>

"File system killer Reiser rejected 3-year sentence" The Register. Web. 5 Dec, 2011. <http://www.theregister.co.uk/2008/07/10/reiser_rejected_voluntary_manslaughter_plea/>

"Calc - C-style arbitrary precision calculator" Landon Curt Noll. Web. 5 Dec, 2011. <http://www.isthe.com/chongo/tech/comp/calc/>

"NTFS-3G + Ntfsprogs" Tuxera. Web. 5 Dec, 2011. <http://www.tuxera.com/community/ntfs-3g-download/>

"thttpd" ACME Labs. Web. 5 Dec, 2011. <http://www.acme.com/software/thttpd/>

"utils/util-linux/util-linux.git" kernel.org. Web. 5 Dec, 2011. <http://git.kernel.org/?p=utils/util-linux/util-linux.git>

"udev project files: udev" launchpad.net. Web. 5 Dec, 2011. <https://launchpad.net/udev/+download>

"retawq Home Page" Sourceforge. Web. 5 Dec, 2011. <http://retawq.sourceforge.net/>

"ppp" Samba. Web. 5 Dec, 2011. <http://ppp.samba.org/>

"Announcing ncurses 5.9" GNU Project. Web. 5 Dec, 2011. <http://www.gnu.org/software/ncurses/>

"Main Page - Linux Kernel Modules Wiki" kernel.org. Web. 5 Dec, 2011. <https://modules.wiki.kernel.org>

"Alioth: LILO Linux Bootloader: Project Home" Alioth Debian. Web. 5 Dec, 2011. <https://alioth.debian.org/projects/lilo/>

"The Linux Kernel Archives" kernel.org. Web. 5 Dec, 2011. <http://www.kernel.org/>

"netfilter/iptables project homepage" netfilter. Web. 5 Dec, 2011. <http://www.netfilter.org/projects/iptables/index.html>

"gpm" Nico Schottelius. Web. 5 Dec, 2011. <http://www.nico.schottelius.org/software/gpm/>

"GNU C Library" GNU Project. Web. 5 Dec, 2011. <http://www.gnu.org/s/libc/>

"E2fsprogs: Ext2 Filesystem Utilities" Sourceforge. Web. 5 Dec, 2011. <http://e2fsprogs.sourceforge.net/>

"Bash" GNU Project. Web. 5 Dec, 2011. <http://www.gnu.org/software/bash/bash.html>

"proc(5) - Linux man page" die.net. Web. 5 Dec, 2011. <http://linux.die.net/man/5/proc>

Linux man pages: <man init>