Caution: These instructions are not to be used without understanding them!

You must be the root user for many of these operations and that means you can really mess up your system if you are careless or hasty.

If possible, you should already have made a boot disk set based on rote instructions that came with your Linux distribution.

You cannot depend on instructions that are appropriate for my system also being appropriate for your system. (My system has a Matrox Millennium video card with 8 MB VRAM and an Adaptec 2940UW SCSI Adapter.)

The Bootdisk-HOWTO, CD-Writing HOWTO, man mkisofs, and man cdrecord as well as the Linux kernel source code in linux/init/main.c, linux/fs/super.c, linux/drivers/block/rd.c, and linux/drivers/block/genhd.c provided the background information needed to assemble the following instructions. You should read those HOWTOs and man pages, using the following as a specific implementation example.

Craig Van Degrift / KanjiFlash@CompuServe.com / revised February 27, 2000

An "El Torito" Bootable CD-ROM

These notes assume that you are familiar with making the two diskette rescue system; they skip through steps that are similar to those described there.

An "El Torito" style of bootable CD-ROM contains an implanted image of a bootable floppy diskette. This image is extracted by the system BIOS at boot time and used as if it were an ordinary boot diskette. The boot image includes an initial compressed ramdisk image that is loaded into RAM by the Lilo loader as the root filesystem. A script is then run that fills our this root filesystem with additional program files from the CD-ROM's filesystem. Even though the root ramdisk image uncompresses to a 32-MB ext2 filesystem, it compresses very tightly because it only needs to contain the files necessary to support this copying process.

First, I set up a working directory /boot/bootCD for the assembly of the boot image bootImage. That directory contains the following:

/boot/bootCD:
total 3014
-rwxr--r--   1 root     root         2048 Dec 19 17:28 boot.catalog
-rw-r--r--   1 root     root      1474560 Dec 18 00:40 bootImage
-rw-r--r--   1 root     root          498 Dec 17 23:30 bootImage_lilo.conf
-rwxr-xr-x   1 root     root          372 Dec 17 23:19 finishBootImage
-rwxr-xr-x   1 root     root          426 Dec 18 00:26 finishRootImage
drwxr-xr-x   4 root     root         1024 Dec 18 00:39 mnt_boot
drwxr-xr-x   2 root     root         1024 Dec  9 13:55 mnt_new
drwxr-xr-x   2 root     root         1024 Dec  9 13:55 mnt_old
-rw-r--r--   1 root     root       790912 Dec 18 00:37 rootfs_new.gz
-rw-r--r--   1 root     root       792663 Dec 18 00:36 rootfs_old.gz
-rwxr-xr-x   1 root     root         1456 Dec 17 01:25 startBootImage
-rwxr-xr-x   1 root     root          433 Dec 17 23:24 startRootImage
This directory has a mount point mnt_boot and two helper scripts, startBootImage and finishBootImage, which form the boot diskette image, bootImage. It also has two mount points, mnt_new, and mnt_old, and two scripts, startRootImage and finishRootImage for working with the ramdisk root filesystem.

The scripts may be extracted from this WWW page, and the rootfs_new.gz and lilo.conf files that I used may be extracted from this 1440-KB bootImage file by mounting it as a loop filesystem (mount -t ext2 -o loop) and copying them. Be sure to understand the contents of these files and adapt them as needed to your own system. For example, these files use libc.so.5 and your system might use glibc, libc.so.6. Similarly, the scripts assume bzImage and other files are to be found in places that are likely to be different from your system.

bootImage, custom-tailored for my system, contains the following files:

.:
total 1395
drwxr-xr-x    2 root     root         1024 Feb 18 11:27 boot
drwxr-xr-x    2 root     root         1024 Feb 18 11:20 dev
-rw-r--r--    1 root     root          499 Feb 18 11:20 lilo.conf
-rw-r--r--    1 root     root       872565 Feb 18 11:26 rootfs_new.gz
-rw-r--r--    1 root     root       542597 Feb 18 11:20 vmlinuz-2.2.14

./boot:
total 16
-rw-r--r--    1 root     root         4540 Feb 18 11:20 boot.b
-rw-r--r--    1 root     root          612 Feb 18 11:20 chain.b
-rw-------    1 root     root         9728 Feb 18 11:27 map

./dev:
total 0
brw-rw-rw-    1 root     disk       2,   0 Feb 18 11:20 fd0
brw-r--r--    1 root     root       2,   2 Feb 18 11:20 fd1
cr-xr-xr-x    1 root     root       1,   3 Feb 18 11:20 null
br--r-----    1 root     disk      11,   0 Feb 18 11:20 scd0
br--r-----    1 root     disk      11,   1 Feb 18 11:20 scd1
brw-rw----    1 root     disk       8,   0 Feb 18 11:20 sda
brw-rw----    1 root     disk       8,   1 Feb 18 11:20 sda1
brw-rw----    1 root     disk       8,   2 Feb 18 11:20 sda2
brw-rw----    1 root     disk       8,   3 Feb 18 11:20 sda3
brw-rw----    1 root     disk       8,   4 Feb 18 11:20 sda4
brw-rw----    1 root     disk       8,   5 Feb 18 11:20 sda5
brw-rw----    1 root     disk       8,   6 Feb 18 11:20 sda6
brw-rw----    1 root     disk       8,  16 Feb 18 11:20 sdb
brw-rw----    1 root     disk       8,  17 Feb 18 11:20 sdb1
brw-rw----    1 root     disk       8,  18 Feb 18 11:20 sdb2
brw-rw----    1 root     disk       8,  19 Feb 18 11:20 sdb3
brw-rw----    1 root     disk       8,  20 Feb 18 11:20 sdb4
brw-rw----    1 root     disk       8,  21 Feb 18 11:20 sdb5
brw-rw----    1 root     disk       8,  22 Feb 18 11:20 sdb6
This is very similar to the "boot" diskette of the Two-diskette set described earlier. The lilo.conf here is:
boot = /dev/fd0
install = /boot/bootCD/mnt_boot/boot/boot.b
map = /boot/bootCD/mnt_boot/boot/map
backup = /dev/null
compact
prompt
default = Linux_on_CD

image = /boot/bootCD/mnt_boot/vmlinuz-2.2.14
	label = Linux_on_CD
	initrd = /boot/bootCD/mnt_boot/rootfs_new.gz
	root = /dev/ram0
	vga = 0x012c
	append = "ramdisk_size=32768 init=/preinit"

image = /boot/vmlinuz-2.2.14
	label = Linux_on_sdb5
	root = /dev/sdb5

other = /dev/sda
	label = Boot_Manager
	loader = /boot/bootCD/mnt_boot/boot/chain.b
The main difference is the inclusion of an initrd=... line to tell the Lilo map installer program /sbin/lilo that there is a compressed root filesystem image rootfs_new.gz that will need to be loaded into a special ramdisk area (/dev/initrd which is known to the operating system). The Lilo loader places this image in ram and informs the kernel of its existence. The kernel then moves it to /dev/ram0 and mounts it as the root filesystem.

If we were making a Linux install CD, the code in rootfs_new.gz would probe the system hardware and construct a module-oriented kernel and supporting files on a hard disk specified by the root=... parameter. But, our intention here is to make a fancy CD-ROM-based rescue and manipulation system that floats in RAM above the hard disks without disturbing them. We therefore specify root=/dev/ram0, telling the kernel that the initial ramdisk in /dev/ram0 is to be our final root filesystem, not just a temporary one.

The kernel boot parameters in append=... set the maximum size for ramdisks to the size chosen for our root ramdisk and also tells the kernel that the first program to run shall be /preinit, a shell script that fills out the root ramdisk with files from elsewhere on the CD-ROM. As it terminates, /preinit starts up the normal /sbin/init program.

The remaining items in this lilo.conf have been discussed earlier in connection with the two-diskette rescue system.

In order to have plenty of read-write room in the ramdisk root filesystem, I have compressed a 32 MB ext2 filesystem along with the necessary starter files to form rootfs_new.gz. Specifically it contains:

.:
total 24
-rw-r--r--    1 root     root          129 Nov 22 01:37 .bashrc
drwxr-xr-x    2 root     root         1024 Feb 17 23:27 backup
drwxr-xr-x    2 root     root         1024 Feb 17 23:27 biglinux
drwxr-xr-x    2 root     root         1024 Feb 18 01:02 bin
drwxr-xr-x    2 root     root         1024 Feb 17 23:27 cdrom
drwxr-xr-x    2 root     root         2048 Feb 18 00:55 dev
drwxr-xr-x    2 root     root         1024 Feb 17 23:27 dos
drwxr-xr-x   13 root     root         1024 Feb 18 03:26 etc
drwxr-xr-x    2 root     root         1024 Feb 17 23:27 extra
-rw-r--r--    1 root     root            0 Feb 17 23:12 fastboot
drwxr-xr-x    2 root     root         1024 Feb 17 23:27 floppy
drwxr-xr-x    2 root     root         1024 Feb 17 23:27 floppyB
drwxr-xr-x    3 root     root         1024 Feb 18 00:33 lib
drwxr-xr-x    2 root     root         1024 Feb 17 23:27 os2
-rwxr-xr-x    1 root     root         2884 Feb 18 11:24 preinit
drwxr-xr-x    2 root     root         1024 Sep  5 17:57 proc
drwxr-xr-x    2 root     root         1024 Dec  7 09:53 root
drwxr-xr-x    2 root     root         1024 Dec 17 12:40 sbin
drwxr-xr-x    2 root     root         1024 Feb 17 23:27 tinyos2
drwxr-xr-x    2 root     root         1024 Nov  8 21:25 tmp
drwxr-xr-x    2 root     root         1024 Feb 17 23:30 usr
drwxr-xr-x    7 root     root         1024 Feb 18 03:19 var

./backup:
total 0

./biglinux:
total 0

./bin:
total 687
-rwxr-xr-x    1 root     root       461720 Jan 12 01:28 bash
-rwxr-xr-x    1 root     root         9668 Aug  9  1999 cat
-rwxr-xr-x    1 root     root        32176 Feb  5 06:45 cp
-rwxr-xr-x    1 root     root        25712 Nov 23 10:28 date
-rwxr-xr-x    1 root     root         6300 Nov 23 10:28 env
-rwxr-xr-x    1 root     root        10296 Dec  4 05:41 hostname
-rwxr-xr-x    1 root     root         9552 Nov 23 10:28 id
-rwxr-xr-x    1 root     root        18832 Feb  5 06:45 ln
-rwxr-xr-x    1 root     root        13088 Feb  5 06:45 mkdir
-rwsr-xr-x    1 root     root        65360 Feb  5 10:14 mount
lrwxrwxrwx    1 root     root            4 Feb 18 11:26 reset -> tset
lrwxrwxrwx    1 root     root            4 Feb 18 11:26 sh -> bash
-rwxr-xr-x    1 root     root         5952 Nov 23 10:28 sleep
-rwxr-xr-x    1 root     root        29200 Jan 26 15:56 tset

./cdrom:
total 0

./dev:
total 0
lrwxrwxrwx    1 root     root            4 Feb 18 11:26 cdrom -> scd0
lrwxrwxrwx    1 root     root            4 Feb 18 11:26 console -> tty0
brw-rw-rw-    1 root     disk       2,   0 Sep  7 10:17 fd0
brw-rw-rw-    1 root     disk       2,   1 Sep  7 10:18 fd1
brw-rw----    1 root     disk       7,   0 Nov  9 00:05 loop0
brw-rw----    1 root     disk       7,   1 Nov  9 00:05 loop1
brw-rw----    1 root     disk       7,   2 Nov  9 00:05 loop2
brw-rw----    1 root     disk       7,   3 Nov  9 00:05 loop3
brw-rw----    1 root     disk       7,   4 Nov  9 00:05 loop4
brw-rw----    1 root     disk       7,   5 Nov  9 00:05 loop5
brw-rw----    1 root     disk       7,   6 Nov  9 00:05 loop6
brw-rw----    1 root     disk       7,   7 Nov  9 00:05 loop7
cr-xr-xr-x    1 root     root       1,   3 Nov  9 00:14 null
brwxrwx---    1 root     disk       1,   0 Nov  9 12:30 ram0
brwxrwx---    1 root     disk       1,   1 Sep  5 17:53 ram1
brwxrwx---    1 root     disk       1,   2 Nov  9 12:26 ram2
brwxrwx---    1 root     disk       1,   3 Nov  9 12:26 ram3
brwxrwx---    1 root     disk       1,   4 Nov  9 12:26 ram4
brwxrwx---    1 root     disk       1,   5 Nov  9 12:26 ram5
brwxrwx---    1 root     disk       1,   6 Nov  9 12:26 ram6
brwxrwx---    1 root     disk       1,   7 Nov  9 12:31 ram7
brw-rw-r--    1 root     disk      11,   0 Sep  3 19:12 scd0
brw-rw----    1 root     disk       8,   0 Sep  3 19:12 sda
brw-rw----    1 root     disk       8,   1 Sep  3 19:12 sda1
brw-rw----    1 root     disk       8,   2 Sep  3 19:12 sda2
brw-rw----    1 root     disk       8,   3 Sep  3 19:12 sda3
brw-rw----    1 root     disk       8,   4 Sep  3 19:12 sda4
brw-rw----    1 root     disk       8,   5 Sep  3 19:12 sda5
brw-rw----    1 root     disk       8,   6 Sep  3 19:12 sda6
brw-rw----    1 root     disk       8,   7 Sep  3 19:12 sda7
brw-rw----    1 root     disk       8,   8 Sep  3 19:12 sda8
brw-rw----    1 root     disk       8,  16 Sep  3 19:12 sdb
brw-rw----    1 root     disk       8,  17 Sep  3 19:12 sdb1
brw-rw----    1 root     disk       8,  18 Sep  3 19:12 sdb2
brw-rw----    1 root     disk       8,  19 Sep  3 19:12 sdb3
brw-rw----    1 root     disk       8,  20 Sep  3 19:12 sdb4
brw-rw----    1 root     disk       8,  21 Sep  3 19:12 sdb5
brw-rw----    1 root     disk       8,  22 Sep  3 19:12 sdb6
brw-rw----    1 root     disk       8,  23 Sep  3 19:12 sdb7
brw-rw----    1 root     disk       8,  24 Sep  3 19:12 sdb8
crw-------    1 root     root      21,   0 Nov  7 19:45 sg0
crw-------    1 root     root      21,   1 Nov  7 19:45 sg1
crw-------    1 root     root      21,  10 Nov  7 19:45 sg10
crw-------    1 root     root      21,  11 Nov  7 19:45 sg11
crw-------    1 root     root      21,  12 Nov  7 19:45 sg12
crw-------    1 root     root      21,  13 Nov  7 19:45 sg13
crw-------    1 root     root      21,  14 Nov  7 19:45 sg14
crw-------    1 root     root      21,  15 Nov  7 19:45 sg15
crw-------    1 root     root      21,  16 Nov  7 19:45 sg16
crw-------    1 root     root      21,   2 Nov  7 19:45 sg2
crw-------    1 root     root      21,   3 Nov  7 19:45 sg3
crw-------    1 root     root      21,   4 Nov  7 19:45 sg4
crw-------    1 root     root      21,   5 Nov  7 19:45 sg5
crw-------    1 root     root      21,   6 Nov  7 19:45 sg6
crw-------    1 root     root      21,   7 Nov  7 19:45 sg7
crw-------    1 root     root      21,   8 Nov  7 19:45 sg8
crw-------    1 root     root      21,   9 Nov  7 19:45 sg9
crw-rw----    1 root     tty        4,   0 Sep  2 17:02 tty0
crw-rw----    1 root     tty        4,   1 Nov 12 18:09 tty1
crw-rw----    1 root     tty        4,   2 Nov 12 18:09 tty2
crw-rw----    1 root     tty        4,   3 Nov 12 18:09 tty3
crw-rw----    1 root     tty        4,   4 Nov 12 18:09 tty4
crw-rw----    1 root     tty        4,   5 Nov 12 18:09 tty5
crw-rw----    1 root     tty        4,   6 Nov 12 18:09 tty6
crw-rw----    1 root     tty        4,   7 Nov 12 18:09 tty7
crw-r--r--    1 root     root       1,   9 Nov 12 18:17 urandom
crw-------    1 root     sys        7,   0 Sep  8 18:53 vcs0
crw-------    1 root     sys        7,   1 Sep  8 18:53 vcs1
crw-------    1 root     sys        7,   2 Sep  8 18:53 vcs2
crw-------    1 root     sys        7,   3 Sep  8 18:53 vcs3
crw-------    1 root     sys        7,   4 Sep  8 18:53 vcs4
crw-------    1 root     sys        7,   5 Sep  8 18:53 vcs5
crw-------    1 root     sys        7,   6 Sep  8 18:53 vcs6
crw-------    1 root     sys        7, 128 Sep  8 18:53 vcsa
crw-------    1 root     sys        7, 129 Sep  8 18:53 vcsa1
crw-------    1 root     sys        7, 130 Sep  8 18:53 vcsa2
crw-------    1 root     sys        7, 131 Sep  8 18:53 vcsa3
crw-------    1 root     sys        7, 132 Sep  8 18:53 vcsa4
crw-------    1 root     sys        7, 133 Sep  8 18:53 vcsa5
crw-------    1 root     sys        7, 134 Sep  8 18:53 vcsa6
crw-rw-rw-    1 root     root       1,   5 Nov  9 00:05 zero

./dos:
total 0

./etc:
total 25
-rw-r--r--    1 root     root           82 Feb 11 13:58 bash.bashrc
drwxr-xr-x    2 root     root         1024 Feb  9 14:24 default
-rw-r--r--    1 root     root          967 Feb 18 02:31 fstab
-rw-r--r--    1 root     root          488 Feb 11 04:30 group
-rw-r--r--    1 root     root           74 Nov  8 23:49 hexdump.fmt
-rw-r--r--    1 root     root            6 Feb  6 02:30 hostname
drwxr-xr-x    2 root     root         1024 Feb 18 03:28 init.d
-rw-r--r--    1 root     root          634 Feb 14 19:04 inittab
-rw-r--r--    1 root     root           37 Feb 11 04:30 issue
-rw-r--r--    1 root     root            1 Feb 11 04:40 ld.so.cache
-rw-r--r--    1 root     root            1 Feb 11 04:44 ld.so.conf
-rw-r--r--    1 root     root           39 Feb 10 15:17 mtab
-rw-r--r--    1 root     root         1400 Feb 14 11:34 passwd
-rw-r--r--    1 root     root          378 Feb 18 03:26 profile
drwxr-xr-x    2 root     root         1024 Feb 14 17:54 rc0.d
drwxr-xr-x    2 root     root         1024 Feb 14 17:55 rc1.d
drwxr-xr-x    2 root     root         1024 Feb 11 04:09 rc2.d
drwxr-xr-x    2 root     root         1024 Feb 14 17:56 rc3.d
drwxr-xr-x    2 root     root         1024 Feb 14 17:57 rc4.d
drwxr-xr-x    2 root     root         1024 Feb 14 17:57 rc5.d
drwxr-xr-x    2 root     root         1024 Feb 14 17:59 rc6.d
drwxr-xr-x    2 root     root         1024 Feb 14 19:02 rcS.d
drwxr-xr-x    3 root     root         1024 Feb 15 03:49 terminfo
-rw-r--r--    1 root     root           11 Feb 11 06:01 timezone

./etc/default:
total 2
-rw-r--r--    1 root     root           92 Nov  5 09:04 devpts
-rwxr--r--    1 root     root          589 Feb  9 14:24 rcS

./etc/init.d:
total 28
-rwxr-xr-x    1 root     root         1934 Feb 14 18:17 bootmisc.sh
-rwxr-xr-x    1 root     root          731 Feb 11 04:05 checkfs.sh
-rwxr-xr-x    1 root     root         2943 Feb 11 04:05 checkroot.sh
-rwxr-xr-x    1 root     root         1087 Feb 11 04:05 devpts.sh
-rwxr-xr-x    1 root     root          281 Feb 11 04:05 halt
-rwxr-xr-x    1 root     root          132 Feb 11 04:05 hostname.sh
-rwxr-xr-x    1 root     root          395 Feb 11 04:05 isapnp
-rwxr-xr-x    1 root     root          583 Feb 18 03:28 mountall.sh
-rwxr-xr-x    1 root     root         1013 Feb 11 04:05 procps.sh
-rwxr-xr-x    1 root     root         2213 Feb 11 04:05 rc
-rwxr-xr-x    1 root     root         1190 Feb 11 04:05 rcS
-rwxr-xr-x    1 root     root          197 Feb 11 04:05 reboot
-rwxr-xr-x    1 root     root          252 Feb 11 04:05 rmnologin
-rwxr-xr-x    1 root     root          349 Feb 11 04:05 sendsigs
-rwxr-xr-x    1 root     root          476 Feb 11 04:05 single
-rwxr-xr-x    1 root     root         1471 Feb 11 04:05 sysklogd
-rwxr-xr-x    1 root     root          488 Feb 11 04:05 umountfs
-rwxr-xr-x    1 root     root           96 Nov 12 17:09 update
-rwxr-xr-x    1 root     root         1128 Feb 11 04:05 urandom

./etc/rc0.d:
total 0
lrwxrwxrwx    1 root     root           18 Feb 18 11:26 K90sysklogd -> ../init.d/sysklogd
lrwxrwxrwx    1 root     root           18 Feb 18 11:26 S20sendsigs -> ../init.d/sendsigs
lrwxrwxrwx    1 root     root           17 Feb 18 11:26 S30urandom -> ../init.d/urandom
lrwxrwxrwx    1 root     root           18 Feb 18 11:26 S40umountfs -> ../init.d/umountfs
lrwxrwxrwx    1 root     root           14 Feb 18 11:26 S90halt -> ../init.d/halt

./etc/rc1.d:
total 0
lrwxrwxrwx    1 root     root           18 Feb 18 11:26 K90sysklogd -> ../init.d/sysklogd
lrwxrwxrwx    1 root     root           16 Feb 18 11:26 S20single -> ../init.d/single

./etc/rc2.d:
total 0
lrwxrwxrwx    1 root     root           19 Feb 18 11:26 S99rmnologin -> ../init.d/rmnologin

./etc/rc3.d:
total 0
lrwxrwxrwx    1 root     root           18 Feb 18 11:26 S10sysklogd -> ../init.d/sysklogd
lrwxrwxrwx    1 root     root           19 Feb 18 11:26 S99rmnologin -> ../init.d/rmnologin

./etc/rc4.d:
total 0
lrwxrwxrwx    1 root     root           18 Feb 18 11:26 S10sysklogd -> ../init.d/sysklogd
lrwxrwxrwx    1 root     root           19 Feb 18 11:26 S99rmnologin -> ../init.d/rmnologin

./etc/rc5.d:
total 0
lrwxrwxrwx    1 root     root           18 Feb 18 11:26 S10sysklogd -> ../init.d/sysklogd
lrwxrwxrwx    1 root     root           19 Feb 18 11:26 S99rmnologin -> ../init.d/rmnologin

./etc/rc6.d:
total 0
lrwxrwxrwx    1 root     root           18 Feb 18 11:26 K90sysklogd -> ../init.d/sysklogd
lrwxrwxrwx    1 root     root           18 Feb 18 11:26 S20sendsigs -> ../init.d/sendsigs
lrwxrwxrwx    1 root     root           17 Feb 18 11:26 S30urandom -> ../init.d/urandom
lrwxrwxrwx    1 root     root           18 Feb 18 11:26 S40umountfs -> ../init.d/umountfs
lrwxrwxrwx    1 root     root           16 Feb 18 11:26 S90reboot -> ../init.d/reboot

./etc/rcS.d:
total 0
lrwxrwxrwx    1 root     root           22 Feb 18 11:26 S10checkroot.sh -> ../init.d/checkroot.sh
lrwxrwxrwx    1 root     root           16 Feb 18 11:26 S15isapnp -> ../init.d/isapnp
lrwxrwxrwx    1 root     root           20 Feb 18 11:26 S30checkfs.sh -> ../init.d/checkfs.sh
lrwxrwxrwx    1 root     root           19 Feb 18 11:26 S30procps.sh -> ../init.d/procps.sh
lrwxrwxrwx    1 root     root           19 Feb 18 11:26 S35devpts.sh -> ../init.d/devpts.sh
lrwxrwxrwx    1 root     root           21 Feb 18 11:26 S35mountall.sh -> ../init.d/mountall.sh
lrwxrwxrwx    1 root     root           21 Feb 18 11:26 S40hostname.sh -> ../init.d/hostname.sh
lrwxrwxrwx    1 root     root           21 Feb 18 11:26 S55bootmisc.sh -> ../init.d/bootmisc.sh
lrwxrwxrwx    1 root     root           17 Feb 18 11:26 S55urandom -> ../init.d/urandom

./etc/terminfo:
total 1
drwxr-xr-x    2 root     root         1024 Feb 15 03:49 l

./etc/terminfo/l:
total 2
-rw-r--r--    1 root     root         1563 Feb 15 03:49 linux

./extra:
total 0

./floppy:
total 0

./floppyB:
total 0

./lib:
total 1195
-rwxr-xr-x    1 root     root        83939 Feb  7 18:13 ld-2.1.3.so
lrwxrwxrwx    1 root     root           11 Feb 18 11:26 ld-linux.so.2 -> ld-2.1.3.so
-rwxr-xr-x    1 root     root       886932 Feb  7 18:13 libc-2.1.3.so
lrwxrwxrwx    1 root     root           13 Feb 18 11:26 libc.so.6 -> libc-2.1.3.so
-rw-r--r--    1 root     root         9372 Feb  7 18:13 libdl-2.1.3.so
lrwxrwxrwx    1 root     root           14 Feb 18 11:26 libdl.so.2 -> libdl-2.1.3.so
lrwxrwxrwx    1 root     root           17 Feb 18 11:26 libncurses.so.5 -> libncurses.so.5.0
-rw-r--r--    1 root     root       232780 Jan 26 15:56 libncurses.so.5.0
drwxr-xr-x    3 root     root         1024 Nov  8 18:04 terminfo

./lib/terminfo:
total 1
drwxr-xr-x    2 root     root         1024 Nov  8 18:04 l

./lib/terminfo/l:
total 2
-rw-r--r--    1 root     root         1549 Nov  8 18:04 linux

./os2:
total 0

./proc:
total 0

./root:
total 2
-rw-r--r--    1 root     root          810 Feb 18 02:34 .bashrc
-rw-r--r--    1 root     root          141 Dec  7 08:29 .profile

./sbin:
total 0

./tinyos2:
total 0

./tmp:
total 0

./usr:
total 0

./var:
total 5
drwxr-xr-x    3 root     root         1024 Feb 17 23:26 lib
drwxr-xr-x    2 root     root         1024 Feb 18 02:41 lock
drwxr-xr-x    2 root     root         1024 Feb 18 03:19 log
drwxr-xr-x    2 root     root         1024 Nov 12 17:50 run
drwxr-xr-x    3 root     root         1024 Dec  7 08:49 state

./var/lib:
total 1
drwxr-xr-x    2 root     root         1024 Feb 17 23:26 locate

./var/lib/locate:
total 0

./var/lock:
total 0

./var/log:
total 0

./var/run:
total 1
-rw-------    1 root     root          512 Nov 12 15:59 random-seed
-rw-r--r--    1 root     root            0 Nov 12 01:59 utmp

./var/state:
total 1
drwxr-xr-x    2 root     root         1024 Dec  7 08:50 misc

./var/state/misc:
total 0
-rw-r--r--    1 root     root            0 Dec  7 08:50 locatedb
These basic directories and files form the nucleus of our root filesystem. (Actually, some of these could also be loaded instead by /preinit, but they are included here because there was still room available after the bare essential files had been included.)

This is very similar to the root diskette of the two-diskette boot system except that quite a few files have been purged so that, when compressed, this can fit together with the kernel, map, etc., into the single 1440-KB boot image bootImage being stashed in the CD-ROM as its "El Torito" boot image.

As we noted above, the kernel has been instructed by the init=/preinit appended boot parameter to start up a shell (/bin/sh -> /bin/bash) and run /preinit which may be either a program or a shell script and must have execute permission. In our case, /preinit is a script and has the following contents:

#!/bin/sh
mount -t iso9660 -o ro /dev/scd0 /cdrom || mount -t ext2 -o ro /dev/sdb5 /cdrom

cp -a /cdrom/boot/bootCD/sbin/e2fsck /sbin
cp -a /cdrom/boot/bootCD/sbin/fdisk /sbin
cp -a /cdrom/boot/bootCD/sbin/halt /sbin
cp -a /cdrom/boot/bootCD/sbin/init /sbin
cp -a /cdrom/boot/bootCD/sbin/killall5 /sbin
cp -a /cdrom/boot/bootCD/sbin/ldconfig /sbin
cp -a /cdrom/boot/bootCD/sbin/mingetty /sbin
cp -a /cdrom/boot/bootCD/sbin/mke2fs /sbin
cp -a /cdrom/boot/bootCD/sbin/reboot /sbin
cp -a /cdrom/boot/bootCD/sbin/shutdown /sbin
cp -a /cdrom/boot/bootCD/sbin/sulogin /sbin
cp -a /cdrom/boot/bootCD/sbin/telinit /sbin
cp -a /cdrom/boot/bootCD/sbin/update /sbin

cp -a /cdrom/boot/bootCD/bin/chgrp /bin
cp -a /cdrom/boot/bootCD/bin/chmod /bin
cp -a /cdrom/boot/bootCD/bin/chown /bin
cp -a /cdrom/boot/bootCD/bin/dd /bin
cp -a /cdrom/boot/bootCD/bin/df /bin
cp -a /cdrom/boot/bootCD/bin/dmesg /bin
cp -a /cdrom/boot/bootCD/bin/grep /bin
cp -a /cdrom/boot/bootCD/bin/gunzip /bin
cp -a /cdrom/boot/bootCD/bin/gzip /bin
cp -a /cdrom/boot/bootCD/bin/ls /bin
cp -a /cdrom/boot/bootCD/bin/mknod /bin
cp -a /cdrom/boot/bootCD/bin/mv /bin
cp -a /cdrom/boot/bootCD/bin/ps /bin
cp -a /cdrom/boot/bootCD/bin/rm /bin
cp -a /cdrom/boot/bootCD/bin/rmdir /bin
cp -a /cdrom/boot/bootCD/bin/sed /bin
cp -a /cdrom/boot/bootCD/bin/stty /bin
cp -a /cdrom/boot/bootCD/bin/tar /bin
cp -a /cdrom/boot/bootCD/bin/umount /bin
cp -a /cdrom/boot/bootCD/bin/uname /bin

cp -a /cdrom/boot/bootCD/lib/libcom_err* /lib
cp -a /cdrom/boot/bootCD/lib/libcrypt* /lib
cp -a /cdrom/boot/bootCD/lib/libe2p* /lib
cp -a /cdrom/boot/bootCD/lib/libext2fs* /lib
cp -a /cdrom/boot/bootCD/lib/libnss_db* /lib
cp -a /cdrom/boot/bootCD/lib/libnss_files* /lib
cp -a /cdrom/boot/bootCD/lib/libproc* /lib
cp -a /cdrom/boot/bootCD/lib/libuuid* /lib

mke2fs /dev/ram1
mount -t ext2 /dev/ram1 /usr
mkdir /usr/bin /usr/sbin /usr/lib /usr/lib/locate

cp -a /cdrom/boot/bootCD/usr/sbin/chroot /usr/sbin

cp -a /cdrom/boot/bootCD/usr/bin/cdrecord /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/dircolors /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/du /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/find /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/free /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/hexdump /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/less /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/locate /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/mkisofs /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/setterm /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/sort /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/tput /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/updatedb /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/vi /usr/bin
cp -a /cdrom/boot/bootCD/usr/bin/vim /usr/bin

cp -a /cdrom/boot/bootCD/usr/lib/locate/bigram /usr/lib/locate
cp -a /cdrom/boot/bootCD/usr/lib/locate/code /usr/lib/locate
cp -a /cdrom/boot/bootCD/usr/lib/locate/frcode /usr/lib/locate

umount /cdrom

exec /sbin/init
These mount the CD-ROM and load the remaining programs from it. At the end, the CD-ROM is unmounted and control is transferred over to /sbin/init using an exec shell command so that /sbin/init will take over as Process 1.

Because my machine has lots of RAM, this script sets up a second ramdisk device, /dev/ram1 and mounts it to be /usr. Thus, my ram-based system has, in effect, 64 MB of ramdisk space to work with.

Finally, as mentioned earlier, all of this is coordinated by the four shell scripts, each set executable with "chmod +x ..." commands. The first, startBootImage, creates from scratch the 1440-KB boot diskette image:

#!/bin/sh
#
# startBootImage - a shell script to assemble all of the "El Torito" 
#                  boot image except for the initial ramdisk.
#
dd if=/dev/zero of=bootImage bs=1k count=1440
mke2fs -m 0 -F /boot/bootCD/bootImage
mount -t ext2 -o loop /boot/bootCD/bootImage mnt_boot
cd /boot/bootCD/mnt_boot
rm -rf lost+found
mkdir dev
cd dev
mknod null c 1   3; chmod 555 null ; chown root:root null

mknod fd0  b 2   0; chmod 666 fd0  ; chown root:disk fd0
mknod fd1  b 2   2; chmod 666 fd0  ; chown root:disk fd0

mknod sda  b 8   0; chmod 660 sda  ; chown root:disk sda
mknod sda1 b 8   1; chmod 660 sda1 ; chown root:disk sda1
mknod sda2 b 8   2; chmod 660 sda2 ; chown root:disk sda2
mknod sda3 b 8   3; chmod 660 sda3 ; chown root:disk sda3
mknod sda4 b 8   4; chmod 660 sda4 ; chown root:disk sda4
mknod sda5 b 8   5; chmod 660 sda5 ; chown root:disk sda5
mknod sda6 b 8   6; chmod 660 sda6 ; chown root:disk sda6

mknod sdb  b 8  16; chmod 660 sdb  ; chown root:disk sdb
mknod sdb1 b 8  17; chmod 660 sdb1 ; chown root:disk sdb1
mknod sdb2 b 8  18; chmod 660 sdb2 ; chown root:disk sdb2
mknod sdb3 b 8  19; chmod 660 sdb3 ; chown root:disk sdb3
mknod sdb4 b 8  20; chmod 660 sdb4 ; chown root:disk sdb4
mknod sdb5 b 8  21; chmod 660 sdb5 ; chown root:disk sdb5
mknod sdb6 b 8  22; chmod 660 sdb6 ; chown root:disk sdb6

mknod scd0 b 11  0; chmod 440 scd0 ; chown root:disk scd0
mknod scd1 b 11  1; chmod 440 scd1 ; chown root:disk scd1

cd ..
mkdir boot
cd boot
cp /boot/boot.b .
cp /boot/chain.b .
cd ..
cp /boot/vmlinuz-2.2.14 .
cp /boot/bootCD/bootImage_lilo.conf lilo.conf
ls -AlR
A second script, startRootImage, is analogous to the script start of the 2-diskette boot system but begins with a 32-MB, zeroed ext2 filesystem.
#!/bin/sh
#
# startRootImage - a shell script to prepare for editing of initial ramdisk
#
cd /boot/bootCD
mv /boot/bootCD/rootfs_new.gz /boot/bootCD/rootfs_old.gz
dd if=/dev/zero of=/boot/bootCD/rootfs_new bs=1k count=32768
mke2fs -m 0 -F /boot/bootCD/rootfs_new
gunzip /boot/bootCD/rootfs_old.gz
mount -o loop /boot/bootCD/rootfs_new /boot/bootCD/mnt_new
mount -o loop /boot/bootCD/rootfs_old /boot/bootCD/mnt_old
rmdir /boot/bootCD/mnt_new/lost+found
df
This prepares for editing the self-filling filesystem with the /preinit script. You edit rootfs_old (mounted on mnt_old) according to your needs, making sure that its compressed image together with the kernel, map, etc. can still fit into the boot diskette image. This limits it to about 900 KB when compressed. The version shown here is 790 KB.

Finally, you can start finishing up. First you wrap up rootfs_old with the script finishRootImage:

#!/bin/sh
#
# finishRootImage - a shell script to finish up after editing an initial ramdisk
#
cd /boot/bootCD/mnt_old
cp -a . /boot/bootCD/mnt_new
cd ..
df
umount /boot/bootCD/mnt_new /boot/bootCD/mnt_old
gzip -v9 /boot/bootCD/rootfs_new
gzip -v9 /boot/bootCD/rootfs_old
ls -Al
echo "***************************************************"
echo "******* Don't forget to run finishBootImage *******"
echo "*******     with a diskette in /dev/fd0     *******"
echo "***************************************************"
Next, bootImage is completed by placing a diskette in /dev/fd0 and running the script finishBootImage:
# Finish making bootImage
cp /boot/bootCD/rootfs_new.gz /boot/bootCD/mnt_boot
umount /boot/bootCD/bootImage
dd if=/boot/bootCD/bootImage of=/dev/fd0 bs=1k count=1440
mount -t ext2 /dev/fd0 /boot/bootCD/mnt_boot
/sbin/lilo -C /boot/bootCD/mnt_boot/lilo.conf
ls -R /boot/bootCD/mnt_boot
umount /boot/bootCD/mnt_boot
dd if=/dev/fd0 of=/boot/bootCD/bootImage bs=1k count=1440
It is strange that we apparently need to use an actual diskette at this point, but that seems to be required in order to give /sbin/lilo a chance to stash the boot sector in the first sector of the image. Lilo doesn't seem to know how to do this with a mounted loop filesystem. Anyway, it doesn't hurt to have such a diskette around if for some reason you find yourself using a CD and/or SCSI BIOS that doesn't support the "El Torito" system. The diskette itself can be booted and will copy the programs it needs from the CD-ROM. You end up with the same RAM-based Linux system either way.

We now finally have created the 1440-KB boot Image. In this particular case, I am making a bootable backup of my entire Linux system. I boot from a rescue disk (or CD) into a Linux system completely in RAM and package my quiescent hard disk Linux installation (/mnt/biglinux) into a CD-ROM filesystem by using the utility mkisofs. The complete command with arguments suitable for this on my system is:

mkisofs -D -R -v -d -L -b boot/bootCD/bootImage       \
                       -c boot/bootCD/boot.catalog    \
                       -o /mnt/extra/biglinux.isofs   \
                       /mnt/biglinux
Here, besides the boot image specification (-b boot/bootCD/bootImage), we are required to specify a place where a "catalog" is placed ( -c boot/bootCD/boot.catalog), a hard disk file path for the temporary several-hundred MB CD-ROM filesystem file (/mnt/extra/biglinux.isofs), and the path to the files being written (/mnt/biglinux). The files written to the CD-ROM must, of course, include the files to be loaded by /preinit as well as the boot image and catalog files.

This large CD-ROM image file, biglinux.isofs is finally placed onto the CD-ROM itself by cdrecord using an instruction something like:

cdrecord -v speed=2 dev=0,6,0 -data /mnt/extra/biglinux.isofs
On my system, the CD writer is on my only (0th) SCSI chain, has a unit id of 6 and a logical unit number of 0 -- hence the dev=0,6,0 specification.

It might be necessary to reset your motherboard BIOS to look for a boot from the SCSI system, and the SCSI BIOS to look for a bootable CD-ROM before checking the fixed disks.

If all is well, the next time you reboot with this CD-ROM in your drive, you will find yourself running a complete Linux system in RAM. You will be, in effect, safely floating above your hard disk partitions able to examine, tweek, and back them up while they are inactive.