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.

1 Comments:

At 3:20 AM, Blogger esther said...

My cousin recommended this blog and she was totally right keep up the fantastic work!



Web Design Packages

 

Post a Comment

<< Home