Quick Jumps:
Home Lists Forums Downloads Support
Guide Navigation:

Practical Guide to UNIX System Administration

Devices

Under UNIX, a device is any piece of hardware in the system that a user or process would explicitly use. Examples of devices include disk drives, tape drives, soundcards, keyboards, and so on. System components such as the motherboard, processor, and so on aren't generally considered devices since users and processes have no reason to access them directly.

The way UNIX treats devices demonstrates the fascination that its originators had with files. Rather than having to write data to a specific memory address, notify a device driver, and all kinds of other garbage that some operating systems require; UNIX only requires that data be read from or written to a file. The "file" that is used to interact with a device isn't really a file in the traditional sense, but more of a special file that acts as an alias to a device driver. Unless you want to write device drivers, there's really no reason to ever think of these special files as anything but just that - files.

System administration usually focuses on two classes of these special files - disk devices and magnetic tape devices. For the most part, just knowing what special file is associated with which device is all the information you'll need. The operating system or helper programs take care of the rest. For example, to mount a new disk partition or rewind a backup tape all you need to know is the special file name for the disk partition or the tape drive.

The special files for hard disks come in two forms: character (which is unbuffered) and block (which is buffered). Character devices are called raw devices on some versions of UNIX, including Linux. Every operating system has a slightly different system for naming hard disk special files, but most follow either the Linux or Solaris convention.

Solaris uses a highly precise (but slightly complicated) system for naming its special files. The file itself is named based on the physical disk's controller number (c), target number (t), and the partition number (s) (called a "slice" in Solaris, hence the "s"). For example, the third slice on the master disk attached to the first IDE controller in a Solaris system would be identified as c0t0s3, while the third slice on the slave disk on the same controller would be c0t1s3. If the device is a SCSI disk, a SCSI device number (d) is added to the file name. So the third partition of a disk on the first SCSI controller with a device number of 7 would be c0t0d7s3. It's complicated, but it makes sense. The character special files for Solaris disks are located in /dev/rdsk, and the block special files are located in /dev/dsk.

The special file names for magnetic tape drives under Solaris are much simpler. The name of the file is simply a number - the first tape drive in the system is identified as 0, the second as 1, and so on. The special files are located in /dev/rmt, so the full pathname to the special file for the first tape drive is /dev/rmt/0.

The system Linux uses for naming special files isn't even close to being as complicated as the one Solaris uses, but it's also not as precise. The first hard disk in a Linux system is identified as hda, the second as hdb, and so on. A number attached to the hard disk identifier identifies the partition. For example, the third partition on the first disk is referenced as hda3. SCSI disks are referenced in a similar fashion - the first SCSI disk is sda, the second is sdb, and so on. The partitions are identified the same way as non-SCSI disks, so the third partition on the first SCSI disk is referenced as sda3. The block special files for disks are located in /dev. Character special files are rarely used on Linux systems, and are located in /dev/rd. Just to make life complicated, the character special files on Linux follow the same naming scheme as character special files on Solaris rather than the standard Linux convention.

The special file names for magnetic tape drives in Linux are very similar to the names used under Solaris. Instead of having a separate directory for tape devices, they are located in /dev with the other devices. The first magnetic tape drive in the system is referenced as /dev/rmt0, the second as /dev/rmt1, and so on.


Generously hosted by:
SourceForge Logo