Making a Linux Boot Disk
It's easy. Three steps:
1. Insert an MS-DOS formatted floppy into your floppy drive. We'll be
a lot of stuff on it, so make sure it's empty. The box of floppys you
at the office store is fine.
2. Copy a kernel image onto the floppy. Copy a config file onto the
3. Run 'syslinux /dev/fd0' (quotes mine - you don't type them in). Copy
filesystem image to the floppy disk. You will need at least 4MB of RAM
your computer. Some older laptops don't have this much RAM.
There is a more complicated way. This involves copying the kernel image
the floppy, and determining an offset based on the kernel size. Copy a
system to the floppy, putting the file system image after the kernel
using the offset. Run the program 'rdev' to tell the kernel where the
system image is. More details are in the Bootdisk-HOWTO file mentioned below.
Now for the details.
First some files you will need. Here is a linux
kernel image you can use on your boot floppy.
Here is the config file mentioned above.
It is called SYSLINUX.CFG. Here is what I have in the file:
append initrd=FS.gz root=/dev/ram0
That's it. This command tells the kernel (when it boots up and starts
to use the file FS.gz as it's initrd (initial ram disk), which is a
name for a file system. The file system is a list of files to run and a
to put them. Below I'll show you what's needed.
Here is a batch file that I use to
a bootable floppy. It's called makedisk.
And here is a batch file I use to make a
system image. It's called batch.
The above two batch files have enough comments in them to help you
but not enough to teach shell programming under linux/unix. Sorry.
One more text file - this is the original
bootdisk howto seen in some distrubutions. It may be updated, but
is really all you need, and it explains it a lot better than I can.
Now for all the details.
The program syslinux creates an image on the boot floppy's bootsector.
image looks for three things:
1) A file called 'linux'. It must be called linux. You can call it
but the configuration line for syslinux has limitations. Calling it
makes it simpler. This file (linux) is a bootable kernel image. You can
one yourself. The one I supplied above should get you started. You want
to be fairly small (mine is about 500KB). If it's too big, you won't be
to get much more on the floppy. To get the current (and not-so-current)
sources go to http://www.kernel.org
2) A config file called 'SYSLINUX.CFG'. This text file tells syslinux
to do when starting the boot process. A lot of detail on the SYSLINUX home page.
3) A file system. This is a collection of files that are part of the
system. In the file system I include below, I have the directory
some library files, a program called busybox, some config files for the
system, and some other misc. files. I created a small, and fairly
file system that let's you learn enough of this to add on to it for
own purposes. You can get a copy of it here.
First, however, let's take a look at the details of two batch files
above. The first is called batch. This shell script creates a file
First create a 4MB file, and fill it with zeros. Zeros are easy to
You will see why I do this later. Here are the lines of code that do
(all copied from the batch file).
# create empty space for filesystem - 4.0MB
echo "Creating Space for File System"
dd if=/dev/zero of=FS bs=1k count=4096
The dd command takes /dev/zero as an input file. The output file is
FS. Block size is 1KB, and I want 4096 blocks of 1KB in size.
Now let's create an ext2 file system on this FS file.
# create ext2 file system w/1500 i-nodes
echo "Making new EXT2 File System"
mke2fs -m 0 -N 1500 FS -F -q
The mke2fs command creates the file system on the empty file. The -N
option makes 1500 inodes. More than enough for a small file system. The
option tells the mke2fs program to be quiet as it runs.
Next we want to mount this new file system so we can add stuff to it.
need to use the loopback device to do this, which means your current
must be compiled with the loopback device enabled. Also, /dev/loop0
to be created. More details are in the Bootdisk-HOWTO
file above. If you already have a working Linux distribution you are
you should already have these.
Let's mount the newly created file system:
# now mount it
echo "Mounting File System in /mnt2"
mount -o loop=/dev/loop0 FS /mnt2
The mount point I use is /mnt2. This is just an empty directory. You
don't have it - to make it do the following:
or you can change the line to use /mnt which you probably already
(A word on mount points - a mount point is an empty directory that will
a reference point for a mounted file system. Examples are /cdrom,
/USBCARD, etc. These provide an easy to remember reference to access
file system. All distrubitions have /mnt. I use /mnt for something
so I created /mnt2.)
If you now go to the /mnt2 directory, you will be looking at your empty
system. Let's add some files:
# Install packages
# get list of packages to install from ./package_list
while read files; do
echo "Adding package $files"
cp packages/$files /mnt2
cd /mnt2; tar xfz $files; rm
} < package_list
This takes the precompiled packages in the packages/ directory and
them to your new file system. They are in tar/gzip format. The line
xfz $files' untars and unzips them, and then deletes the original
The file 'package_list' is a text file of the available packages.
Now let's stuff the /etc directory with some config files
# create the etc/ archive from the local source/etc/ directory
if [ -e packages/etc.tgz ]; then
echo "Removing old etc/
echo "Creating etc/ archive"
cd source; tar cfz ~/distro/packages/etc.tgz etc/; cd ~/distro;
# and install it
cp packages/etc.tgz /mnt2
cd /mnt2; tar xfz etc.tgz; rm etc.tgz; cd ~/distro
I make a directory called 'etc' where the batch file resides. In this
I placed several files that the above lines of code take, tar/zip up,
to the new file system, then unzip, and untar. I then remove the
file from the file system.
Our new file system, as you can see, is just a collection of files. We
unmount the file system and zip it up.
# now unmount the new FS
echo "Unmounting File System"
# double syncing is a hold-over from the early days of linux
# and zip it up
echo "Ziping up new File System"
gzip -9 FS
# delete old FS.gz from floppy
echo "Removing old File System from floppy"
# and move in new one
echo "Installing new File System on floppy"
mcopy FS.gz a:
The mcopy and mdel command is part of the msdos tools (mtools) included
most distributions. The gzip -9 command zips up the file called FS (our
system) and the '-9' option makes the zip file as small as possible.
zipping up the file, the filename is changed to FS.gz. Having the empty
filled with zeros from /dev/zero (above) make compressing the file as
Notice that we just copied the zipped filesystem onto the floppy. We
syslinux the file system was called FS.gz in the SYSLINUX.CFG config
with the line: 'append initrd=FS.gz root=/dev/ram0'.
This means after the syslinux bootloader starts, and loads the kernal
called 'linux' that it will mount a filesystem called 'FS.gz' and use
for the operating system. The /dev/ram0 is the device for the ram0
If you want to see the packages I use for the file system, here they
Right click on the link, save them, and use 'tar tvfz package_name.tgz'
view them. You can also uncompress/unzip them and make changes. Use
xfz package_name.tgz' to install them to your hard drive.
Base.tgz (Base file system - just the
BusyBox1.01.tgz (Busybox program
most of the system binaries need to run the system)
checkit.tgz (error checking program
use - not really needed)
fsutils.tgz (some file system
utilities when building a new system)
to run busybox)
bwbasic.tgz (a basic interpreter)
minicom2.1.tgz (a serial
program - bloated)
Lastly, here is an image of the completed
Right click on the link, save it, and using the dd command in linux
the following with a blank floppy in your floppy drive:
dd if=BOOTDISK of=/dev/fd0
If you're using windows/dos, use the dos command 'rawwrite'. Click
here for a current (2007) Windows copy. Original source on freshmeat.net.
Reboot your machine with this floppy in and you will boot up (if your
is set correctly) on your new bootdisk.
Any questions? Contact me (Kurt Theis) from the e-mail link on
the Main Page