Linux Essentials: Bootdisks and The Boot Process
Linux Essentials: Bootdisks and The Boot Process
Linux Essentials: Bootdisks and The Boot Process
All PC systems start the boot process by executing code in ROM (specifically, the BIOS) to load
the sector from sector 0, cylinder 0 of the boot drive. The boot drive is usually the first floppy
drive (designated A: in DOS and /dev/fd0 in Linux). The BIOS then tries to execute this sector.
On most bootable disks, sector 0, cylinder 0 contains either:
code from a boot loader such as LILO, which locates the kernel, loads it and executes it
to start the boot proper; or
the start of an operating system kernel, such as Linux.
If a Linux kernel has been raw-copied to a diskette, the first sector of the disk will be the first
sector of the Linux kernel itself. This first sector will continue the boot process by loading the
rest of the kernel from the boot device.
When the kernel is completely loaded, it initializes device drivers and its internal data structures.
Once it is completely initialized, it consults a special location in its image called the ramdisk
word. This word tells it how and where to find its root filesystem. A root filesystem is simply a
filesystem that will be mounted as ``/''. The kernel has to be told where to look for the root
filesystem; if it cannot find a loadable image there, it halts.
In some boot situations — often when booting from a diskette — the root filesystem is loaded
into a ramdisk, which is RAM accessed by the system as if it were a disk. RAM is several orders
of magnitude faster than a floppy disk, so system operation is fast from a ramdisk. Also, the
kernel can load a compressed filesystem from the floppy and uncompress it onto the ramdisk,
allowing many more files to be squeezed onto the diskette.
Once the root filesystem is loaded and mounted, you see a message like:
Once the system has loaded a root filesystem successfully, it tries to execute the init program
(in /bin or /sbin). init reads its configuration file /etc/inittab, looks for a line designated
sysinit, and executes the named script. The sysinit script is usually something like /etc/rc
or /etc/init.d/boot. This script is a set of shell commands that set up basic system services,
This script often invokes various other scripts to do modular initialization. For example, in the
common SysVinit structure, the directory /etc/rc.d/ contains a complex structure of
subdirectories whose files specify how to enable and shut down most system services. However,
on a bootdisk the sysinit script is often very simple.
When the sysinit script finishes control returns to init, which then enters the default runlevel,
specified in inittab with the initdefault keyword. The runlevel line usually specifies a
program like getty, which is responsible for handling commununications through the console
and ttys. It is the getty program which prints the familiar ``login:'' prompt. The getty program
in turn invokes the login program to handle login validation and to set up user sessions.
Disk types
Having reviewed the basic boot process, we can now define various kinds of disks involved. We
classify disks into four types. The discussion here and throughout this document uses the term
``disk'' to refer to floppy diskettes unless otherwise specified, though most of the discussion
could apply equally well to hard disks.
boot
A disk containing a kernel which can be booted. The disk can be used to boot the kernel,
which then may load a root file system on another disk. The kernel on a bootdisk usually
must be told where to find its root filesystem.
Often a bootdisk loads a root filesystem from another diskette, but it is possible for a
bootdisk to be set up to load a hard disk's root filesystem instead. This is commonly done
when testing a new kernel (in fact, ``make zdisk'' will create such a bootdisk
automatically from the kernel source code).
root
A disk with a filesystem containing files required to run a Linux system. Such a disk does
not necessarily contain either a kernel or a boot loader.
A root disk can be used to run the system independently of any other disks, once the
kernel has been booted. Usually the root disk is automatically copied to a ramdisk. This
makes root disk accesses much faster, and frees up the disk drive for a utility disk.
boot/root
utility
A disk which contains a filesystem, but is not intended to be mounted as a root file
system. It is an additional data disk. You would use this type of disk to carry additional
utilities where you have too much to fit on your root disk.
In general, when we talk about ``building a bootdisk'' we mean creating both the boot (kernel)
and root (files) portions. They may be either together (a single boot/root disk) or separate (boot +
root disks). The most flexible approach for rescue diskettes is probably to use separate boot and
root diskettes, and one or more utility diskettes to handle the overflow.
Overview
A root filesystem must contain everything needed to support a full Linux system. To be able to
do this, the disk must include the minimum requirements for a Linux system:
Of course, any system only becomes useful when you can run something on it, and a root
diskette usually only becomes useful when you can do something like:
Check a file system on another drive, for example to check your root file system on your
hard drive, you need to be able to boot Linux from another drive, as you can with a root
diskette system. Then you can run fsck on your original root drive while it is not
mounted.
In order to build such a root filesystem, you need a spare device that is large enough to hold all
the files before compression. You will need a device capable of holding about four megabytes.
There are several choices:
Use a ramdisk (DEVICE = /dev/ram0). In this case, memory is used to simulate a disk
drive. The ramdisk must be large enough to hold a filesystem of the appropriate size. If
you use LILO, check your configuration file (/etc/lilo.conf) for a line like RAMDISK
= nnn which determines the maximum RAM that can be allocated to a ramdisk. The
default is 4096K, which should be sufficient. You should probably not try to use such a
ramdisk on a machine with less than 8MB of RAM. Check to make sure you have a
device like /dev/ram0, /dev/ram or /dev/ramdisk. If not, create /dev/ram0 with
mknod (major number 1, minor 0).
If you have an unused hard disk partition that is large enough (several megabytes), this is
acceptable.
Use a loopback device, which allows a disk file to be treated as a device. Using a
loopback device you can create a three megabyte file on your hard disk and build the
filesystem on it.
Type man losetup for instructions on using loopback devices. If you don't have losetup,
you can get it along with compatible versions of mount and unmount from the util-
linux package in the directory ftp://ftp.win.tue.nl/pub/linux/utils/util-
linux/.
If you do not have a loop device (/dev/loop0, /dev/loop1, etc.) on your system, you
will have to create one with ``mknod /dev/loop0 b 7 0''. Once you've installed these
special mount and umount binaries, create a temporary file on a hard disk with enough
capacity (eg, /tmp/fsfile). You can use a command like:
After you've chosen one of these options, prepare the DEVICE with:
Zeroing the device is critical because the filesystem will be compressed later, so all unused
portions should be filled with zeroes to achieve maximum compression. Keep this in mind
whenever you move or delete files on the filesystem. The filesystem will correctly de-
allocate the blocks, but it will not zero them out again. If you do a lot of deletions and
copying, your compressed filesystem may end up much larger than necessary.
Next, create the filesystem. The Linux kernel recognizes two file system types for root disks to
be automatically copied to ramdisk. These are minix and ext2, of which ext2 is preferred. If
using ext2, you may find it useful to use the -N option to specify more inodes than the default; -N
2000 is suggested so that you don't run out of inodes. Alternatively, you can save on inodes by
removing lots of unnecessary /dev files. mke2fs will by default create 360 inodes on a 1.44Mb
diskette. I find that 120 inodes is ample on my current rescue root diskette, but if you include all
the devices in /dev you will easily exceed 360. Using a compressed root filesystem allows a
larger filesystem, and hence more inodes by default, but you may still need to either reduce the
number of files or increase the number of inodes.
(If you're using a loopback device, the disk file you're using should be supplied in place of this
DEVICE.)
The mke2fs command will automatically detect the space available and configure itself
accordingly. The ``-m 0'' parameter prevents it from reserving space for root, and hence provides
more usable space on the disk.
(You must create a mount point /mnt if it does not already exist.) In the remaining sections, all
destination directory names are assumed to be relative to /mnt.
Here is a reasonable minimum set of directories for your root filesystem [1]:
Three of these directories will be empty on the root filesystem, so they only need to be created
with mkdir. The /proc directory is basically a stub under which the proc filesystem is placed.
The directories /mnt and /usr are only mount points for use after the boot/root system is
running. Hence again, these directories only need to be created.
/dev
A /dev directory containing a special file for all devices to be used by the system is mandatory
for any Linux system. The directory itself is a normal directory, and can be created with mkdir in
the normal way. The device special files, however, must be created in a special way, using the
mknod command.
There is a shortcut, though — copy devices files from your existing hard disk /dev directory.
The only requirement is that you copy the device special files using -R option. This will copy the
directory without attempting to copy the contents of the files. Be sure to use an upper case R. For
example:
assuming that the diskette is mounted at /mnt. The dp switches ensure that symbolic links are
copied as links, rather than using the target file, and that the original file attributes are preserved,
thus preserving ownership information.
If you want to do it the hard way, use ls -l to display the major and minor device numbers for
the devices you want, and create them on the diskette using mknod.
Note that one inode is required for each device special file, and inodes can at times be a scarce
resource, especially on diskette filesystems. You'll need to be selective about the device files you
include. For example, if you do not have SCSI disks you can safely ignore /dev/sd*; if you
don't intend to use serial ports you can ignore /dev/ttyS*.
If, in building your root filesystem, you get the error No space left on device but a df
command shows space still available, you have probably run out of inodes. A df -i will display
inode usage.
Be sure to include the following files from this directory: console, kmem, mem, null, ram0
and tty1.
/etc
The /etc directory contains configuration files. What it should contain depends on what programs
you intend to run. On most systems, these can be divided into three groups:
Files which are not essential can usually be identified with the command:
ls -ltru
This lists files in reverse order of date last accessed, so if any files are not being accessed, they can be
omitted from a root diskette.
On my root diskettes, I have the number of config files down to 15. This reduces my work to
dealing with three sets of files:
Be sure that passwd contains at least root. If you intend other users to login, be sure their
home directories and shells exist.
termcap, the terminal database, is typically several hundred kilobytes. The version on
your boot/root diskette should be pruned down to contain only the terminal(s) you use,
which is usually just the linux or linux-console entry.
Out of this, I only really have to configure two files, and what they should contain is surprisingly
small.
rc should contain:
#!/bin/sh
/bin/mount -av
/bin/hostname Kangaroo
Be sure it is executable, be sure it has a "#!" line at the top, and be sure any absolute
filenames are correct. You don't really need to run hostname — it just looks nicer if you
do.
fstab should contain at least:
You can copy entries from your existing fstab, but you should not automatically mount
any of your hard disk partitions; use the noauto keyword with them. Your hard disk may
be damaged or dead when the bootdisk is used.
Your inittab should be changed so that its sysinit line runs rc or whatever basic boot script
will be used. Also, if you want to ensure that users on serial ports cannot login, comment out all
the entries for getty which include a ttys or ttyS device at the end of the line. Leave in the tty
ports so that you can login at the console.
id:2:initdefault:
si::sysinit:/etc/rc
1:2345:respawn:/sbin/getty 9600 tty1
2:23:respawn:/sbin/getty 9600 tty2
Note that some programs cannot be moved elsewhere because other programs have hardcoded
their locations. For example, on my system, /etc/shutdown has hardcoded in it /etc/reboot.
If I move reboot to /bin/reboot, and then issue a shutdown command, it will fail because it
cannot find the reboot file.
For the rest, just copy all the text files in your /etc directory, plus all the executables in your
/etc directory that you cannot be sure you do not need. As a guide, consult the sample listing in
Appendix C. Probably it will suffice to copy only those files, but systems differ a great deal, so
you cannot be sure that the same set of files on your system is equivalent to the files in the list.
The only sure method is to start with inittab and work out what is required.
Most systems now use an /etc/rc.d/ directory containing shell scripts for different run levels.
The minimum is a single rc script, but it may be simpler just to copy inittab and the
/etc/rc.d directory from your existing system, and prune the shell scripts in the rc.d directory
to remove processing not relevent to a diskette system environment.
The /bin directory is a convenient place for extra utilities you need to perform basic operations,
utilities such as ls, mv, cat and dd. See Appendix C for an example list of files that go in a /bin
and /sbin directories. It does not include any of the utilities required to restore from backup,
such as cpio, tar and gzip. That is because I place these on a separate utility diskette, to save
space on the boot/root diskette. Once the boot/root diskette is booted, it is copied to the ramdisk
leaving the diskette drive free to mount another diskette, the utility diskette. I usually mount this
as /usr.
Be sure to include the following programs: init, getty or equivalent, login, mount, some
shell capable of running your rc scripts, a link from sh to the shell.
/lib
In /lib you place necessary shared libraries and loaders. If the necessary libraries are not found
in your /lib directory then the system will be unable to boot. If you're lucky you may see an
error message telling you why.
% ls -l /lib/libc*
-rwxr-xr-x 1 root root 4016683 Apr 16 18:48 libc-2.1.1.so*
lrwxrwxrwx 1 root root 13 Apr 10 12:25 libc.so.6 -> libc-
2.1.1.so*
In this case, you want libc-2.1.1.so. To find other libraries you should go through all the
binaries you plan to include and check their dependencies with ldd. For example:
% ldd /sbin/mke2fs
libext2fs.so.2 => /lib/libext2fs.so.2 (0x40014000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x40026000)
libuuid.so.1 => /lib/libuuid.so.1 (0x40028000)
libc.so.6 => /lib/libc.so.6 (0x4002c000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
Each file on the right-hand side is required. The file may be a symbolic link.
Note that some libraries are quite large and will not fit easily on your root filesystem. For
example, the libc.so listed above is about 4 meg. You will probably need to strip libraries when
copying them to your root filesystem. See Section 8 for instructions.
In /lib you must also include a loader for the libraries. The loader will be either ld.so (for
A.OUT libraries, which are no longer common) or ld-linux.so (for ELF libraries). Newer
versions of ldd tell you exactly which loader is needed, as in the example above, but older
versions may not. If you're unsure which you need, run the file command on the library. For
example:
The QMAGIC indicates that 4.7.2 is for A.OUT libraries, and ELF indicates that 5.4.33 and
2.1.1 are for ELF.
Copy the specific loader(s) you need to the root filesystem you're building. Libraries and loaders
should be checked carefully against the included binaries. If the kernel cannot load a necessary
library, the kernel may hang with no error message.
Your system may require dynamically loaded libraries that are not visible to ldd. If you don't
provide for these, you may have trouble logging in or using your bootdisk.
If your system uses PAM (Pluggable Authentication Modules), you must make some provision
for it on your bootdisk. Briefly, PAM is a sophisticated modular method for authenticating users
and controlling their access to services. An easy way to determine if your system uses PAM is
run ldd on your login executable; if the output includes libpam.so, you need PAM.
Fortunately, security is usually of no concern with bootdisks since anyone who has physical
access to a machine can usually do anything they want anyway. Therefore, you can effectively
disable PAM by creating a simple /etc/pam.conf file in your root filesystem that looks like
this:
Also copy the file /lib/security/pam_permit.so to your root filesystem. This library is only
about 8K so it imposes minimal overhead.
This configuration allows anyone complete access to the files and services on your machine. If
you care about security on your bootdisk for some reason, you'll have to copy some or all of your
hard disk's PAM setup to your root filesystem. Be sure to read the PAM documentation
carefully, and copy any libraries needed in /lib/security onto your root filesystem.
You must also include /lib/libpam.so on your bootdisk. But you already know this since you
ran ldd on /bin/login, which showed this dependency.
If you are using glibc (aka libc6), you will have to make provisions for name services or you will
not be able to login. The file /etc/nsswitch.conf controls database lookups for various
servies. If you don't plan to access services from the network (eg, DNS or NIS lookups), you
need only prepare a simple nsswitch.conf file that looks like this:
passwd: files
shadow: files
group: files
hosts: files
services: files
networks: files
This specifies that every service be provided only by local files. You will also need to include
/lib/libnss_files.so.X, where X is 1 for glibc 2.0 and 2 for glibc 2.1. This library will be
loaded dynamically to handle the file lookups.
If you plan to access the network from your bootdisk, you may want to create a more elaborate
nsswitch.conf file. See the nsswitch man page for details. You must include a file
/lib/libnss_service.so.1 for each service you specify.
Modules
If you have a modular kernel, you must consider which modules you may want to load from your
bootdisk after booting. You might want to include ftape and zftape modules if your backup
tapes are on floppy tape, modules for SCSI devices if you have them, and possibly modules for
PPP or SLIP support if you want to access the net in an emergency.
These modules may be placed in /lib/modules. You should also include insmod, rmmod and
lsmod. Depending on whether you want to load modules automatically, you might also include
modprobe, depmod and swapout. If you use kerneld, include it along with
/etc/conf.modules.
However, the main advantage to using modules is that you can move non-critical modules to a
utility disk and load them when needed, thus using less space on your root disk. If you may have
to deal with many different devices, this approach is preferable to building one huge kernel with
many drivers built in.
In order to boot a compressed ext2 filesystem, you must have ramdisk and ext2 support
built-in. They cannot be supplied as modules.
Some system programs, such as login, complain if the file /var/run/utmp and the directory
/var/log do not exist. So:
mkdir -p /mnt/var/{log,run}
touch /mnt/var/run/utmp
ldconfig -r /mnt
4.7. Wrapping it up
When you have finished constructing the root filesystem, unmount it, copy it to a file and
compress it:
umount /mnt
dd if=DEVICE bs=1k | gzip -v9 > rootfs.gz
When this finishes you will have a file rootfs.gz. This is your compressed root filesystem. You
should check its size to make sure it will fit on a diskette; if it doesn't you'll have to go back and
remove some files. Some suggestions for reducing root filesystem size appear in Section 8.
Notes
[1] The directory structure presented here is for root diskette use only. Real Linux systems have
a more complex and disciplined set of policies, called the Filesystem Hierarchy Standard,
for determining where files should go.)
Choosing a kernel
At this point you have a complete compressed root filesystem. The next step is to build or select
a kernel. In most cases it would be possible to copy your current kernel and boot the diskette
from that. However, there may be cases where you wish to build a separate one.
One reason is size. If you are building a single boot/root diskette, the kernel will be one of the
largest files on the diskette so you will have to reduce the size of the kernel as much as possible.
To reduce kernel size, build it with the minumum set of facilities necessary to support the desired
system. This means leaving out everything you don't need. Networking is a good thing to leave
out, as well as support for any disk drives and other devices which you don't need when running
your boot/root system. As stated before, your kernel must have ramdisk and ext2 support built
into it.
Having worked out a minimum set of facilities to include in a kernel, you then need to work out
what to add back in. Probably the most common uses for a boot/root diskette system would be to
examine and restore a corrupted root file system, and to do this you may need kernel support. For
example, if your backups are all held on tape using Ftape to access your tape drive, then, if you
lose your current root drive and drives containing Ftape, then you will not be able to restore from
The point here is that, whatever I/O support you have added to your kernel to support backups
should also be added into your boot/root kernel.
The procedure for actually building the kernel is described in the documentation that comes with
the kernel. It is quite easy to follow, so start by looking in /usr/src/linux. If you have trouble
building a kernel, you should probably not attempt to build boot/root systems anyway.
Remember to compress the kernel with ``make zImage''.
You should decide whether to use LILO to boot the bootdisk kernel. The alternative is to copy
the kernel directly to the diskette and boot without LILO. The advantage of using LILO is that it
enables you to supply some parameters to the kernel which may be necessary to initialize your
hardware (Check the file /etc/lilo.conf on your system. If it exists and has a line like
``append=...'', you probably need this feature). The disadvantage of using LILO is that building
the bootdisk is more complicated and takes slightly more space. You will have to set up a small
separate filesystem, which we shall call the kernel filesystem, where you transfer the kernel and a
few other files that LILO needs.
If you are going to use LILO, read on; if you are going to transfer the kernel directly, skip ahead
to Section 6.2.
You must create a small configuration file for LILO. It should look like this:
boot =/dev/fd0
install =/boot/boot.b
map =/boot/map
read-write
backup =/dev/null
compact
image = KERNEL
label = Bootdisk
For an explanation of these parameters, see LILO's user documentation. You will probably also
want to add an append=... line to this file from your hard disk's /etc/lilo.conf file.
You now have to create a small filesystem, which we shall call a kernel filesystem, to distinguish
it from the root filesystem.
First, figure out how large the filesystem should be. Take the size of your kernel in blocks (the
size shown by ``ls -s KERNEL'') and add 50. Fifty blocks is approximately the space needed for
inodes plus other files. You can calculate this number exactly if you want to, or just use 50. If
you're creating a two-disk set, you may as well overestimate the space since the first disk is only
used for the kernel anyway. Call this number KERNEL_BLOCKS.
Put a floppy diskette in the drive (for simplicity we'll assume /dev/fd0) and create an ext2
kernel filesystem on it:
The ``-N 24'' specifies 24 inodes, which is all you should need for this filesystem. Next, mount
the filesystem, remove the lost+found directory, and create dev and boot directories for LILO:
Next, create devices /dev/null and /dev/fd0. Instead of looking up the device numbers, you
can just copy them from your hard disk using -R:
cp -R /dev/{null,fd0} /mnt/dev
LILO needs a copy of its boot loader, boot.b, which you can take from your hard disk. It is
usually kept in the /boot directory.
cp /boot/boot.b /mnt/boot
Finally, copy in the LILO configuration file you created in the last section, along with your
kernel. Both can be put in the root directory:
LILO should run without error, after which the kernel filesystem should look something like this:
total 361
1 –rw–r––r–– 1 root root 176 Jan 10 07:22 bdlilo.conf
1 drwxr–xr–x 2 root root 1024 Jan 10 07:23 boot/
1 drwxr–xr–x 2 root root 1024 Jan 10 07:22 dev/
358 –rw–r––r–– 1 root root 362707 Jan 10 07:23 vmlinuz
boot:
total 8
4 –rw–r––r–– 1 root root 3708 Jan 10 07:22 boot.b
4 –rw––––––– 1 root root 3584 Jan 10 07:23 map
dev:
total 0
0 brw–r––––– 1 root root 2, 0 Jan 10 07:22 fd0
0 crw–r––r–– 1 root root 1, 3 Jan 10 07:22 null
Do not worry if the file sizes are slightly different from yours.
If you are not using LILO, transfer the kernel to the bootdisk with dd:
In this example, dd wrote 353 complete records + 1 partial record, so the kernel occupies the
first 354 blocks of the diskette. Call this number KERNEL_BLOCKS and remember it for use in the
next section.
Finally, set the root device to be the diskette itself, then set the root to be loaded read/write:
Inside the kernel image is the ramdisk word that specifies where the root filesystem is to be
found, along with other options. The word can be accessed and set via the rdev command, and
its contents are interpreted as follows:
Bit Description
field
11- unused
13
If bit 15 is set, on boot-up you will be prompted to place a new floppy diskette in the drive. This
is necessary for a two-disk boot set.
There are two cases, depending on whether you are building a single boot/root diskette or a
double ``boot+root'' diskette set.
1. If you are building a single disk, the compressed root filesystem will be placed right after
the kernel, so the offset will be the first free block (which should be the same as
KERNEL_BLOCKS). Bit 14 will be set to 1, and bit 15 will be zero. For example, say you're
building a single disk and the root filesystem will begin at block 253 (decimal). The
ramdisk word value should be 253 (decimal) with bit 14 set to 1 and bit 15 set to 0. To
calculate the value you can simply add the decimal values. 253 + (2^14) = 253 + 16384 =
16637. If you don't quite understand where this number comes from, plug it into a
scientific calculator and convert it to binary,
2. If you are building a two-disk set, the root filesystem will begin at block zero of the
second disk, so the offset will be zero. Bit 14 will be set to 1 and bit 15 will be 1. The
decimal value will be 2^14 + 2^15 = 49152 in this case.
After carefully calculating the value for the ramdisk word, set it with rdev -r. Be sure to use the
decimal value. If you used LILO, the argument to rdev here should be the mounted kernel path,
e.g. /mnt/vmlinuz; if you copied the kernel with dd, instead use the floppy device name (e.g.,
/dev/fd0).
Do not believe what the rdev/ramsize manpage says about ramdisk size. The manpage is
obsolete. As of kernel 2.0 or so, the ramdisk word no longer determines the ramdisk size;
the word is instead interpreted according to the table at the beginning of section Section 6.3.
For a detailed explanation, see the documentation file ramdisk.txt or
http://www.linuxhq.com/kernel/v2.4/doc/ramdisk.txt.html.
If the root filesystem will be placed on the same disk as the kernel, transfer it using dd
with the seek option, which specifies how many blocks to skip:
If the root filesystem will be placed on a second disk, remove the first diskette, put the
second diskette in the drive, then transfer the root filesystem to it:
You should always test a bootdisk before putting it aside for an emergency. If it fails to
boot, read on.
This section assumes that you are familiar with the process and workings of writing CDs in
linux. Consider this to be a quick reference to include the ability to boot the CD which you will
burn. The CD-Writing-HOWTO should give you an in-depth reference.
For the x86 platform, many BIOS's have begun to support bootable CDs. The patches for
mkisofs is based on the standard called "El Torito". Simply put, El Torito is a specification that
says how a cdrom should be formatted such that you can directly boot from it.
The "El Torito" spec says that any cdrom drive should work (SCSI or EIDE) as long as the BIOS
supports El Torito. So far this has only been tested with EIDE drives because none of the SCSI
controllers that has been tested so far appears to support El Torito. The motherboard definately
has to support El Torito. How do you know if your motherboard supports "El Torito"? Well, the
ones that support it let you choose booting from hard disk, Floppy, Network or CDROM.
How it Works
The El Torito standard works by making the CD drive appear, through BIOS calls, to be a
normal floppy drive. This way you simply put any floppy size image (exactly 1440k for a 1.44
meg floppy) somewhere in the ISO filesystem. In the headers of the ISO fs you place a pointer to
this image. The BIOS will then grab this image from the CD and for all purposes it acts as if it
were booting from the floppy drive. This allows a working LILO boot disk, for example, to
simply be used as is.
Roughly speaking, the first 1.44 (or 2.88 if supported) Mbytes of the CD-ROM contains a
floppy-disk image supplied by you. This image is treated like a floppy by the BIOS and booted
from. (As a consequence, while booting from this virtual floppy, your original drive A:
(/dev/fd0) may not be accessible, but you can try with /dev/fd1).
First create a file, say "boot.img", which is an exact image of the bootable floppy-disk which you
want to boot via the CD-ROM. This must be an 1.44 MB bootable floppy-disk. The command
below will do this
Place this image somewhere in the hierarchy which will be the source for the iso9660 filesystem.
It is a good idea to put all boot related files in their own directory ("boot/" under the root of the
iso9660 fs, for example).
One caveat -- Your boot floppy must load any initial ramdisk via LILO, not the kernel ramdisk
driver! This is because once the linux kernel starts up, the BIOS emulation of the CD as a floppy
disk is circumvented and will fail. LILO will load the initial ramdisk using BIOS disk calls, so
the emulation works as designed.
So we have our boot image in the file boot.img, and we are going to put it in the directory
boot/ under the root of the iso9660 filesystem. We will have the boot catalog go in the same
directory with the name boot.catalog. The command to create the iso9660 fs in the file
bootcd.iso is then:
The -b option specifies the boot image to be used (note the path is relative to the root of the
iso9660 disk), and the -c option is for the boot catalog file. The -r option will make approptiate
file ownerships and modes (see the mkisofs manpage). The "." in the end says to take the source
from the current directory.
Now burn the CD with the usual cdrecord command and it is ready to boot.
The first step is to get hold of the bootable image used by the source CD. But you cannot simply
mount the CD under linux and dd the first 1440k to a floppy disk or to a file like boot.img.
Instead you simply boot with the source CD-ROM.
When you boot the Win98 CD you are dropped to A: prompt which is the actual ramdisk. And
D: or Z: is where all the installables are residing. By using the diskcopy command of dos copy
the A: image into the actual floppy drive which is now B: The command below will do this.
diskcopy A: B:
It works just like dd. You can try booting from this newly created disk to test if the booting
process is similar to that of the source CD. Then the usual dd of this floppy to a file like boot.img
and then rest is as usual.
A: This probably should be explained better in the text, but I'll put an answer here for the time
being.
Second, keep in mind that ramdisks are actually dynamic; when you set a ramdisk size you aren't
allocating any memory, you're just setting the limit of how large it can grow. Don't be afraid to
set these fairly large (eg, 8 or even 16 meg). The RAM space is not actually consumed until you
need it. You can set these limits in one of several ways.
1. Use the ramdisk_size=NNN command line parameter. You can either enter this manually
or use a command like append="ramdisk_size=NNN" with LILO.
2. If you're using LILO, you can use a kernel option like ramdisk=8192K in the lilo.conf
file.
3. Change the kernel configuration option CONFIG_BLK_DEV_RAM_SIZE and recompile your
kernel.
A: See section
A: Since I don't have an LS-120 drive, the following information is summarized from
information provided by Dave Cinege from the Linux Router Project.
The LS-120 is an IDE floppy drive. It is compatible with both standard 3.5" disks and the new
120MB disks. As of Linux v2.0.31 there is full support. To be able to boot from these you must
have a BIOS that specifically allows the LS-120 to be treated as drive 0 (whereas IDE devices
normally start at 80). If you do not have BIOS support, you can purchase a small IDE
FloppyMAX card from Promise Technologies to overcome this deficiency.
The kernel boot loader does not like the LS-120, and instantly dies. Also 2m disks do not like it
and will not boot. 1.44MB through 1.74MB disks will work fine. SYSLINUX works with the
120MB disks as of v1.32. You would better off partitioning the disk and using ext2 or minix,
instead of SYSLINUX unless you need MS-DOS compatibility.
LILO does work fine with 120MB disks. Here is a sample lilo.conf:
boot=/dev/hda
compact
disk=/dev/hda bios=0
install=/floppy/boot.b
map=/floppy/map
image=/floppy/linux
label=Linux
append="load_ramdisk=1"
initrd=/floppy/root.bin
The line "disk=/dev/hda bios=0" is what does the trick to make it boot the LS-120.
A: The easiest way is to obtain a Slackware kernel from your nearest Slackware mirror site.
Slackware kernels are generic kernels which atttempt to include drivers for as many devices as
possible, so if you have a SCSI or IDE controller, chances are that a driver for it is included in
the Slackware kernel.
Go to the a1 directory and select either IDE or SCSI kernel depending on the type of controller
you have. Check the xxxxkern.cfg file for the selected kernel to see the drivers which have been
included in that kernel. If the device you want is in that list, then the corresponding kernel should
boot your computer. Download the xxxxkern.tgz file and copy it to your boot diskette as
described above in the section on making boot disks.
You must then check the root device in the kernel, using the command rdev zImage. If this is
not the same as the root device you want, use rdev to change it. For example, the kernel I tried
was set to /dev/sda2, but my root SCSI partition is /dev/sda8. To use a root diskette, you
would have to use the command rdev zImage /dev/fd0.
If you want to know how to set up a Slackware root disk as well, that's outside the scope of this
HOWTO, so I suggest you check the Linux Install Guide or get the Slackware distribution. See
the section in this HOWTO titled ``References''.
A: The easiest way is to copy the filesystem from the rootdisk back to the DEVICE you used
Then mount the filesystem and make the changes. You have to remember where your root
filesystem started and how many blocks it occupied:
After making the changes, proceed as before (in Section 4.7) and transfer the root filesystem
back to the disk. You should not have to re-transfer the kernel or re-compute the ramdisk word if
you do not change the starting position of the new root filesystem.
A: This is not really a Bootdisk topic, but it is asked often. Within Linux, you can run:
/sbin/lilo -u
Within DOS and Windows you can use the DOS command:
FDISK /MBR
MBR stands for Master Boot Record. This command replaces the boot sector with a clean DOS
one, without affecting the partition table. Some purists disagree with this, but even the author of
LILO, Werner Almesberger, suggests it. It is easy, and it works.
A: If you don't have a boot disk standing by, probably the easiest method is to obtain a
Slackware kernel for your disk controller type (IDE or SCSI) as described above for ``How do I
make a boot disk with a XXX driver?''. You can then boot your computer using this kernel, then
repair whatever damage there is.
The kernel you get may not have the root device set to the disk type and partition you want. For
example, Slackware's generic SCSI kernel has the root device set to /dev/sda2, whereas my
root Linux partition happens to be /dev/sda8. In this case the root device in the kernel will have
to be changed.
You can still change the root device and ramdisk settings in the kernel even if all you have is a
kernel, and some other operating system, such as DOS.
rdev changes kernel settings by changing the values at fixed offsets in the kernel file, so you can
do the same if you have a hex editor available on whatever systems you do still have running --
for example, Norton Utilities Disk Editor under DOS. You then need to check and if necessary
change the values in the kernel at the following offsets:
The interpretation of the ramdisk word was described in Section 6.3, above.
The major and minor device numbers must be set to the device you want to mount your root
filesystem on. Some useful values to select from are:
Once you have set these values then you can write the file to a diskette using either Norton
Utilities Disk Editor, or a program called rawrite.exe. This program is included in all
distributions. It is a DOS program which writes a file to the ``raw'' disk, starting at the boot
sector, instead of writing it to the file system. If you use Norton Utilities you must write the file
to a physical disk starting at the beginning of the disk.
A: Because magnetic media may deteriorate over time, you should keep several copies of your
rescue disk, in case the original is unreadable.
The easiest way of making copies of any diskettes, including bootable and utility diskettes, is to
use the dd command to copy the contents of the original diskette to a file on your hard drive, and
then use the same command to copy the file back to a new diskette. Note that you do not need to,
and should not, mount the diskettes, because dd uses the raw device interface.
dd if=DEVICENAME of=FILENAME
where DEVICENAME is the device name of the diskette drive and FILENAME is the name of
the (hard-disk) output file. Omitting the count parameter causes dd to copy the whole diskette
(2880 blocks if high-density).
To copy the resulting file back to a new diskette, insert the new diskette and enter the reverse
command:
dd if=FILENAME of=DEVICENAME
Note that the above discussion assumes that you have only one diskette drive. If you have two of
the same type, you can copy diskettes using a command like:
dd if=/dev/fd0 of=/dev/fd1
A: Where a disk device cannot be autodetected it is necessary to supply the kernel with a
command device parameter string, such as:
aha152x=0x340,11,3,1
By entering it on the command line every time the system is booted via LILO. This is
boring, though.
By using LILO's lock keyword to make it store the command line as the default
command line, so that LILO will use the same options every time it boots.
By using the append= statement in the LILO config file. Note that the parameter string
must be enclosed in quotes.
For example, a sample command line using the above parameter string would be:
This would pass the device parameter string through, and also ask the kernel to set the root
device to /dev/sda1 and save the whole command line and reuse it for all future boots.
APPEND = “aha152x=0x340,11,3,1”
Note that the parameter string must not be enclosed in quotes on the command line, but it must
be enclosed in quotes in the APPEND statement.
Note also that for the parameter string to be acted on, the kernel must contain the driver for that
disk type. If it does not, then there is nothing listening for the parameter string, and you will have
to rebuild the kernel to include the required driver. For details on rebuilding the kernel, go to
/usr/src/linux and read the README, and read the Linux FAQ and Installation HOWTO.
Alternatively you could obtain a generic kernel for the disk type and install that.
Readers are strongly urged to read the LILO documentation before experimenting with LILO
installation. Incautious use of the BOOT statement can damage partitions.
A: There are several cases of program names being hardcoded in various utilities. These cases do
not occur everywhere, but they may explain why an executable apparently cannot be found on
your system even though you can see that it is there. You can find out if a given program has the
name of another hardcoded by using the strings command and piping the output through grep.
A: Where this occurs, a kernel message like this will appear as the kernel is booting:
This is probably because the size has been set to 0 by kernel parameters at boot time. This could
possibly be because of an overlooked LILO configuration file parameter:
ramdisk= 0
This was included in sample LILO configuration files in some older distributions, and was put
there to override any previous kernel setting. If you have such a line, remove it.
Note that if you attempt to use a ramdisk of 0 size, the behaviour can be unpredictable, and can
result in kernel panics.
Ramdisk usage
An excellent description of the how the ramdisk code works may be found with the
documentation supplied with the Linux kernel. See
/usr/src/linux/Documentation/ramdisk.txt. It is written by Paul Gortmaker and includes a
section on creating a compressed ramdisk.
arch/i386/boot/compressed/misc.c
arch/i386/kernel/
Directory containing kernel initialization code. setup.c defines the ramdisk word.
drivers/block/rd.c
Contains the ramdisk driver. The procedures rd_load and rd_load_image load blocks
from a device into a ramdisk. The procedure identify_ramdisk_image determines what
kind of filesystem is found and whether it is compressed.
Output Problem
(nothing) No part of LILO has been loaded. LILO either isn't installed or the partition on which
its boot sector is located isn't active.
L The first stage boot loader has been loaded and started, but it can't load the second
stage boot loader. The two-digit error codes indicate the type of problem. (See also
section ``Disk error codes''.) This condition usually indicates a media failure or a
geometry mismatch (e.g. bad disk parameters).
LI The first stage boot loader was able to load the second stage boot loader, but has failed
to execute it. This can either be caused by a geometry mismatch or by moving
/boot/boot.b without running the map installer.
LIL The second stage boot loader has been started, but it can't load the descriptor table
from the map file. This is typically caused by a media failure or by a geometry
mismatch.
LIL? The second stage boot loader has been loaded at an incorrect address. This is typically
caused by a subtle geometry mismatch or by moving /boot/boot.b without running
the map installer.
LIL- The descriptor table is corrupt. This can either be caused by a geometry mismatch or
by moving /boot/map without running the map installer.
LILO All parts of LILO have been successfully loaded.
If the BIOS signals an error when LILO is trying to load a boot image, the respective error code
is displayed. These codes range from 0x00 through 0xbb. See the LILO User Guide for an
explanation of these.
LinuxWorld
Format: Web based
Cover Price: no charge
Monthly ezine with daily news updates.
SlashDot
Format: Web based
Cover Price: no charge
Up-to-the-minute online ezine with lots of Linux information and news. Visitors may post responses in a
discussion format.