Brian Writes about His BOEL
Brian's Own Embedded Linux, or BOEL as it is affectionately known, was created as part of the SystemImager Project. SystemImager is a tool used for, well, imaging systems and distributing live updates. Part of the imaging process involves booting a client machine in such a way that its hard disks are not in use and therefore are available for manipulation. The SystemImager autoinstall client does this by using a root filesystem that exists entirely in memory, or an initrd (initial RAM disk). This initrd and the kernel that goes with it are the embedded Linux system we call BOEL.
One of my initial requirements for BOEL was that it had to fit on a single floppy. I wanted to be able to boot a virgin machine from a floppy diskette and have it come up to a point where it could communicate with the network and access its hard disk(s). From that point, I figured I could pull over any scripts or tools necessary that didn't fit on the floppy itself.
I started by using tomsrtbt and simply added my custom commands to one of its initialization scripts. As SystemImager progressed, I began to customize tomsrtbt. One day I hit a big snag. I needed to add some new binaries to the boot diskette. I copied the binaries over and hoped they would work. Some did, but some didn't. For the ones that didn't, it was because the binaries were linked dynamically to libraries that didn't match up with the libraries on the boot diskette.
After a bit of contemplation, I tried two different hacks before stumbling upon a real solution. The first hack was to install an old version of Linux with a small libc5, custom compile all my binaries there and copy the binaries and the relevant libraries over. The second hack was to compile the binaries with statically linked libraries. By compiling the libraries directly into the binaries, it no longer mattered which libraries, if any, existed on the boot diskette. While this worked for adding one or two binaries to tomsrtbt, I quickly ran out of space as I added new binaries over time. I was able to remove components from tomsrtbt that I didn't need, and I used strip on my binaries to remove the symbols and make them smaller. But having pieces of the libraries compiled into each static binary is very redundant and inefficient from a disk-space perspective.
At this point, I stumbled upon Debian's PIC (Position Independent Code) libraries. These are the standard libraries, broken up into little pieces. They are broken up in such a way that you can take only the pieces you need and combine them together into a single library file. No recompiling is necessary. You don't even have to know which pieces you require--there's a little shell script that does that for you called mklibs.sh. When you run this script, it examines the binary or binaries you point it at, determines which pieces of which libraries are needed, grabs the appropriate pieces from the PIC libraries, squashes them together and produces a directory full of library files--perfectly customized to your binaries, with no more and no less than exactly what you need. This alone was enough to make me a Debian convert.
Unfortunately, there is relatively little documentation on the PIC libraries. I'm not a C-library developer, so take this with a grain of salt, but here is a little bit of additional (unconfirmed) information I've been able to glean from PIC-related scripts, the installed PIC libraries and their supporting files and my use of the wonderful little beasties:
PIC libraries appear to be granular down to the function.
As of this writing, the PIC libraries are available for glibc releases 2.0 through 2.2.5.
PIC libraries are currently available for the glibc, libnewt and slang libraries.
If you want to try out the PIC libraries, run apt-get install boot-floppies from a Debian system. When that completes, untar /usr/src/boot-floppies.tar.gz. You will find the mklibs.sh script in the /usr/src/boot-floppies/scripts/rootdisk/ directory. To try it out, find a dynamically linked binary, say cat, and verify that it is dynamically linked with the file command: file /bin/cat. If it is dynamically linked, you'll see something like ``dynamically linked (uses shared libs)'' in the output. Now let's create a temporary directory for our test libraries: mkdir /tmp/lib. Then cd into the directory where our script lives:
cd /usr/src/boot-floppies/scripts/rootdisk/Next, run the command to create our new libraries:
./mklibs.sh -v -d /tmp/lib /bin/catIf we do an ls -l /tmp/lib/, we can see that our new C library is about 408K (on my system). To create a minimal library for more than one binary, just include them all at the end of the command line--wild cards are okay.
Trending Topics
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
| Razor-qt 0.4 - Qt based Desktop Environment | Jan 30, 2012 |
- Fun with ethtool
- Parallel Programming with NVIDIA CUDA
- Readers' Choice Awards 2011
- 100% disappointed with the decision to go all digital.
- Linux-Based X Terminals with XDMCP
- Validate an E-Mail Address with PHP, the Right Way
- You Need A Budget
- The Linux powered LAN Gaming House
- Build Your Own Arcade Game Player and Relive the '80s!
- Why Python?





3 hours 50 min ago
8 hours 56 min ago
9 hours 57 min ago
19 hours 24 min ago
19 hours 35 min ago
1 day 1 hour ago
1 day 5 hours ago
1 day 6 hours ago
1 day 6 hours ago
1 day 11 hours ago