Chapter 15: Disk and File System Management


Oh, my head hurts bad.
Rings of ones and zeros, ouch!
File systems hide them.

Disk management is one of a systems administrator's most vital duties. Disk flexibility and reliability are paramount to any operating system, and understanding how to manage, tune, and optimize disks and file systems is unquestionably a necessary skill. OpenBSD can handle several different sorts of disks and file systems, and in this chapter we'll discuss many of them.

Device Nodes

A device node is a special file that provides a logical interfaces to a piece of hardware. By using a command on a device node, sending information to a device node, or reading from a device node, you're telling the operating system to perform an action on a piece of hardware or, in some cases, a "logical" device. The action taken varies widely from device to device — for example, writing to a disk drive produces very different results than writing data to the screen! OpenBSD stores all device nodes in /dev and actually mounts other file systems in such a way that device nodes cannot be used on them. Many disk-management programs expect to be given a device name as an argument. Device node names are frequently cryptic and vary widely between operating systems, even operating systems that are closely related and run on similar hardware. The following table lists the device node names for OpenBSD disk devices.

Device node

Description

/dev/fd*

floppy disk (block)

/dev/rfd*

"raw" floppy disk

/dev/wd*

IDE disk (block)

/dev/rwd*

"raw" IDE disk

/dev/sd*

SCSI disk (block)

/dev/rsd*

"raw" SCSI disk

/dev/cd*

CD-ROM device, either IDE or SCSI (block)

/dev/rcd*

"raw" CD-ROM device

Device names also have a number, indicating which instance of that device it refers to. For example, /dev/wd0 is your first IDE hard drive, /dev/wd1 is the second, and /dev/cd1 is your second CD-ROM drive.

Remember from when we installed OpenBSD that each partition has a letter: The root partition was "a," the swap area was "b," the whole disk was "c," and so on. Each of those partitions has a separate device node, given by adding the letter to the device name for the hard drive device. For example, /dev/wd0a is the root partition on the first IDE hard drive, and /dev/sd3b is the swap partition on the fourth SCSI hard drive.

Raw and Block Devices

Raw devices are neither crunchy, healthy, nor full of vitamins, but are just a different way of accessing the same device. If you're not interested in an explanation, all you need to know is that certain programs expect to access a device through the standard device node and others expect to access the raw device node. Programs designed to work with raw device nodes will not work on the standard device node, and vice versa. Raw devices are sometimes called character devices, because they access the hard drive a character at a time. If you must control exactly how the data is laid down on the disk, such as when creating a file system in the first place, use a raw device.

A "standard" device node is more properly called a block device. Data transmitted to or from the device is buffered, meaning that chunks of data are collected until there is enough data to make it worth the trouble to access the device. A block device is occasionally called a cooked device. Block devices are generally considered more efficient than raw devices.

In contrast, a raw device does no buffering. If you tell a system to write to a file via a raw device, the data is immediately transmitted to the device. This works best when running a program that provides its own input/output buffering or has a particular way it wants to arrange disk data.

Here's an easy way to remember the difference between block and raw throughput. Spill a bottle of aspirin. You might pick up the aspirin with your right hand and collect them in the left, until your left hand is comfortably full and you can dump a bunch into the bottle at once. You're buffering your aspirin transfers in your hand. (If it's buffered aspirin, then this is buffered buffered aspirin transfers. But let's not go there.) If you pick up each aspirin individually and deposit it directly in the bottle, it's considered an unbuffered or raw transfer.

Raw devices have an "r" in front of their name, but they refer to the same physical hardware as the block device. If a program opens /dev/wd0a, it's accessing the root partition on the first IDE hard drive in block mode; however, if it asks for /dev/rwd0a, it's accessing the same partition in raw mode.




Absolute Openbsd(c) Unix for the Practical Paranoid
Absolute OpenBSD: Unix for the Practical Paranoid
ISBN: 1886411999
EAN: 2147483647
Year: 2005
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net