[Rehman00] Chapter 17. Peripheral Devices

来源:百度文库 编辑:神马文学网 时间:2024/04/28 04:02:47

Chapter 17. Peripheral Devices

Chapter Syllabus

17.1 Devices and Physical Paths

17.2 Device Files

17.3 SCSI Device File Naming Convention

17.4 Listing Installed Devices

17.5 Creating Device Files

17.6 Installing a New Device

17.7 Terminals and Modems

HP-UX communicates with all devices through device files placed in the/devdirectory. Logically, there is no difference between I/O to these filesand to ordinary disk files. But these files are not like ordinary diskfiles in that they don't occupy any space on the disk. As soon as dataare written to any of the device files, they are sent to the devicerepresented by that file. For example, if you output some data to aprinter device file, they go to an attached printer for the printingprocess. Any data read request from a device file is also redirected tothe actual device. A read request from the modem file reads incomingdata from the modem.

Most of the device files are created automatically by HP-UX. During the boot process, HP-UX probes all devices and executes/sbin/ioinit.rcscripts that create new device files if needed. If any device file isnot created automatically, HP-UX provides commands to create the devicefiles manually. These files follow a particular naming convention thatindicates the hardware path a device is connected to and the type ofthe device. There are two major types of devices: character-typedevices and block-type devices. These files also contain two specialfields, listed with thellcommand. These are major and minor device numbers. These numbersindicate the device driver and the encoded hardware address of thatdevice.

In this chapter, you will be introduced to hardware paths and device files. You will see how device files in the/devdirectory are arranged. You will find information about major and minornumbers, character- and block-type devices, the naming conventions usedfor device files, and some examples of device names. Then you will moveon to how to list devices installed in your system and how to determinewhich devices are usable. Device drivers will be the next topic, andafter that you will find information about how to install and configurenew devices in your system. Finally, you will find information onmodems and terminals, the device files related to them, and how theyare configured.

Aftergoing through this chapter, you will be able to install and removedevices from HP-UX systems, and to diagnose and correct problemsrelated to devices.

17.1. Devices and Physical Paths

AllHP-9000 series servers and workstations use PA-RISC processors that areconnected to several types of device adapters by using buses. Alldevices are connected to these device adapters. HP systems use manydifferent types of buses, so you need to specify what type of expansioncard you need. The buses that are used in HP systems are:

  • Extended Industry Standard Architecture (EISA)

  • General System Connect (GSC)

  • Hewlett-Packard Precision Bus (HP-PB)

  • High Speed System Connect (HSC)

  • PCI

Eachbus has its own characteristics, such as clock speed, data throughput,and signaling. The type of adapter is also different for each bus. Forexample, you will find different Ethernet adapters for PCI and GSCbuses.

Common Types of Device Adapters

Someof the device adapters commonly used in HP-9000 systems are listedhere. This list does not include all types of adapters; there are manyothers.

SCSI adapters Small Computer System Interface (SCSI) adapters are used to connect disk drives, tape drives, and CD-ROM drives to the system. Many devices can be connected to one adapter. There are different standards for SCSI adapters used today. The Fast/Wide SCSI adapter is the fastest of all types and has the capability of transferring data at the speed of 20 Mbytes per second. It can support up to 15 devices on a single adapter. Standard SCSI adapters support seven devices and can have a throughput of 5 Mbytes per second. Fast/Narrow or differential SCSI can support up to seven devices and have a throughput of 10 Mbytes per second. You need to purchase a particular type of adapter after verifying the type of bus present in your system.   All devices attached to SCSI adapters have a number that determines the priority of the device. The SCSI controller itself uses address 7. On SCSI adapters to which you can attach seven devices, device number 6 has the highest priority and device number 0 has the lowest priority. If you are using a Fast/Wide SCSI adapters the additional addresses have lower priorities than 0. Number 15 has a lower priority than number 0 and number 8 has the least priority level. The priority ordering for a Fast/Wide SCSI is: 7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8.   Care must be taken while powering up and down the SCSI devices. All SCSI devices must be powered up before starting the system and powered off after the system is shut down. No device should be attached or detached to a running system. Multiplexer A multiplexer or MUX is used to connect serial devices to the system. Typically, this is used for connecting modems, terminals, and any serial plotter or printer. A variety of MUXs is available from Hewlett-Packard. LAN card LAN/9000 supports Ethernet and IEEE 802.3 networks and is used to connect your machine to a local area network. Hewlett-Packard manufactures LAN cards for different buses, topologies, and speeds.

Youcan add a new device adapter any time you want. For example, to have anetwork-efficient server, you may add Gigabit Ethernet to your system.Similarly, you can add SCSI adapters to increase the number of diskdrives in the system.

Hardware Paths

A hardware path indicates the location of a device in your system. Typically, a hardware path is a string of numbers separated by the slash (/) and dot (.) symbols. Starting from the left, the first part of the device path is usually a bus number. This is followed by a slash (/)and then a bus converter number (if any). Then there are some othernumbers separated by dots. These numbers show the path to the device ina systematic way.

Let us analyze a device path name. A hardware path of8/12.5.0represents a SCSI disk connected to the system. The number 8 representsa bus in the system. The number 12 is the address of the SCSI adapteron the bus. The disk is connected to that SCSI adapter at address 5,having a logical unit number 0. Similarly, hardware address8/5/0represents a fiber channel adapter connected to bus 8, bus converternumber 5, and adapter number 0. On the backside of an HP-9000 server,you can see expansion slots, and some of these numbers may be presentthere. To list the devices in your system, you can use theioscancommand, which shows the hardware paths of all devices connected toyour system. A typical output of this command is as follows.

Code View:Scroll/Show All
# ioscan -f
Class I H/W Path Driver S/W State H/W Type Description
========================================================================
bc 0 root CLAIMED BUS_NEXUS
bc 1 8 ccio CLAIMED BUS_NEXUS I/O Adapter
ext_bus 0 8/0 c720 CLAIMED INTERFACE GSC add-on
Fast/Wide SCSI Interface
target 0 8/0.7 tgt CLAIMED DEVICE
ctl 0 8/0.7.0 sctl CLAIMED DEVICE Initiator
ext_bus 1 8/4 c720 CLAIMED INTERFACE GSC add-on
Fast/Wide SCSI Interface
bc 2 10 ccio CLAIMED BUS_NEXUS I/O Adapter
ext_bus 2 10/0 c720 CLAIMED INTERFACE GSC built-in
Fast/Wide SCSI Interface
target 13 10/0.1 tgt CLAIMED DEVICE
disk 16 10/0.1.0 sdisk CLAIMED DEVICE SEAGATE ST34371W
target 14 10/0.2 tgt CLAIMED DEVICE
disk 17 10/0.2.0 sdisk CLAIMED DEVICE SEAGATEST34572WC
target 15 10/0.3 tgt CLAIMED DEVICE
disk 18 10/0.3.0 sdisk CLAIMED DEVICE SEAGATE ST34371W
target 16 10/0.4 tgt CLAIMED DEVICE
disk 19 10/0.4.0 sdisk CLAIMED DEVICE SEAGATE ST34371W
target 17 10/0.5 tgt CLAIMED DEVICE
disk 20 10/0.5.0 sdisk CLAIMED DEVICE SEAGATE ST15150W
target 18 10/0.6 tgt CLAIMED DEVICE
disk 21 10/0.6.0 sdisk CLAIMED DEVICE SEAGATE ST15150W
target 19 10/0.7 tgt CLAIMED DEVICE
ctl 2 10/0.7.0 sctl CLAIMED DEVICE Initiator
bc 3 10/4 bc CLAIMED BUS_NEXUS Bus Converter
tty 0 10/4/0 mux2 CLAIMED INTERFACE MUX
lan 0 10/4/4 btlan1 CLAIMED INTERFACE HP HP-PB 100 Base TX
card
lan 1 10/4/8 btlan1 CLAIMED INTERFACE HP HP-PB 100 Base TX
card
ba 0 10/12 bus_adapter CLAIMED BUS_NEXUS Core I/O Adapter
ext_bus 3 10/12/5 c720 CLAIMED INTERFACE Built-in SCSI
target 20 10/12/5.0 tgt CLAIMED DEVICE
tape 0 10/12/5.0.0 stape CLAIMED DEVICE HP C1537A
target 21 10/12/5.2 tgt CLAIMED DEVICE
disk 22 10/12/5.2.0 sdisk CLAIMED DEVICE TOSHIBA CD-ROM
target 22 10/12/5.7 tgt CLAIMED DEVICE
ctl 3 10/12/5.7.0 sctl CLAIMED DEVICE Initiator
lan 4 10/12/6 lan2 CLAIMED INTERFACE Built-in LAN
ps2 0 10/12/7 ps2 CLAIMED INTERFACE Built-in
Keyboard/Mouse
processor 0 32 processor CLAIMED PROCESSOR Processor
processor 1 34 processor CLAIMED PROCESSOR Processor
memory 0 49 memory CLAIMED MEMORY Memory
#



A short description of the fields in theioscan command output is presented here.

Class Shows the category of the device. I Instance: When multiple devices or adapters of the same category are present, they are distinguished from one another by instance numbers. Usually instance numbers are assigned at installation time. H/W Path This is the hardware path as already discussed in this chapter. Driver Name of the driver that controls the device. The device drivers are built into the HP-UX kernel. When adding a device that needs a new device driver, the kernel needs to be reconfigured. S/W State CLAIMED means the device driver is loaded in the kernel and is bound to the device. UNCLAIMED means the device driver is not available in the kernel for that device. H/W Type Shows what type of device it is. Description A short description of the device.

Theioscancommand can be used, with the help of command line switches, to listdevices of a specific type only or devices connected to a particularadapter.

17.2. Device Files

Every device in HP-UX has a corresponding device file in the/devdirectory. This file describes the hardware path of the device and isused to communicate with the device. As you have seen in theioscan listing, all devices (keyboard, mouse, disks, etc.) have device drivers associated with them.

Thedevice files don't contain any data; instead, these are special filesused for input or output purposes related to that device. These devicefiles are created by HP-UX; however, you need to know which device filerepresents a particular device. You can use theioscan command to list devices and device files simultaneously. For example, if you want to list devices and device files of categorydisk, use the following command.

# ioscan -funC disk
Class I H/W Path Driver S/W State H/W Type Description
===========================================================
disk 16 10/0.1.0 sdisk CLAIMED DEVICE SEAGATE
ST34371W /dev/dsk/c2t1d0 /dev/rdsk/c2t1d0
disk 17 10/0.2.0 sdisk CLAIMED DEVICE SEAGATE
ST34572WC /dev/dsk/c2t2d0 /dev/rdsk/c2t2d0
disk 18 10/0.3.0 sdisk CLAIMED DEVICE SEAGATE
ST34371W /dev/dsk/c2t3d0 /dev/rdsk/c2t3d0
disk 19 10/0.4.0 sdisk CLAIMED DEVICE SEAGATE
ST34371W /dev/dsk/c2t4d0 /dev/rdsk/c2t4d0
disk 20 10/0.5.0 sdisk CLAIMED DEVICE SEAGATE
ST15150W /dev/dsk/c2t5d0 /dev/rdsk/c2t5d0
disk 21 10/0.6.0 sdisk CLAIMED DEVICE SEAGATE
ST15150W /dev/dsk/c2t6d0 /dev/rdsk/c2t6d0
disk 22 10/5.2.0 sdisk CLAIMED DEVICE TOSHIBA CD-
ROM XM-5401TA /dev/dsk/c3t2d0 /dev/rdsk/c3t2d0

Here youcan see that device files related to all disk type devices are listed.Each disk has two device files, one that represents a character-typedevice and the other that represents a block-type device. To list anindividual device file, you can use thell command with a result as shown.

brw-r-----   1 root   sys  31 0x010500 Jun 10  1996 c2t5d0

Output of thellcommand for a device file is different from a normal file and itcontains additional fields such as major and minor numbers. Thesefields will be explained shortly.

Devices Directory Hierarchy

Usually the device files are present in the/dev directory. However, some device files are also grouped in a subdirectory under the/dev directory. For example, all block-type device files for disk drives are located in the/dev/dsk directory. Table 17-1 lists some other directories used for grouping device files.

Table 17-1. Directories Used for Grouping Device Files
Directory Type of Files Present /dev/dsk Block device files for disk drives and CD-ROM /dev/rdsk Raw or character device files for disk drives and CD-ROM /dev/vg00 Device for volume group vg00; every volume group has its own directory /dev/rmt Device files for tape drives /dev/pts Stream-based pseudoterminal device files /dev/pty Pseudoterminal slave device files /dev/ptym Pseudoterminal master device files

Major and Minor Numbers

Let's look at a list of files. This list is an output of thell command, and it does not show file sizes. Instead, there is some other information in fields 5 and 6. Field 5 shows the major device number and field 6 shows the minor device number.

brw-r-----   1 root   sys  31 0x010500 Jun 10  1996 c1t0d5
brw-r----- 1 root sys 31 0x010600 Jun 10 1996 c1t0d6
brw-r----- 1 root sys 31 0x010700 Jun 10 1996 c1t0d7
brw-r----- 1 root sys 31 0x011000 Jun 10 1996 c1t1d0
brw-r----- 1 root sys 31 0x011100 Jun 10 1996 c1t1d1

Majordevice numbers represent the kernel driver used for the device. Thekernel driver is a software component that is invoked when an I/Orequest is made for the device. All devices of the same type have thesame major number, because the same driver is used for all of them. Forexample, the list shown is for disk drives of the same type, so thesehave the same major device number of 31.

Minordevice numbers show the physical location of a device. It is asix-digit hexadecimal number. It may also be considered to distinguishamong devices that have the same major number. The minor number is alsoused for device specific options. Consider this list of tape devices.

$ ll /dev/rmt/0m*
crw-rw-rw- 2 bin bin 212 0x030000 Oct 28 1997 /dev/rmt/0m
crw-rw-rw- 2 bin bin 212 0x030080 Sep 29 1997 /dev/rmt/0mb
crw-rw-rw- 2 bin bin 212 0x030040 Sep 29 1997 /dev/rmt/0mn
crw-rw-rw- 2 bin bin 212 0x0300c0 Sep 29 1997 /dev/rmt/0mnb
$

Allof these device files represent the same tape drive but they havedifferent minor numbers. These numbers represent a specific type oftape cartridge or format used when accessing the drive.

Character Devices

Characterdevices are also called raw devices. I/O to these devices is performedone character at one time. These devices are used for serial datatransfer. The types of character devices are terminals, modems, serialprinters, and tape drives. Disk drives also have character devices thatare used for low-level functions on a disk.

When you use thell command to list device files, the first character of every line in the output is “c” for these device files.

Block Devices

Blockdevices are used for transferring a block of data to and from a device.The data are exchanged through a buffer space in memory. An actualwrite to the device is performed only when the buffer is full.Similarly, when a read operation is performed, a block of data is readand put into the buffer. All disk drives and CD-ROM drives are examplesof block-type devices.

When you use thell command to list device files, the first character of every output line is “b” in block-type device files.

Study Break

Device Files and Hardware Paths

Go to the /dev directory and write down all subdirectories in this directory. Use the ioscan command to list all disk devices. Also write down the hardware paths for all disk drives. Are all of the disks attached to one SCSI interface? How many interfaces are installed in the system? You can find out by looking into the hardware path of the disk drives. From the output of the ll command you can also find out if all disk drives are using the same driver. Note the major device number associated with the disk device files. If the major number is the same, all disks use the same device driver.


17.3. SCSI Device File Naming Convention

SCSIdevice files in HP-UX follow a common naming convention, although it ispossible to assign other names to these files. The general format ofdevice file naming is shown in Figure 17-1.

Figure 17-1. Device file naming convention.


The first letter of the device file name is “c”followed by a digit that represents an instance number. This part showsthe interface card and the instance number assigned to that card.Instance numbers are automatically assigned by the kernel and can belisted using theioscan command as explained earlier in this chapter.

The character “t”is followed by the SCSI target address. The target address shows thedevice number on the SCSI bus. These target addresses may be from 0 to6 for single-ended or differential SCSI adapters, and from 0 to 15(excluding 7) for Fast/Wide SCSI adapters. Usually target addresses areset through dipswitches or jumpers on the devices. For example, you canset a particular address for a disk by selecting a jumper settingbefore it is connected to the SCSI adapter. All target addresses for aparticular SCSI adapter must be unique.

The device number or logical unit number (LUN) is represented by “d#”. It is usually the number 0.

Afterthat, there may be other optional device-dependent information. Thispart may or may not be present in the device name depending on the typeof the device.

As an example, we consider a device namec0t1d0.It shows that the SCSI adapter to which the device is attached has aninstance number of 0. The device target ID is 1, and it has a logicalunit number 0.

Disk Naming

Every disk drive has two device files attached to it. The character-type device file is stored in the/dev/rdsk directory and is also called the raw device file. The block-type device file is stored in the/dev/dsk directory.

Forexample, if a disk is attached to an SCSI adapter having instancenumber 2 and a target ID of 4, the character device file for the diskwill be/dev/rdsk/c2t4d0 and the block device file will be/dev/dsk/c2t4d0.

Tape Devices

Thetape devices also follow the same naming convention as used for diskdevices. However, depending on the type of tape cartridge and itsformat, a number of other optional features are also included in thedevice name. Consider the output ofioscan -funC tape command.

Class I  H/W Path Driver  S/W State H/W Type  Description
=========================================================
tape 1 10/8.1.0 stape CLAIMED DEVICE QUANTUM DLT
/dev/rmt/1m /dev/rmt/c4t1d0BEST
/dev/rmt/1mb /dev/rmt/c4t1d0BESTb
/dev/rmt/1mn /dev/rmt/c4t1d0BESTn
/dev/rmt/1mnb /dev/rmt/c4t1d0BESTnb

This list shows the device names for a tape device. The name/dev/rmt/c4t1d0BESTnbshows that the tape device is attached to an adapter having instancenumber 4. The device target number is 1 and the logical unit number is0. The word “BEST” indicatesthat with this device file, the highest possible capacity format willbe used. This will also include data compression if it is supported bythe device. The character “n” shows that the tape will not be rewound at the end of the operation. The “b” character shows that the tape drive will follow the Berkley style instead of AT&T.

Prior to HP-UX version 10.x, a different naming convention was used for tape devices. The tape device names were, for example,/dev/rmt/0m,/dev/rmt/1m, and so on. In this scheme, an arbitrary number (such as 0 and 1) followed by the letter “m”was used for tape devices. This number was followed by additionalcharacters showing the properties of the device. For example,/dev/rmt/c4t1d0BEST was represented by/dev/rmt/1m, and/dev/rmt/c4t1d0BESTn was represented by/dev/rmt/1mn. This naming convention is still used for backward compatibility. The output of theioscan -funC tape command shows both types of devices.

Options used with tape drive devices are listed in Table 17-2.

Table 17-2. Tape Drive Device File Options
Option Description Density Use one of the four: BEST, NOMOD, DDS, or D. The BEST option uses the highest capacity, including compression. The NOMOD option can be used on DDS and 8-mm devices only, and it maintains the density of previously written data. DDS shows the number of the DDS standard used, i.e., DDS2 or DDS3. The D option followed by a number defines the density of the tape as a numeric value. C Compress. The optional number following C shows the compression algorithm. n No rewind at the end of the operation. b Berkley-style tape behavior. w Wait for the physical completion of the operation before returning the status.

17.4. Listing Installed Devices

The device files associated with the installed devices can be listed using one of thell,ioscan, orlssf commands. Each of these commands lists particular characteristics of device files.

Using the ll Command

Consider this list of files displayed by thell command.

$ ll /dev/rmt/0m*
crw-rw-rw- 2 bin bin 212 0x030000 Oct 28 1997 /dev/rmt/0m
crw-rw-rw- 2 bin bin 212 0x030080 Sep 29 1997 /dev/rmt/0mb
crw-rw-rw- 2 bin bin 212 0x030040 Sep 29 1997 /dev/rmt/0mn
crw-rw-rw- 2 bin bin 212 0x0300c0 Sep 29 1997 /dev/rmt/0mnb
$

Thell command lists the following features of a device file.

  • Type of the file. If the first character of an output line is “c”, it is a character or raw device file. If the first character is “b”, it is a block-type file.

  • The major number of the device file in field 5, which is 212 in this listing.

  • The minor number of the file in field 6.

Using the ioscan Command

Theioscan command has an advantage over thellcommand in that it shows which device is attached to which file. It canalso be used to list device files related to a particular class ofdevices. Output of theioscan -funC disk command is shown here, which displays a list of all device files linked to classdisk.

# ioscan -funC disk
Class I H/W Path Driver S/W State H/W Type Description
===========================================================
disk 16 10/0.1.0 sdisk CLAIMED DEVICE SEAGATE
ST34371W /dev/dsk/c2t1d0 /dev/rdsk/c2t1d0
disk 17 10/0.2.0 sdisk CLAIMED DEVICE SEAGATE
ST34572WC /dev/dsk/c2t2d0 /dev/rdsk/c2t2d0
disk 18 10/0.3.0 sdisk CLAIMED DEVICE SEAGATE
ST34371W /dev/dsk/c2t3d0 /dev/rdsk/c2t3d0
disk 19 10/0.4.0 sdisk CLAIMED DEVICE SEAGATE
ST34371W /dev/dsk/c2t4d0 /dev/rdsk/c2t4d0
disk 20 10/0.5.0 sdisk CLAIMED DEVICE SEAGATE
ST15150W /dev/dsk/c2t5d0 /dev/rdsk/c2t5d0
disk 21 10/0.6.0 sdisk CLAIMED DEVICE SEAGATE
ST15150W /dev/dsk/c2t6d0 /dev/rdsk/c2t6d0
disk 22 10/5.2.0 sdisk CLAIMED DEVICE TOSHIBA CD-
ROM XM-5401TA /dev/dsk/c3t2d0 /dev/rdsk/c3t2d0

Note that CD-ROM is also included in the “disk” class of devices. Similarly, to list all tape devices, you can use theioscan -funC tape command. Theioscan command lists the following device file characteristics.

  • Device class. If you use ioscan without any class option, it lists all devices attached to the system. From the first column of the output, you can find which device is related to which class.

  • Instance number of the device.

  • Hardware path of the device.

  • Kernel driver used for the device.

  • S/W state that shows whether the device driver is attached to the device.

  • Description field that shows what type of device it is.

Using the lssf Command

You have seen that more than one file is attached to a tape device. Thelssf command shows the characteristics of each device file. Consider the output of the following command.

$ lssf /dev/rmt/c4t1d0BESTn
stape card instance 4 SCSI target 1 SCSI LUN 0 at&t no
rewind best density available at address 10/8.1.0 /dev/
rmt/c4t1d0BESTn
$

This output shows additional information thatioscan does not provide. Specifically it shows that:

  • The tape device file uses AT&T-style tape behavior.

  • It will not rewind automatically.

  • It will use the best density available for writing data.

Usable Devices

Theioscan command with the-u option shows only usable devices. The usable devices have the software driver bound to the device.

Study Break

Listing and Naming Device Files

You have seen that a particular naming convention is used with devices attached to an SCSI interface. Use the command ioscan -funC lan to list all network interfaces attached to the system and see if there is any particular naming convention. The lssf command shows additional features of a device file. Go to the /dev/rmt directory where tape device files are stored. Use the lssf command on all of these files and see what characteristics each file has. Consult Table 17-2 to compare these characteristics with the device name.


后续