Building Tiny Linux Systems with Busybox, Part 2: Building the Kernel
You'll need the genromfs program to generate the ROM file system image. If you are using Debian or Red Hat, it's already packaged for you as part of the standard system; you'll just need to run the command to install it. If your Linux distribution doesn't include a prepackaged version, at this writing the program can be found at ftp://ibiblio.org/pub/Linux/system/recovery/genromfs-0.3.tar.gz. Install the program, change directory to the directory that contains tiny-linux and run these commands:
genromfs -d tiny-linux -f fs
This creates the ROM file system image in the file fs. Now, compress the file system image using the gzip command:
gzip -9 fsThat will create the file fs.gz, which is about half the size of the uncompressed version.
We'll need one more program to build our floppy: syslinux. This is an i386 bootstrap program that will load a kernel and a compressed root file system image from a floppy, hard disk or CD. Again, it's prepackaged with Debian or Red Hat and can be found, at this writing, at ftp://ibiblio.org/pub/Linux/system/boot/loaders/syslinux-1.48.tar.gz.
Create an MS-DOS file system on a floppy by using the Linux mformat command (or by another means). Put the floppy in your drive but don't mount it, and install the syslinux bootstrap with this command:
syslinux /dev/fd0
That will copy a first-stage bootstrap onto the first block of the floppy and a second-stage bootstrap into the file LDLINUX.SYS in the MS-DOS file system of the floppy. I'm assuming you have a directory called /mnt; substitute whatever directory you usually use for mounting floppy disks in the shell commands below. Now, it's time to copy our kernel and root file system onto the floppy:
mount -t msdos /dev/fd0 /mnt cp fs.gz /mnt cp /usr/src/linux/arch/i386/boot/bzImage /mnt/linuxCreate the configuration file /mnt/syslinux.cfg with an editor:
TIMEOUT 20
DEFAULT linux
LABEL linux
KERNEL linux
APPEND root=/dev/ram0 initrd=fs.gz
This tells syslinux to wait for two seconds and then boot the
default system. You can interrupt the default boot during those two
seconds by pressing the shift key. Typing linux at the prompt will
do the same thing as the default.
The kernel is booted with the arguments root=/dev/ram0 and initrd=fs.gz. These arguments tell the kernel that the root is a RAM disk, and that the RAM disk is loaded from the compressed ROM file system image fs.gz. Although the ``ROM'' root file system is actually in RAM, it will not be writable because the Linux ROM file system driver used in this example is meant to work with real ROMs and thus doesn't support writing.
Configure an i386 PC to boot from the floppy. Note that this is a setting in the BIOS preferences of most new PCs, and they are often configured to boot from the hard disk without first looking for a bootstrap on the floppy. Place the floppy in the first floppy drive, and restart the system. You should see something like the following:
SYSLINUX 1.48 1999-09-26 Copyright (C) 1994-1999 H. Peter Anvin loading fs.gz......... loading linux............... Uncompressing linux, OK, booting the kernel
Tons of cybercrud about every device driver and facility in the kernel race by too rapidly to read...
RAMDISK: Compressed image found at block 0. VFS: Mounted root (romfs file system) Please press Enter to activate this console.You've done it! Press Enter and you should see something like this:
Busybox v0.46 (2000-09-12-22:16+0000) built-in shell Enter 'help' for a list of built-in commands. / # _Pop out the floppy disk; it's not being used any longer. The root file system is entirely in RAM. You should be able to look around the system and try out commands, but you won't have any writable storage. This is the simplest, bootable-system, running busybox that I could think of, and thus I've left out the files in /dev that you'd need to mount writable RAM disks, floppies and hard disks. You now should be able to figure out what those devices are, add them and build a tiny Linux system specialized to your application.
email: bruce@perens.com
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
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.
Sponsored by ActiveState
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
| Introduction to MapReduce with Hadoop on Linux | Jun 05, 2013 |
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Linux Systems Administrator
- Introduction to MapReduce with Hadoop on Linux
- RSS Feeds
- Tech Tip: Really Simple HTTP Server with Python
- Weechat, Irssi's Little Brother
- Help with Designing or Debugging CORBA Applications
- Senior Perl Developer
- Reply to comment | Linux Journal
20 min 54 sec ago - Welcome to 1998
1 hour 9 min ago - notifier shortcomings
1 hour 33 min ago - heroku?
3 hours 9 min ago - Android User
3 hours 11 min ago - Reply to comment | Linux Journal
5 hours 4 min ago - compiling
7 hours 54 min ago - This is a good post. This
13 hours 7 min ago - Great, This is really amazing
13 hours 9 min ago - These posts are really good
13 hours 10 min ago
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?



Comments
How Keyboard is working when no support provided in Linux
How Keyboard is working when no support provided in Linux ?
When i booted Linux from floppy and used the ramdisk as the rootfs, everything is working fine.
But i was wondering how the keyboard is working ? No loadable drivers provided.
Also no support in Linux provided>
I am not getting the # prompt instead i am getting the $ prompet
Hai Bruce Perens,
I have followed each and every step you told in this article but i am not getting the # prompt after booting it from the floppy. Instead i am getting the $ prompt.
How to get the # prompt can you tell me the error i am donig
Thanking you,
K.RajaSekahr
Re: Building Tiny Linux Systems with Busybox, Part 2: Building t
Luckily he provided the list of names in almost the right format for python.
An easier way to create those links to busybox:
import os
names=["ls","ar","basename","cat","chgrp","chmod","chown","chroot","chvt","clear","cp","cut","date","dc","dd","deallocvtdf","dirname","dmesg","du","dumpkmap","dutmp","echo","false","fbset","fdflush","find","free","freeramdisk","fsck.minix","grep","gunzip","gzip","halt","head","hostid","hostname","id","init","insmod","kill","killall","length","linuxrc","ln","loadacm","loadfont","loadkmap","logger","logname","lsmod","makedevs","md5sum","mkdir","mkfifo","mkfs.minix","mknod","mkswap","mktemp","more","mount","mt","mv","nc","nslookup","ping","poweroff","printf","ps","pwd","reboot","rm","rmdir","rmmod","sed","setkeycodes", "sh", "sleep", "sort","swapoff","swapon","syn", "csyslogd", "tail", "tar", "tee", "telnet", "test", "touch", "tri", "true", "tty", "umount", "uname", "uniq", "update", "uptime", "usleep", "uudecode", "uuencode", "wc", "which", "whoami", "yes", "zcat"]
for name in names:
os.system("ln busybox "+name)
Re: Building Tiny Linux Systems with Busybox, Part 2: Building t
I did this do create the links with a debian 'busybox-static'
#!/bin/sh
#
# Thorsten Strusch 2005-01-06
#
#########################################################################
#
BUSYBOX=$(which busybox)
#
Liste=$( $BUSYBOX 2>&1 | grep -A20 Currently | grep -v Curren | sed -e '{s/\t//}' -e '{s/\n//}' -e '{s/ //}' | grep -v ^$)
export IFS=','
for i in $Liste
do ln -s $BUSYBOX $i
done
unset IFS
Re: Building Tiny Linux Systems with Busybox, Part 2: Building t
Or even easier:
from the busybox build dir
$ make PREFIX=../tiny-linux install-hardlinks
Re: Building Tiny Linux Systems with Busybox, Part 2: Building t
Hi...
all went ok, kernel uncompressed, but then..kernel panic :(
kernel panic: unable to mount root fs on 01:00, what that is.. i gave my full memory, but .. nothing.. why? can u send me reply?
P.S.: best article(s).. thanx...
Re: Building Tiny Linux Systems with Busybox, Part 2: Building t
Im trying to make a mini floppy disk linux distro thing (if thats the right name) , i used a differant tutorial looks almost the same as this BUT .... i got the same boot error! that and something about VFS and "cramfs: wrong magic" so yeah. somethings up there, maybe i enabled some wrong options in the kernel and they are breaking each other.
Re: Building Tiny Linux Systems with Busybox, Part 2: Building t
did you enable ROM filesystem support in the kernel? if not you can try mkcramfs instead
ROM filesystem
I had a similar problem with romfs. In my case, I had to gzip the file system without "-9".