Home Index Search Links About LF
[LinuxFocus Image]
[Navegation Bar]
News    Archives    Map 
This document is available in: English  Castellano  Deutsch  Francais  Nederlands  Russian  Turkce  

[no author]
by Mooneer Salem



Creating a (Somewhat Useful) Version of Linux



Follow this article and learn how to create your own set of boot/root disks under Linux. Customize your root disks with your most-needed tools for the maintenance of your Linux system!

_________________ _________________ _________________



Have you seen those sites where they promise a useful version of Linux on a single floppy or two floppies? They usually don't have many programs or access to certain features either. I'll show you how to make a boot/root disk that'll have almost everything that you are going to need or use.

First off, you need one or two clean, blank floppies, depending on how much software you're going to put on your version of Linux. Basically your version of Linux will just be a boot/root disk and maybe a utility disk. If you don't know any of these terms, I suggest that you look at Chapter 2 of the Bootdisk-HOWTO before you start.

Now let's begin. Here are the basic steps to making your floppy-disk version of Linux:

  1. Compile a custom bare-bones kernel
  2. Create a filesystem for your disk
  3. Copy everything to your floppy(ies)

Compile the Kernel

Because the disk will only hold 1.44 megabytes (1440 kilobytes) of data, you cannot just copy your original kernel to your floppy. First you get the kernel sources and unpack them into /usr/src/linux. Then you issue the following command while inside /usr/src/linux:

make config

While in the program, only set up what you really need. On mine I only setup support for ex2, floppy disk support, and PPP support. Your settings may be different depending on what you set up. Next enter the following command:

make dep; make clean; make zImage

make zImage is very important! It compresses the finished kernel. After the command finishes you should find the kernel in /usr/src/linux/arch/i386/boot under the name zImage.  

The Filesystem: Not Just Any Old Set of Files

Now we have to create the filesystem for the disk. Instead of copying the stuff directly to the floppy, we are going to compress all of the programs. This will make it slightly harder to modify anything permanently. First, we issue the following command:

dd if=/dev/zero of=DEVICE bs=1k count=3000

Where DEVICE is the location on your hard drive where you are going to keep the uncompressed filesystem. Next, enter the following command and press Enter, replacing DEVICE with the location on your hard drive where you are keeping the uncompressed filesystem:

mke2fs -m 0 DEVICE

If make2fs asks you if you really want to do this, say yes.

Then we have to mount the newly created filesystem. Since the new filesystem is inside a regular file, the "loopback device" must be compiled in the kernel to mount it. If your kernel (not the created kernel, but your system kernel) do not have it, then recompile it. You have to say (Y)es (or (M)odule) to the question:

Loopback device support (CONFIG_BLK_DEV_LOOP) [M/n/y/?]
when configuring the kernel. Notice that you are recompiling YOUR normal kernel, not the floppy kernel, so you have to include all the drivers and utilities you already have. If you have compiled the loopback device as a module do not forget to install it (modprobe loop).
mount -t ext2 DEVICE /mnt
If the mount program complains, try the following:
mount -o loop -t ext2 DEVICE /mnt

Now you have to copy all of the files that you need to your newly created filesystem. First, cd to /mnt. Create the following directories:


Let's take care of the files in /dev by typing the following:

cp -dpR /dev /mnt/dev

If you run out of inodes, go to /mnt/dev and delete the device files that you don't need. Having completed copying the files necessary for /dev, let's move on to /etc. To be safe, copy all of the files from /etc to /mnt:

cp -dpR /etc /mnt/etc

Then copy everything in the /lib directory to /mnt:

cp -dpR /lib /mnt/lib

For /bin, copy only the things that you think you need to /mnt.  

Copying Everything to Your Floppy

Now we have to copy everything to your floppy(ies). To do this, we now must compress your filesystem by typing the following commands:

cd /
umount /mnt
dd if=DEVICE bs=1k | gzip -9 > rootfs.gz

Now it's important to check the size of the kernel. Go to /usr/src/linux/arch/i386/boot and issue the command ls -l. Then you have to divide 1024 into the size of the kernel. For example, if the size of my kernel is 250000 bytes, then it is 245 KB. Use the total number of kilobytes that you figured out earlier where any command says ROOTBEGIN. Now copy the kernel to the floppy using the following command:

dd if=zImage of=/dev/fd0

This command will put the kernel onto the floppy. Next enter the following command to tell the kernel to find the root filesystem on the floppy:

rdev /dev/fd0 /dev/fd0

Now you'll have to do a little calculating in hex. Add 4000 to the hex equivalent of ROOTBEGIN (which is F5 in this example). Convert the answer into decimal form and type the following command, replacing 16629 with your answer you got:

rdev -r /dev/fd0 16629

Finally, issue the following command to copy the filesystem to your floppy:

dd if=rootfs.gz of=/dev/fd0 bs=1k seek=ROOTBEGIN

The root filesystem will be copied to your floppy right after the kernel. Then you're done! For the second floppy, the process is easier. You just copy the files that you want onto the floppy. However, in order to be able to use the files that are on the second disk, you'll have to enter the following after booting with the disk:

mount /dev/fd0 /usr
One final note: if you do a little fiddling around, you can probably be able to make a version that you can release to the public as a seperate "distribution" of Linux. Just a thought :)
For more information:

Webpages maintained by the LinuxFocus Editor team
© Mooneer Salem, FDL
Translation information:
en --> -- : Mooneer Salem <mooneer(at)earthlink.net>

2002-11-02, generated by lfparser version 2.34