You want to boot off the cdrom and use it for most of the core files for
your operating system and use your hard drive for other stuff.

You want to make it real easy to do upgrades. Use a rewritable cdrom and
just swap out the old cdrom with a new one.

The long term direction is to use a cdrom to create computers without hard
drives. You use the cdrom for most of the core filesystem, a ramdisk for
/tmp, and NFS for everything else. I really really dislike professional
network computers that are diskless and hope that creating your own
diskless workstations will be the way of the future.

STRING NOTE: The perl scripts and methods I use to make bootable cdroms
is NOT NOT NOT very clean yet. I am still working to perfect the process.
I want to have it all run in Python or Perl (preferrably Python). Once
making bootable cdroms is well documented, I am going to merge this with
my MILAS project.

Creating an EXT2 cdrom and a bootable floppy disk

For this exersize, we will do something a little strange. We will make
an ext2 formatted cdrom and a floppy disk that is bootable. For people
want to use the easier iso9660 format, skip this section.

What advantages do you have by doing this in my strange way? Well, first,
realize something before I answer that question. Realize that a floppy,
cdrom, or a hard drive partition can be treated the same in most respects.
Okay, now I will answer the question:

You can use a spare partition on your hard drive to test the image you
want to put on your cdrom. If you boot off of a floppy disk, you can point
it to the hard drive partition, and if it works out great, then on the
next floppy disk you make bootable, have it point to your cdrom. Remember
to mount the hard-drive partition read-only to simulate a read-only cdrom.
Hard drive partitions are a good way to test images before you put them
on your cdrom (especially when it is a write-once cdrom).

Have a spare partition on your hard drive to use for your image for the
cdrom.

Format the partition as an ext2 format. Example: "mkfs -t ext2 /dev/hda3".
This formats the third partition on your primary hard drive. Make sure
you change the number "3" to the correct number used for your spare partition.

Copy over all critical directories and configure the files in ROOT/etc
to correctly reflect your new installation.

Use a ramdisk for "/tmp" and point "/var" to "/tmp/var".

Make a bootable floppy disk, and either configure it to use the cdrom drive
as "root" or "/" or if you get lilo installed on the floppy drive, you
can type in a command at boottime to use a different partition for "/".
You can do this with the command

lilo root=/dev/hdc
if your cdrom drive is "/dev/hdc". Notice I did not specify a partition
number. There is none.
There are also other ways to make bootable floppies. For my redhat
installation
### Make a copy of the kernel
cp /boot/vmlinuz-2.2.12-32 /tmp/Vmlinuz
### Make the copy boot from the cdrom on /dev/hdc
rdev /tmp/Vmlinuz /dev/hdc
ramsize /tmp/Vmlinuz 20000
### copy the kernel directly to the floppy disk, you might
have to format it first, mkfs -t ext2 /dev/fd0
dd if=/tmp/Vmlinuz of=/dev/fd0
For examples of how to copy over directories and files, look at the Perl
script at the end of the document.
For examples on how to use a ramdisk, read about this RamDisk article
I wrote a while ago, and also "man lilo.conf".

Second, either using the files from a partition you were using for testing purposes,
or if you want to start from scratch,

Make an image that is 600 megs but using "dd"
and a loopback device. Then copy this image to your cdrom. How do you make
an image?
Assume that "/mnt/Partition" is the directory you have all the files
that you want to make an image out of.

OR, if you don't mind using an ISO9660 formatted cdrom, which will work
the same with rock-ridge extensions, enter this command.
mkisofs -aJlL -r -o /tmp/Image /mnt/Partition
NOTE: Making an iso9660 cdrom in one step is a lot easier and is described
in the section below.

Now burn the image located at "/tmp/Image" to your cdrom.

Actually, I was thinking, you can probably just make a hard drive partition
600 megs and copy it over directlly without having to make an image. If
your hard drive partition is "/dev/hda4", then do this.

### Note, I never tested this yet.
### Unmount our partition that we copied files to
umount /dev/hda4
### Make an image of the partition
dd if=/dev/hda4 of=/tmp/Image.raw

Now just take Image.raw and burn it to your cdrom.

For better examples on how to do this, look at my Perl script below.
Anybody want to convert this into a Python Script? Perhaps a Python/TK
script?

The big deal about make ISO9660 formatted cdroms with Rock-Ridge extensions
is that fact that you can make cdroms bootable. This is very useful for
creating your own diskless workstations, creating boot-able installation
cdroms, creating a cdrom to fix hard drives, and probably other stuff.

With this section, you don't need a to use a loopback device, you don't
need to use any partitions, you just need a directory somewhere on your
computer and the program "mkisofs". This probably is the easiest way to
create an image that you want to use for a cdrom.

The key to making a bootable cdrom is the "mkisofs"
program. Here is a typical command that I use,
mkisofs -aJlL -r -o /tmp/Boot_Image /CDROM
"/CDROM" is the directory that you want to burn
onto a cdrom. To add the boot file,
mkisofs -aJlL -r -b /tmp/Boot.image -o /tmp/Boot_Image /CDROM
In the next section we discuss how to make a bootable
floppy disk that you can put on your cdrom.

The key item to remember is that you need a directory for this program.
This nice thing is, it doesn't grab the empty space on a partition when
it creates its image. You can use a spare

Configuring the boot-up process so that the computer is useable.

The toughest part about creating a live filesystem is copying over the
critical files and configuring them. You should have the same directory
structure as your Linux filesystem, except the stuff under /usr should
not be critical, but perhaps helpful. Remember to mount a ramdisk to /tmp,
remember that you should point /var to /tmp/var, and remember to configure
the files in /etc correctly. This could be a whole article itself. I try
to do it in the Perl script below. If you combine a live filesytem on a
cdrom with a hard drive or NFS, you will have more options as to what you
can do.

Here is an example of how to copy over files and configure the bootup
process.
Assume the directory you are making an image of is, "/tmp/Boot_Image".

Now you need to make a bootdisk with a larger ramdisk on it.
### This makes a bootdisk, put a floppy disk in
mkbootdisk `uname -r`
### This makes the directory to mount the floppy disk
mkdir /mnt/floppy_test
### Mount the floppy disk
mount /dev/fd0 /mnt/floppy_test
### Edit the lilo.conf file and put "ramdisk=35000" in the lilo.conf
file, mine looks like

### After you umount the floppy disk, make an image of
the floppy disk to burn on a cdrom
dd if=/dev/fd0 of=/tmp/Boot.image

Conclusions and future articles

I wanted to make it easier to create bootable cdroms with a live filesystem.
From here, I will make an article on how to use a bootable cdrom to

Create installation cdroms to burn your image of an operating system to
your hard drive.

How to use a bootable cdrom and a hard drive and/or NFS.

Finish up my MILAS project. My MILAS project started when I needed a way
to configure custom-made computers that I used to sell (and probably will
again someday to help force competitors to do cool things).

Make a more accurate Perl script to take the version of Linux you have
on your computer and put it on a cdrom. I will probably end up using
the iso9660 format for the cdrom.

I apologize for the roughness of this article. It was a pain in the butt
to figure out how to make bootable cdroms. I imagine other people have
documented it much better than I have. In my next article, I will clean
it up a lot.

Mark Nielsen works for
The
Computer Underground as a clerk and as a book binder at ZING.
In his spare time, he does volunteer stuff, like writing articles for The
Linux Gazette and developing ZING's website.