Difference between revisions of "COMP 3000 2011 Report: ttylinux"

From Soma-notes
Jump to navigation Jump to search
Line 125: Line 125:
| 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.
| 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.
|-
|-
|
|}
|}



Revision as of 23:06, 5 December 2011

Part 1

Background

The distribution I chose is ttylinux, named for its initial orientation towards TeleTYpewriter, or TTY serial interfaces. It caters itself to a target audience that includes both users, looking either to get older hardware up and running on the web or for a lightweight portable system they can boot off a USB stick, and developers who are either looking for an OS they can use on embedded systems or for one to base their own variant of Linux on. 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 its website.

You can download ttylinux on the [project website], or from one of a number of the mirrors it lists. Derived from scratch, ttylinux has a file system that can be as small as ~8 megabytes, making it as little as ~12 megabytes with the kernel; however, the smallest default install for i686 uses ~25 megabytes.

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, and 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 most minimal i686 compatible install (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 version of ttylinux that appears to be about the same as it intends the finished install to look like, and you're presented with a shell prompt where I was able to login with the username 'root', and 'password' for the password. The currently out of date [ttylinux User Guide] explains a method of installation that seems to involve a somewhat manual install process, but in the root user's home directory, I discovered a file named 'install.conf' that explained a (relatively) more user friendly way, and I decided to leave the ttylinux User Guide behind in favour of following this.

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', some basic network configuration to connect to my network using the bridged network adapter I'd created, and some options for the boot loader including where it should be installed. At this point, I ran 'ttylinux-installer --config=install.conf /dev/hdc', meaning that 'ttylinux-installer' would use './install.conf' as the configuration file and that the install cd was /dev/hdc, and it quickly used the configuration I'd set to format the partitions to the filesystems I'd set for them, created a chroot environment using them and installing ttylinux to in the new environment with the settings I'd chosen.

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

Looking in the file '/etc/inittab' to see what it does when the system starts, I found that it's set to call the init script in '/etc/rc.d/rc.sysinit', so I proceeded to take a look at that. The first thing I noticed is that this script utilizes the losetup program, which is provided by in the util-linux-ng, and so it sounds like uninstalling that package could potentially have a negative impact on your computer's ability to start.

When the start-up script first begins to run, it protects itself against keyboard interaction and mounts the pseudo-file systems like /proc before then remounting root as read-write, and initializing /etc/mtab. The script then checks to see if any kernel or service options have been set using variables that exist within the script, which a user can change to effect the outcome of a series of if statements that follow. The kernel options seem to be looking for a string that has some effect, but many of the options for services such as sshd can as simple as having a 0 for off and 1 for on.

The script then checks to ensure that hostname information is working whether supplied by a user or expected to take care of things itself. Any kernel parameters set in /etc/sysctl.conf are now taken care of, and then the kernel log level is set, which defines how important something need to be before a warning will appear on the screen. The kernel modules that haven't already been loaded for reasons such as needing specific hardware that requires a module to be involved in the boot process, and which aren't loaded automatically as needed by udev, will then be loaded using the list of modules defined in /etc/modtab.

UDEV is then started, setting up /dev and tmpfs along with a device for the root user, before the system continues by starting some low level features such as swapping and configuring the kernel clock using an optionally provided configuration file. The script continues by checking the root file system for errors before setting up /tmp with a file system before checking and mounting the other filesystems, which I'm thinking might be the case so the /tmp folder exists in case anything else goes wrong during a file system check. With the /usr folder something you know to be available now, console fonts and keyboard interactivity gets initiated, and if any scsi exists, it tries to load that as well before finally cleaning up all the excess files that would have been left behind, runing 'depmod' to grab any additional modules you might not know need. The script adds a hack to keep from generating ssh keys when a cpu is too slow, and initiates /etc/rc.d/rc.local (for anything a user might have put in there themselves) before attempting to initiate system services that are set to turn on. Finally, the script runs through a series of checks for things like whether its the PC's first boot, and then cleans/fixes things as they're required until reaching the end where memory is cleaned up as the script ends.

The user is now at a login prompt, using dialog from either /etc/issue, /etc/issue.net or /etc/issue.tty depending on how the user is trying to login.

References

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

"ttylinux User Guide" Minimal Linux. Web. 18 Nov, 2011. <http://www.minimalinux.org/ttylinux/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>