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

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

We have seen various Linux distributions, and yet many others continue to appear. Some are as small as DLX which sits on a single floppy; others are as big as Red Hat 6.2, packed in five CDs. Things seem to become more complex and harder to manage as systems grow. How is a Linux system put together from pieces of free code? How can we assemble and customize our own system for a particular purpose? It seems to be a hard task.

However, from the view of the base system, in principle, all distributions are assembled in a similar way. The difference is that big ones are armed with more packages and more fancy stuff targeted at more general audiences, and small ones have fewer goodies and are aimed at relatively narrow and specific user groups.

Fully featured Linux distributions are usually unnecessarily big for specialized situations. For example, embedded applications need a slim base for their particular situations, and there are already small Linux distributions available for these purposes. However, because there are so many factors to consider, no one can claim that their distribution is comprehensive and satisfies all customers.

Usually an application needs a customized base system to work efficiently. You can pay for a solution from many Linux service providers, or you can do it yourself. Sometimes knowing how to build the base system on your own is more beneficial. With such skills and knowledge, engineers can easily control and improve the system's behavior for the needs of their customers. DIY (Do-It-Yourself) is not just fun, but strategically important in some cases, and more people are recognizing the value Linux offers. By doing so, you acquire the ability to customize not only the Linux kernel but also all other components of your system to achieve the optimizations best suited for your requirements.

This article tries to tell readers that building your own base Linux is not a daunting task. It tells our experiences and gives a brief introduction to building and customizing a Linux system. It is a base system: small, clean and ready to go. We try to make the complex simple, without losing generality and effectiveness. We show how to make the building steps as easy as 1-2-3, and how to customize this system to be minimal, accommodated in one floppy. After all, it should be good enough to be used as a start point for a base system to run any typical applications. This is possible because we build the system directly from unchanged sources. This allows us to always use the latest stable versions and make all required kernel services available.

Linux System

A system is simply defined as a combination of inherently connected parts. A Linux system (only considering software in this article) is a combination of a Linux kernel and other components which make the kernel useful. All software components except the kernel need to be resident in a root file system (there may be a few other file systems, but they must be mounted under the root tree to become visible). So, technically, we can simply consider a Linux system as a combination of a kernel and a root file system. All Linux distributions are arranged in this way. For example, a fully installed Linux system is a kernel plus a big root file system. A Linux installation disk and a rescue system are used to install a full system and to repair problem systems, respectively. They are also organized in the same way; that is, consisting of a kernel and an initial root file system, but the initial root file system is small and only holds a few basic components necessary to do limited jobs (see Figure 1). The Linux kernel has been coded to take special measures to locate the root file system, either from a normal file system or from a compressed image of an initial root file system.

Figure 1. A Linux System

The Approach

Given an application, we want to run it above the kernel using shared libraries on a box. Assume the application doesn't require any rare features which Linux doesn't provide at the moment. We want a base system that can run this application and provide some basic control and management as well. A typical case of the base system is shown in Figure 2. Note that this figure is not complete because a utility may be statically linked, which doesn't require a shared library and a utility may be an a.out style, which doesn't use a dynamic loader.

Figure 2. A Base System

If the application is self-sufficient, that is, statically linked with everything required at runtime, it can run right over the kernel without any support from shared libraries. The base system in this case may mean only the Linux kernel itself. However, almost all systems need support from one or more utilities to manage things like file operations and system monitoring, using commands like mount and ps. We consider a base system to be a combination of the kernel, the dynamic loader, a set of libraries and a set of utilities.

Like many other systems, our goal is to show how to create the system on a floppy with both the kernel and a compressed image of an initial root file system, as shown in Figure 3. This compressed initial root file system will be uncompressed by the kernel and put into a ramdisk, that is, a space of RAM set aside to hold a small Linux file system. Creating such a base system is often straight-forward, but rather tedious for most people. We simplify the procedure. The idea is to design a well-organized hierarchy of makefiles which will extract sources, compile, and setup the contents of the initial ramdisk, then prepare and pack the whole system.

Figure 3. Arrangement of System Components

Customization of the above base system depends on the requirements of the application that will run on the box. Choose a configuration for the kernel, a dynamic loader, a set of libraries that are necessary for the application and utilities, and a set of basic utilities which are required to control and manage the system. Then, compile all these things in a consistent environment. After that, package the results and make it bootable. If something is missing, you are free to add it to the list, and make it again.



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