377 lines
14 KiB
HTML
377 lines
14 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>The Linux Bootdisk HOWTO: Disks</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<A HREF="Bootdisk-HOWTO-1.html"><IMG SRC="prev.gif" ALT="Previous"></A>
|
|
<A HREF="Bootdisk-HOWTO-3.html"><IMG SRC="next.gif" ALT="Next"></A>
|
|
<A HREF="Bootdisk-HOWTO.html#toc2"><IMG SRC="toc.gif" ALT="Contents"></A>
|
|
<HR>
|
|
<H2><A NAME="s2">2. Disks</A></H2>
|
|
|
|
|
|
<H2><A NAME="ss2.1">2.1 Summary of Disk Types</A></H2>
|
|
|
|
<P>I classify boot-related disks into 4 types. The discussion here
|
|
and throughout this document uses the term "disk" to refer to
|
|
diskettes unless otherwise specified. Most of the discussion could
|
|
be equally well applied to hard disks. </P>
|
|
<P>A summary of disk types and uses is:
|
|
<DL>
|
|
<DT><B>boot</B><DD><P>A disk containing a kernel which can be booted. The disk
|
|
can contain a filesystem and use a boot loader to boot, or it can
|
|
simply contain the kernel only at the start of the disk.
|
|
The disk can be used to boot the kernel using a root
|
|
file system on another disk. This could be useful if you lost your
|
|
boot loader due to, for example, an incorrect installation attempt.</P>
|
|
|
|
<DT><B>root</B><DD><P>A disk with a file system containing everything
|
|
required to run a Linux system. It does not necessarily contain
|
|
either a kernel or a boot loader.</P>
|
|
<P>This disk can be used to run the system independently of any other
|
|
disks, once the kernel has been booted. A special kernel feature
|
|
allows a separate root disk to be mounted after booting, with the
|
|
root disk being automatically copied to a ramdisk.</P>
|
|
<P>You could use this type of disk to check another disk for corruption
|
|
without mounting it, or to restore another disk after a disk failure or
|
|
loss of files.</P>
|
|
|
|
<DT><B>boot/root</B><DD><P>A disk which is the same as a root disk, but
|
|
contains a kernel and a boot loader. It can be used to boot from,
|
|
and to run the system. The advantage of this type of disk is
|
|
that is it compact - everything required is on a single disk.
|
|
However the gradually increasing size of everything means that
|
|
it won't necessarily always be possbile to fit everything on a single
|
|
diskette.</P>
|
|
|
|
<DT><B>utility</B><DD><P>A disk which contains a file system, 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.</P>
|
|
<P>The term "utility" only really applies to diskettes, where you would
|
|
use a utility disk to store additional recovery utility software.</P>
|
|
</DL>
|
|
</P>
|
|
|
|
|
|
<H2><A NAME="ss2.2">2.2 Boot</A></H2>
|
|
|
|
|
|
<H3>Overview</H3>
|
|
|
|
<P>All PC systems start the boot process by executing code in ROM to load
|
|
the sector from sector 0, cylinder 0 of the boot drive and try and
|
|
execute it. On most bootable disks, sector 0, cylinder 0 contains either:
|
|
<UL>
|
|
<LI>code from a boot loader such as LILO, which locates the kernel,
|
|
loads it and executes it to start the boot proper.</LI>
|
|
<LI>the start of an operating system kernel, such as Linux.</LI>
|
|
</UL>
|
|
</P>
|
|
<P>If a Linux kernel has been written to a diskette as a raw device,
|
|
then the first sector will be the first sector of the Linux kernel
|
|
itself, and this sector will continue the boot process by loading
|
|
the rest of the kernel and running Linux. For a more detailed
|
|
description of the boot sector contents, see the documentation
|
|
in lilo-01.5 or higher.</P>
|
|
<P>An alternative method of storing a kernel on a boot disk is to create
|
|
a filesystem, not as a root filesystem, but simply as a means of
|
|
installing LILO and thus allowing boot-time command line options
|
|
to be specified. For example, the same kernel could then be used
|
|
to boot using a hard disk root filesystem, or a diskette root
|
|
filesystem. This could be useful if you were trying to rebuild
|
|
the hard disk filesystem, and wanted to repeatedly test results.</P>
|
|
|
|
<H3>Setting Pointer to Root</H3>
|
|
|
|
<P>The kernel must somehow obtain a pointer to the drive and partititon to
|
|
be mounted as the root drive. This can be provided
|
|
in several ways:
|
|
<UL>
|
|
<LI>By setting <CODE>ROOT_DEV = devicename</CODE> in the Linux kernel makefile
|
|
and rebuilding the kernel (for advice on how to rebuild the kernel,
|
|
read the Linux FAQ and look in <CODE>/usr/src/linux</CODE>). Comments in the
|
|
Linux makefile describe the valid values for <CODE>devicename</CODE>.</LI>
|
|
<LI>By running the rdev utility:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
rdev filename devicename
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
|
|
|
|
This will set the root device of the kernel contained in <CODE>filename</CODE>
|
|
to be <CODE>devicename</CODE>. For example:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
rdev zImage /dev/sda1
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
|
|
|
|
This sets the root device in the kernel in zImage to the first partition on
|
|
the first SCSI drive.</LI>
|
|
</UL>
|
|
</P>
|
|
<P>There are some alternative ways of issuing the rdev command. Try:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
rdev -h
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>and it will display command usage.</P>
|
|
<P>There is usually no need to configure the root device for
|
|
boot diskette use, because the kernel currently used to boot from
|
|
probably already points to the root drive device. The need can
|
|
arise, howoever, if you obtain a kernel from another machine,
|
|
for example, from a distribution, or if you want to use the kernel
|
|
to boot a root diskette. It is probably a good idea to check the
|
|
current root drive setting, just in case it is wrong. To get
|
|
rdev to check the current root device in a kernel file, enter
|
|
the command:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
rdev <filename>
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>It is possible to change the root device set in a kernel by means other
|
|
than using rdev. For details, see the FAQ at the end of this document.</P>
|
|
|
|
<H3>Copying Kernel to Boot Diskette</H3>
|
|
|
|
<P>Once the kernel has been configured then it must be copied to the
|
|
boot diskette. </P>
|
|
<P>The commands described below (and throughout the HOWTO) assume that
|
|
the diskettes have been formatted. If not, then use fdformat to format
|
|
the diskettes before continuing.</P>
|
|
<P>If the disk is not intended to contain a file system, then the kernel
|
|
can be copied using the dd command, as follows:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
dd if=infilename of=devicename
|
|
|
|
where infilename is the name of the kernel
|
|
and devicename is the diskette raw device,
|
|
usually /dev/fd0
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>The cp command can also be used:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
cp filename devicename
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>For example:</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
dd if=zImage of=/dev/fd0
|
|
or
|
|
cp zImage /dev/fd0
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>The seek parameter to the dd command should NOT be used. The file
|
|
must be copied to start at the boot sector (sector 0, cylinder 0),
|
|
and omitting the seek parameter will do this.</P>
|
|
<P>The output device name to be used is usually <CODE>/dev/fd0</CODE> for
|
|
the primary diskette drive (i.e. drive "A:" in DOS), and <CODE>/dev/fd1</CODE>
|
|
for the secondary. These device names will cause the kernel to
|
|
autodetect the attributes of the drives. Drive attributes can
|
|
be specified to the kernel by using other device names: for
|
|
example <CODE>/dev/fd0H1440</CODE> specifies a high density 1.44 Mb
|
|
drive. It is rare to need to use these specific device names.</P>
|
|
<P>Where the kernel is to be copied to a boot disk containing a filesystem,
|
|
then the disk is mounted at a suitable point in a currently-mounted
|
|
filesystem, then the cp command is used. For example:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
mount -t ext2 /dev/fd0 /mnt
|
|
cp zImage /mnt
|
|
umount /mnt
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>Note that for almost all operations in this HOWTO, the user should be
|
|
operating as the superuser.</P>
|
|
|
|
|
|
<H2><A NAME="ss2.3">2.3 Root</A></H2>
|
|
|
|
|
|
<H3>Overview</H3>
|
|
|
|
<P>A root disk contains a complete working Linux system, but without
|
|
necessarily including a kernel. In other words, the disk may not
|
|
be bootable, but once the kernel is running, the root disk contains
|
|
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:
|
|
<UL>
|
|
<LI>File system.</LI>
|
|
<LI>Minimum set of directories - dev, proc, bin, etc, lib, usr, tmp.</LI>
|
|
<LI>Basic set of utilities - bash (to run a shell), ls, cp etc.</LI>
|
|
<LI>Minimum set of config files - rc, inittab, fstab etc.</LI>
|
|
<LI>Runtime library to provide basic functions used by utilities.</LI>
|
|
</UL>
|
|
</P>
|
|
<P>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:
|
|
<UL>
|
|
<LI>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.</LI>
|
|
<LI>Restore all or part of your original root drive from backup
|
|
using archive/compression utilities including cpio, tar,
|
|
gzip and ftape.</LI>
|
|
</UL>
|
|
</P>
|
|
|
|
|
|
<H2><A NAME="ss2.4">2.4 Boot/Root </A></H2>
|
|
|
|
<P>This is essentially the same as the root disk, with the
|
|
addition of a kernel and a boot loader such as LILO.</P>
|
|
<P>With this configuration, a kernel file is copied to the root file
|
|
system, and LILO is then run to install a configuration which
|
|
points to the kernel file on the target disk. At boot time, LILO
|
|
will boot the kernel from the target disk.</P>
|
|
<P>Several files must be copied to the diskette for this method to
|
|
work. Details of these files and the required LILO configuration,
|
|
including a working sample, are given below in the section
|
|
titled "LILO".</P>
|
|
|
|
<H3>RAM Disks and Root Filesystems on Diskette</H3>
|
|
|
|
<P>For a diskette root filesystem to be efficient, you need to be able to run
|
|
it from a ramdisk, i.e. an emulated disk drive in main memory.
|
|
This avoids having the system run at a snail's pace, which a
|
|
diskette would impose. The Ftape HOWTO states that a ramdisk will
|
|
be required when using Ftape because Ftape requires exclusive use of
|
|
the diskette controller.</P>
|
|
<P>There is an added benefit from using a ramdisk - the Linux kernel
|
|
includes an automatic ramdisk root feature, whereby it will, under
|
|
certain circumstances, automatically copy the contents of a
|
|
root diskette to a ramdisk, and then switch the root drive
|
|
to be the ramdisk instead of the diskette. This has two major
|
|
benefits:
|
|
<UL>
|
|
<LI>The system runs a lot faster.</LI>
|
|
<LI>The diskette drive is freed up to allow other diskettes
|
|
to be used on a single-diskette drive system.</LI>
|
|
</UL>
|
|
</P>
|
|
<P>The requirements for this feature to be invoked are:
|
|
<UL>
|
|
<LI>The file system on the diskette drive must be either a minix
|
|
or an ext2 file system. The ext2 file system is generally the preferred
|
|
file system to use. Note that if you have a Linux kernel earlier
|
|
than 1.1.73, then you should see the comments in the section
|
|
titled "File Systems" to see whether your kernel will
|
|
support ext2. If your kernel is old then you may have to use
|
|
minix. This will not cause any significant problems.</LI>
|
|
<LI>A ramdisk must be configured into the kernel, and it must
|
|
be at least as big as the diskette drive.</LI>
|
|
</UL>
|
|
</P>
|
|
<P>A ramdisk can be configured into the kernel in several ways:
|
|
<UL>
|
|
<LI>By uncommenting the RAMDISK macro in the Linux kernel
|
|
makefile, so that it reads:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
RAMDISK = -DRAMDISK=1440
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
|
|
to define a ramdisk of 1440 1K blocks, the size of a
|
|
high-density diskette.</LI>
|
|
<LI>By running the rdev utility, available on most Linux
|
|
systems. This utility displays or sets values for several
|
|
things in the kernel, including the desired size for a
|
|
ramdisk. To configure a ramdisk of 1440 blocks into a
|
|
kernel in a file named zImage, enter:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
rdev -r zImage 1440
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
|
|
this might change in the future, of course. To see what
|
|
your version of rdev does, enter the command:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
rdev -h
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
|
|
and it should display its options.</LI>
|
|
<LI>By using the boot loader package LILO to configure it into
|
|
your kernel at boot time. This can be done using the
|
|
LILO configuration parameter:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
ramdisk = 1440
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
|
|
to request a ramdisk of 1440 1K blocks at boot time.</LI>
|
|
<LI>By interrupting a LILO automatic boot and adding ramdisk=1440
|
|
to the command line. For example, such a command line might be:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
zImage ramdisk=1440
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
|
|
See the section on LILO for more details.</LI>
|
|
<LI>By editing the kernel file and altering the values near the
|
|
start of the file which record the ramdisk size. This is definitely a
|
|
last resort, but can be done. See the FAQ near the end of this
|
|
document for more details.</LI>
|
|
</UL>
|
|
</P>
|
|
<P>The easiest of these methods is LILO configuration, because you
|
|
need to set up a LILO configuration file anyway, so why not add the
|
|
ramdisk size here?</P>
|
|
<P>LILO configuration is briefly described in a section titled "LILO"
|
|
below, but it is advisable to obtain the latest stable version of
|
|
LILO from your nearest Linux mirror site, and read the documentation
|
|
that comes with it.</P>
|
|
<P>Ramdisks can be made larger than the size of a diskette, and made to
|
|
contain a filesystem as large as the ramdisk. This can be
|
|
useful to load all the software required for rescue work onto a single
|
|
high-performance ramdisk. The method of doing this is described in
|
|
the FAQ section under the question "How can I create an oversize
|
|
ramdisk filesystem?"</P>
|
|
|
|
|
|
<H2><A NAME="ss2.5">2.5 Utility</A></H2>
|
|
|
|
<P>Often one disk is not sufficient to hold all the software you need
|
|
to be able to perform rescue functions of analysing, repairing and
|
|
restoring corrupted disk drives. By the time you include tar, gzip
|
|
e2fsck, fdisk, Ftape and so on, there is enough for a whole new
|
|
diskette, maybe even more if you want lots of tools.</P>
|
|
<P>This means that a rescue set often requires a utility diskette,
|
|
with a file system containing any extra files required. This file
|
|
system can then be mounted at a convenient point, such as /usr, on
|
|
the boot/root system.</P>
|
|
<P>Creating a file system is fairly easy, and is described in
|
|
the section titled "File Systems". </P>
|
|
|
|
|
|
<HR>
|
|
<A HREF="Bootdisk-HOWTO-1.html"><IMG SRC="prev.gif" ALT="Previous"></A>
|
|
<A HREF="Bootdisk-HOWTO-3.html"><IMG SRC="next.gif" ALT="Next"></A>
|
|
<A HREF="Bootdisk-HOWTO.html#toc2"><IMG SRC="toc.gif" ALT="Contents"></A>
|
|
</BODY>
|
|
</HTML>
|