Customize Linux from the Bottom—Building Your Own Linux Base System

Can't find a system that has everything you want? Build your own.
Creating a Base System

As far as we know, it is hard to find a document that tell us in detail how to put images, executables, binaries and scripts together; in other words, to package things together, to assemble a system. Different systems may take different approaches to packaging, although components can be created in the same way. The easiest and most popular way is packaging on floppies. The general steps of packaging a bootable system on a single floppy, that is a boot/root floppy, can be summarized in the following few steps:

1. Create individual items needed for the system, such as the kernel image, libraries, executables, scripts and configuration etc.2. Create the directory structure of the initial root file system for the base system.3. Move things to the root file system and create items like device nodes.4. Create the compressed root file system.5. Tell the kernel where to find the initial root file system image by setting some flags in the kernel image.6. Write the kernel and the compressed root image to a floppy and make it bootable. To show more details, we wrote a set of makefiles. They are actually instructions to implement the above steps and to create a small base system from freely available packages. We run a simple application called a netperf sever which tests TCP/IP stack performance and is also freely available from the Web. We provide these instructions in Resources. It may not be simple to run, but curious readers can dig into the lines and find how to build a base system from scratch.

An application can be started in different ways depending on how the base system is configured. In most of cases, a Linux kernel is configured to run a startup script or a binary executable, called init or linuxrc, in the initial root file system after the kernel is up. This init program usually does things like remount the root file system to allow read/write permissions, mount other file systems like proc, and initialize other parts of the system, such as starting a shell interface or running the application immediately. The SysVInit program is very popular in most Linux distributions for this purpose.

For our base system, we don't need a complex init sequence to demonstrate. So, we simply write a shell script like the following. Anyone is free to change and add more commands to it:

mount -n -o remount,rw /
mount /proc /proc -t proc
echo  MyCompanyName, Version X.Y. Built Z, August 2000
exec /bin/sh

As an exercise, it might look better if you have the above echo line in your application, and start the application at the end of the script instead of running the standard shell. An example in C++:

__DATE__ << __TIME__;
In our case, the system prompts after it is up.
pipe-elinux> MyCompanyName, Version X.Y,
Build Z, August 2000

Making It More Attractive

After the base system is up, you might think it is not much use without any interesting applications. But it is a base from which you could start your big project. One by one, you can gradually add things into this base system, making it more and more attractive. The following examples might be worth considering:

  • a init program : SysVInit is a good choice, but it seems too big for simple applications

  • a security facility: add login support

  • an editor : vi or emacs

  • more networking services: telnet or ftp dæmons

  • a GUI : X is a choice

  • non-volatile storage: flash memory and hard disk support.

  • add more loadable modules

  • use rpm to manage packages

We don't really need to recompile every package we choose, because we can easily find a binary already compiled for a processor. Like our system, the host and the target machines are the same type, so, we can just use most of the binaries found on the host machine. For example, for the utility top, we just copy the binary into our base system; and then it runs. Things are not always that simple, however. Because most often we have to sort out the dependencies for an executable, that is, the shared libraries it needs and configuration files it reads, usually we don't know until we run it. However, some tools can help us with this. ldd and strace can tell us these dependencies. For example, once I tried successfully to run Emacs on the base system by simply copying the executable (emacs-nox), a few shared libs and configuration files to the base system. This usually helps us a lot during the development and saves a lot of time.

You might not be satisfied with booting from floppies. Instead, you can implement booting from EPROM or others. To do this, you have to redesign your packaging approach, but the components are mostly unchanged. What's specific here is the kernel image loader. Booting can be implemented like:

  • boot from EPROM

  • boot from Networks

  • boot from devices like flash, hard disk partition, CD-ROM and ZIP disks; that is, any devices other than floppies

  • boot from other OS

If you like and want to spend more time, you can make your system as fancy as many other successful systems already in the field.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Sudhakarraj T's picture


My requirement is, my application shoud start in the Linux GUI before my Linux Desktop gets loaded. If i close my application then I can view my Linux desktop. To achieve this what configuration i neeed to make changes
Please suggest me

How to build a Linux Kernel Image for Pocket PC?

Mohit Vohra's picture

Respected Sir

I am a M.E. student in Software Systems in BITS, Pilani, India. I am currently working on some experiments on Pocket PCs and tablet PCs and Pocket PC phones in the context of Pervasive Computing.

I have gone through your introductory article that encourages others to try and compress basic features of linux in as small devices as floppies. Though the article was helpful in a way that it pinpointed the basic steps required to make an image of linux, it still didn't clearly some of my doubts which are as follows:

1. what basic loadable modules will I need to include with which I can provide basic linux features on a pocket pc.
2. whether its possible for one to load multiple operating systems externally by say, a compact flash card for example onto that Pocket PC? If yes then how to do it?
3. And last but not the least, when you mentioned that you can create a rescue disk for your own distribution of linux, can that image be used on even a small device such as a pocket pc that has support for some RAM and some secondary storage (around 32 to 64 MB ram and 32 to 64 MB secondary storage for instance)?

The reason for these questions is that as part of my experiment I am trying to build a Linux kernel image for a Pocket PC and I want to load it externally, so that when I boot Pocket PC, it gives a choice between Windows Mobile and Linux image.

I would be grateful if you could help me in clearing the doubts that I mentioned as that will be a big step towards my eventual implementation of a Linux Kernel image on a Pocket PC.

Thank you.

Sincerely Yours,
Mohit Vohra
M.E. Software Systems Student,
Birla Institute of Technology & Science (BITS),
Pilani, INDIA


Anonymous's picture

hi , can you help me I want to customize linux kernel and want give me some books or support to do that

Linux customization

Ratnesh jha's picture

Dear Mohit ,
I have gone through ur mail ,where u r enquiring for the linux customization for small palm mobile .I am also need of same kind of application please provide me the full detail about how to customize and
necessary steps for the implementation .
I will be highly oblise for the kind help.

Ratnesh Jha