Using CompactFlash Cards in Your Embedded Linux System

Use a CompactFlash card as a nonmechanical alternative to a disk drive.
Setting up the Web Server

For this application I chose the tiny-turbo web server. This web server is very small and takes up very little memory. It also allows CGI programs, so you can write web programs. This would let you write a web application as the user interface to your devices. The web server is installed in the /usr/httpd directory. The configuration file is in /etc/thttpd.conf file and is listed as:

Installing the Boot Loader

Now that the partitions are made, the filesystem created and the kernel built, you need to install a boot loader. The BIOS in PC hardware will load the first sector of the first hard drive when the system boots. You need to have software on your system that will load your Linux kernel from the code in this first sector of the hard drive. I used the LILO boot loader because I've been using this loader for years. It can do so much more than just load a single Linux kernel, but it can do our simple task also.

I had problems making it load the boot-loader software on the CompactFlash card in my development system because the card was addressed at /dev/hdc in my development box. The card will be located at /dev/hda in the target system. Fortunately, there is a way to do it. I found instructions in the LILO mini-HOWTO. See Listing 3 for the contents of the /etc/lilo.conf file. Assuming that you have mounted your CompactFlash card as /mnt/hda1 on your development system, the command to load the boot loader on your CompactFlash card is:

/mnt/hda1/sbin/lilo -r /mnt/hda1 -C etc/lilo.conf

Be very careful with this command. It is possible to replace the boot loader on your development system by mistake. It could cause your development system not to boot properly. It's always a good idea to keep a boot floppy around just in case.

Listing 3. A LILO configuration that will make the CompactFlash card bootable.

Test It Out

You should now be ready to test your CompactFlash boot device. Shut down your development system and remove the CompactFlash card. Install the card in your target system and turn it on. For testing purposes, it is best to have a display adapter in your target system. If this isn't possible, you can configure the kernel to use a serial port as the console device. If you have a display connected to your target, you should see the kernel messages as the kernel boots. When the kernel is finished booting, it will prompt you to press Enter to start a shell.

Congratulations! You have built a Linux operating system for an embedded device from scratch. You can now test the web server. You can check the web server from another computer. Go to the URL in a browser on another computer. Make sure to substitute your IP address in the URL. If you get a welcome screen, it worked. There is a very simple CGI program on the embedded system at that you can try.


As you can see, installing an embedded Linux system isn't very difficult. Now that the OS is installed and working, you just need to write the code for your embedded system and copy it to the CompactFlash card. This is something that anyone with a little knowledge of Linux can accomplish. Good luck building your embedded system!


Jay Sissom is a systems analyst in the computing department at Indiana University in Bloomington, Indiana. He is very busy finishing an Electrical Engineering degree. Amateur radio and playing the piano are two of his hobbies. He likes building electronic things in what little spare time he has between work and school. You can send him e-mail at


White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState