FirstRibIT

The next FirstRib matter I intend to blog a bit about is the process of building a FirstRib-based distro.

However, I find this topic a bit tricky to write because actually there are several somewhat different ways of doing it. Some scenarios require modules to be inserted inside the small FirstRib skeleton initrd.gz component. Some others, because they utilize kernels that are built with most disk device drivers built in (which some refer to as ‘huge kernels’) only need the unmodified FirstRib-provided skeleton initrd.gz to boot the resultant system. The default FirstRib skeleton initrd.gz is under 700 kBytes in size prior to any modules being inserted inside it, so the use of a huge kernel actually helps to build a distro that is as small as possible.

As a general FirstRib distro design rule, however, all you need is a suitable root filesystem, which contains your whole Linux system, along with a suitably configured Firstrib initrd.gz to provide all the FirstRib frugal install overlayfs magic.

  1. In this first blog on this topic I'll simply summarize the basics of how the previously named weedogit script, which has recently been renamed ‘FirstRibIT’, is able to make a FirstRib frugal install using the root filesystem provided by the installation media of many mainstream distros. It should be noted that FirstRibIT pretty much always uses the method of extracting the kernel modules and inserting them into the FirstRib skeleton initrd.gz prior to booting.

  2. After this first post on the topic I'll give another example, which will be how to take an already full installed distribution, where I'll use the example of a full installation of Zorin lite, and turn that into a frugal install via some simple manipulations and the use again of FirstRib initrd.gz to boot the result.

  3. In a follow on blog, I'll next then explain how to use FirstRib initrd.gz with a huge kernel (such as is done in KLV-Airedale). There are actually two possible scenarios for that: one where the kernel includes a driver for overlayfs, and one where overlayfs is only available as a module.

  4. Finally, though there may be some time before I get round to this one, I'll explain the original method of creating a unique FirstRib-based disto using but two simple build scripts: the first such script, build_firstrib_rootfs, being used to build the unique root filesystem you want with the help of an addon plugin containing the main distro build commands (such as packages to install and all system configuration code required), and then the second script, which is used to build the FirstRib initrd such that it is specially configured to work with the overall root filesystem built.

KLV-Airedale construction actually uses a combination of 3. and 4. above because it not only takes advantage of a huge kernel, and thus only needs to use the smallest FirstRib skeleton initrd.gz, but also uses the two build script method via a firstrib build plugin recipe designed by rockedge (Erik) admin/owner of the PLDF.

1. Brief explanation of how FirstRibIT basically works

The FirstRibIT shell script (renamed from original weedogit) basically automates how to make a FirstRib initrd frugal installation from many distrowatch-listed distro installation isos. You can best see how that is done, by carefully studying the FirstRibIT script itself. For example you can study how it is able to take an official Ubuntu installation iso and convert it into a FirstRib initrd.gz frugal installation. For this simple post I'll simply summarise the main steps that FirstRibIT script carries out:

  1. Fetches appropriate pre-made FirstRib skeleton initrd.gz from the cloud.

  2. Fetches the iso to be made into a FirstRib frugal installation.

  3. Extracts the image of the root filesystem out of the iso. That image is most usually in the form of one or more squashed filesystems. Each squashed filesystem is then renamed to start with a 2-digit numeric, which is used by the FirstRib initrd to determine its position in the overlay.

  4. Copies the vmlinuz kernel out for later booting via a bootloader such as grub2.

  5. Extracts a copy of lib/modules/XXX out of the above extracted root filesystem (after temporarily mounting it for access to its contents), uncompresses the FirstRib initrd.gz cpio archive and makes a copy of these modules into /usr/lib/XXX inside the uncompressed initrd.gz after which it recompresses that back as a new initrd.gz that will be used to boot.

  6. Updates root and user login passwords via a temporary overlay involving the root filesystem and a chroot into the merged result followed by appropriate use of the passwd command. The result of that temporary merged overlay is then kept and used as an extra NN addon layer such that the new passwords are available on booting the new FirstRib-based frugal installation.

By that stage the directory to be booted from should now contain all of the necessary frugal install components: vmlinuz, the module-including FirstRib initrd.gz, and the extracted main root filesystem in the form of one or more squashfs files. That's all there basically is to that method - the resulting frugal install can then be booted via a bootloader. Using grub.cfg as an example:

menuentry "FR_testinstall" {
    insmod ext2
    search --no-floppy --fs-uuid --set 424d8f42-e835-4111-9053-dd086b3d38e8
    linux /FR_testinstall/vmlinuz w_bootfrom=UUID=424d8f42-e835-4111-9053-dd086b3d38e8=/FR_testinstall
    initrd /FR_testinstall/initrd.gz
}

where FR_testinstall is the name of the directory you used for the frugal installation, and the UUID shown (obtained for example from blkid command) was that of the partition where the FR_testinstall was made. Of course, you'd use your own system partition's UUID and your own name for the installation directory.


Tiny Linux Blog: https://www.tinylinux.info/

Avatar
wiak
sometimes Linux system/apps developer

My earlier research interests included TCP/IP performance/optimisation over noise-prone, long-delay, VSAT links; and cloud-based, autobuild, virtual machines network construction methodologies for distance learning data-comms students’ research and laboratory work.