Sunday, November 18, 2012

Creating the Tribblix ramdisk

When you're running Tribblix off the live iso image, most of what you're using is actually just one file - the initial ramdisk loaded into memory.

Putting together the ramdisk was one of the trickier areas of getting Tribblix working. It tok a while to work out exactly what needed to be in there.

As part of the build, a minimalist OS is installed into a build area. The simplest approach is to put all of that into the ramdisk. That works, but can be pretty large - for a base build, you're looking at a 512M ramdisk. While this is fine for many modern systems, it's a significant constraint when installing into VirtualBox (because you can only assign a relatively small fraction of your available memory to the entire virtual instance). Besides, being efficient is a target for Tribblix.

So what happens is that /usr, which is the largest part, and can get very large indeed, is handled separately. What ends up in the ramdisk is everything else, with /usr mounted later.

However, there's a catch. There's a tiny amount of /usr that needs to be in the ramdisk to get /usr mounted. Part of this is intrinsic to the special mechanism that's used to mount /usr, and it took some experimentation to work out exactly what files are required.

Other than /usr, the ramdisk contains everything that would be installed. The installation routine simply copies the running OS to disk (and then optionally adds further packages). So there's no fiddling around with what's on the ramdisk. (In OpenSolaris and OpenIndiana, some of the files are parked off in solarismisc.zlib and linked to. I don't need to do that, so solarismisc.zlib doesn't exist in Tribblix.)

And because the contents of the installed system are taken straight off the ramdisk, the ramdisk contains both 32 and 64-bit files. Creating separate 32 and 64-bit ramdisks might make each ramdisk smaller, but would take up more space overall (because there is duplication) and makes the install much more complex. Thus, when grub boots, it uses $ISADIR to choose the right kernel but the boot archive is fixed.

So how is the ramdisk built? It's actually very simple.
  1. Use mkfile to create a file of the correct size, such as 192m
  2. Use lofiadm to create a device containing the file
  3. Use newfs to create a ufs file system on the device. Because we know exactly what it's for we can tune the free space to zero and the number of inodes
  4. Mount that somewhere temporarily
  5. Copy all the temporary install location to it, except /usr
  6. Copy the handful of files from /usr into place
  7. Drop an SMF repository into place. (I copy one from a booted system that's correctly imported.)
  8. There are a few files and directories need by the live boot that need to be created
  9. Unmount the file system and remove the lofi device, then gzip the file.
  10. Then copy the compressed file into where you've told grub to look for the boot archive (/platform/i86pc/boot_archive)
A corollorary to this design is that the iso doesn't need to contain copies of what's in the ramdisk - the iso itself just has /platform (to boot, and containing the ramdisk), solaris.zlib that contains /usr, pkgs.zlib that contains additional packages, and a few odd files required by the installation script.

Tuesday, November 06, 2012

Tribblix Milestone 1

An updated release of Tribblix is now available for download.

This version is built from the same base as the initial release, namely OpenIndiana OI151a7, so is whatever version of Illumos that corresponds to.

Milestone 1 adds Xfce, Firefox 16.0.1, emacs, python, cmake, and AfterStep.

Despite all the additional software, the ISO image isn't much larger than before, due to significant improvements in the way that the ISO is constructed. Essentially, there was quite a bit of duplication on the ISO of files that were already in the ramdisk.

Tribblix is still a long way from production ready, but for everyday office use it's got a decent desktop, an editor, and a web browser, so that's a fair fraction of the workload covered.