-->

Previous | Table of Contents | Next

Page 216

disk caching scheme, which provides most of the speed benefit of a ramdisk but not the fixed cost in memory.

The most common use for ramdisks, then, is to serve as a root filesystem while Linux is being installed. A compressed filesystem image is loaded into a ramdisk, and the installation process is run from this disk. The ramdisk's filesystem can be larger than a single floppy, because the image is compressed on the floppy.

Although ramdisks are useful with operating systems lacking effective disk buffering, they offer little performance advantage under Linux. Should you want to try out a ramdisk, they work just like any other block device. For example, to mount a ramdisk as /tmp, you would add


/dev/ram    /tmp        ext2    defaults    0 0

to /etc/fstab and then create and mount an ext filesystem with the following:


/sbin/mkfs -t ext2 /dev/ram

mount /tmp

Any performance benefits from doing this are hard to find, but you might find that this helps in unusual circumstances.

The principal advantage of ramdisks is that they enable great flexibility in the boot process. Although it is possible to recompile a kernel including support for your hardware, this makes the initial installation process difficult. Historically, this problem has been worked around by the provision of dozens of different installation boot disks, each providing support for one or two items of boot hardware (SCSI cards and CD-ROM drives, for example).

A simpler solution is to exploit loadable kernel modules. Instead of having separate boot disks for each type of hardware, all containing different kernels, it is simple to provide just one boot disk containing a modular kernel and the module utilities themselves.

A compressed filesystem is loaded from the floppy disk into a ramdisk by the kernel loader, LILO, at the same time the kernel is loaded. The kernel mounts this filesystem and runs a program (/linuxrc) from it. This program then mounts the "real" root filesystem and exits, enabling the kernel to remount the real root filesystem on /. This system is convenient to set up, and the process of creating initial ramdisks had been automated by Red Hat Software (see the manual page for mkinitrd). Red Hat Linux systems whose root filesystem is on a SCSI device have a modular kernel and boot by this method.

Zip Drives

Zip drives are drives providing removable 100MB cartridges. They come in three varieties: parallel port (PPA), IDE, and SCSI. All are supported, but the parallel port version is slowest; it is also a SCSI drive but with a proprietary parallel port interface, for which the Linux kernel provides a driver. Hence, both kinds of drive appear as SCSI disks.

Because they're just standard (but removable) SCSI or IDE disks, most aspects of their use are just as for other block devices. Red Hat Linux 4.2 comes with support for both the SCSI and

Page 217

PPA varieties. Further information can be found in the Zip-Drive mini-HOWTO (which explains how to install your Zip drive), and the Zip-Install mini-HOWTO, which explains how to install Red Hat Linux onto a Zip drive.

Character Devices

Character devices offer a flow of data that must be read in order. Whereas block devices enable a seek to select the next block of data transferred, for example, from one edge or the other of a floppy disk, character devices represent hardware that doesn't have this capability. An example is a terminal, for which the next character to be read is whatever key you type at the keyboard.

In fact, because there are only two basic types of devices, block and character, all hardware is represented as one or the other, rather like the animal and vegetable kingdoms of biological classification. Inevitably, this means that there are a few devices that don't quite fit into this classification scheme. Examples include tape drives, generic SCSI devices, and the special memory devices such as /dev/port and /dev/kmem.

NOTE
Network interfaces are represented differently; see Chapter 13.

Parallel Ports

Parallel ports are usually used for communicating with printers, although they are versatile enough to support other things too—for example, Zip drives, CD-ROM drives, and even networking.

The hardware itself offers character-at-a-time communication. The parallel port can provide an interrupt to notify the kernel that it is now ready to output a new character, but because printers are usually not performance-critical on most PCs, this interrupt is often borrowed for use by some other hardware, often sound hardware. This has an unfortunate consequence: The kernel often needs to poll the parallel hardware, so driving a parallel printer often requires more CPU work than it should.

The good news, though, is that if your parallel printer interrupt is not in use by some other hardware, it can be enabled with the printer driver configuration program, tunelp. The -i option for tunelp sets the IRQ for use with each printer device. You might set the IRQ for the printer port to 7 like this:


# /usr/sbin/tunelp /dev/lp1 -i 7

/dev/lp1 using IRQ 7

Page 218

If this results in the printer ceasing to work, going back to the polling method is easy:


# /usr/sbin/tunelp /dev/lp1 -i 0

/dev/lp1 using polling

The best way to test a printer port under Red Hat Linux is from the Control Panel's Printer Configuration tool (/usr/bin/printtool). The Tests menu offers the option of printing a test page directly to the device rather than via the normal printing system. This is a good starting point. More information on setting up printers can be found in Chapter 12, "Printing with Linux."

Tape Drives

Tape drives provide I/O of a stream of bytes to or from the tape. While most tape drives can be repositioned (that is, rewound and wound forward like audio or video tapes), this operation is very slow by disk standards. While access to a random part of the tape is at least feasible, it is very slow, and so the character device interface is workable for using tape drives.

For most UNIX workstations, the interface of choice for tape drives is SCSI because this fits in well with the SCSI disks and so on. SCSI provides the ability to just plug in a new device and start using it. (Of course, you can't do this with the power on.) SCSI has traditionally been more expensive than most other PC technologies, so it wasn't used for many tape drives developed for use with PCs. There have been several interfaces used for tape drives for IBM PCs, and these include the following:


Type Device Names Major Number
SCSI /dev/st* 9
Floppy /dev/rft* 27
QIC-02 /dev/rmt 12
IDE /dev/ht* 37
Parallel Port (Currently unsupported)

All these tape drives have the feature that when the device is closed, the tape is rewound. All these drives except the QIC-02 drive have a second device interface with a name prefixed with n—for example /dev/nst0, /dev/nst3, or /dev/nht0. All these devices support the magnetic tape control program, mt, which is used for winding tapes past files, rewinding them, and so on. Many commands, particularly the more advanced mt commands, are only available for SCSI tape drives.

Apart from the mt command for the basic control of a tape drive, there are many commands that you can use for storing and retrieving data on tape. Because the character devices are "just files," you could use cat to store data on the tape, but this is not very flexible. There are a great many programs particularly or partly designed with tape drives in mind, including the following:

Previous | Table of Contents | Next