Adding a Disk or Tape

Basic Hardware Informaiton

We will limit this discussion to devices that use the Small Computer System Interconnect (SCSI) interface. A SCSi controller is standard on all Unix systems sold today and is the most commonly found type of device controller on Unix. Usually a SCSI controller will support 6 devices. However, this can be liited by the total length of the SCSI cabling. It is best to use the shortest cable possible when connecting SCSI disks. The other option it to purchase a disk enclosure that supports multiple disk drives.

SCSI is made up of a number of different standards, such as:

For an in depth discussion of all of these issues you can look at an summary of the the Usenet comp.periphs.scsi frequently answered question list. This list explains each type of SCSI type listed above. The key points to understand is that there are different types of SCSI interfaces, while they can usually interoperate, you may need special cables or suffer a loss of performance. For example, spending extra money on a FAST/WIDE SCSI disk when your controller does not support this is foolish.

As a system administrator you need to know the following things before hooking up a SCSI device.

Knowing that information you can order the correct cable and set the SCSI ID on the device to an unused number.

Unix System View of Devices

Remember that Unix considers all devices as files. We discussed this when we reviewed the file system earlier in the semester. Unix treats devices as a special form of file named either a block or character oriented special files. Character special files are used by devices such as terminal lines and parallel ports. Block special files are used by disk and tape devices. However, as we will see later Unix creates both types of special files for accessing disks.

Under Unix, a disk can be sperated into logical disks called partitions. Partitions seperate file systems from one another. A file system cannot "cross-over" and use up space on another partition without explicit action on the partof the system administrator. Partitioning was developed as a way of seperating user and system files. Since users will use every byte of space made available this can cause problems on a Unix system when the root area shares space with a user area. To solve this problem partitions were developed whereby the disk is carved up and portions are allocated to each file system.

From the perspective of the system each partition will seem to be it's own disk device. BSD and SV5 use different naming constructs but generally set up similar constructs. On BSD based systems partitions are designated with letters going from a to g . On SV5 based systems partitions are designated using s0 to s10. We will discuss this more later.

All special files are stored under the /dev directory. Under BSD-based systems all files reside in this directory. Under SV5-based systems we have a sub-directory heirarchy where disk and tape devices are stored under a sub-directory. Disk are stored in the /dev/dsk sub-directory. Where these devices are placed is of little consequence.

Each device is assigned a major and minor number. This can be seen when the device is listed using the ls -l command.

Below is a an example from a SGI (SV5) system

umbc7> ls -l dks0d1*
brw-------   2 root     sys       22, 32 Feb  4 10:59 dks0d1s0
brw-r-----   2 root     sys       22, 33 Feb 13 12:04 dks0d1s1
brw-------   2 root     sys       22, 38 Feb  4 10:59 dks0d1s6
brw-------   1 root     sys       22, 39 Feb  4 10:59 dks0d1s7
brw-------   2 root     sys       22, 40 Feb  4 10:59 dks0d1vh
brw-------   1 root     sys       22, 42 Feb  4 10:59 dks0d1vol

Below is an example from a Ultrix (BSD) system

umbc4> ls -l /dev/rz0*
brw-------  1 root      21,   0 Jun  8  1993 /dev/rz0a
brw-------  1 root      21,   1 May 26  1993 /dev/rz0b
brw-------  1 root      21,   2 May 26  1993 /dev/rz0c
brw-------  1 root      21,   3 May 26  1993 /dev/rz0d
brw-------  1 root      21,   4 May 26  1993 /dev/rz0e
brw-------  1 root      21,   5 May 26  1993 /dev/rz0f
brw-------  1 root      21,   6 Jun 30  1993 /dev/rz0g
brw-------  1 root      21,   7 May 26  1993 /dev/rz0h

As you can see in the listing above, in place of the size field the "ls" command returns two integers. In the SGI example above, 22 is the major number of that device. On the SGI system shown above, 22 represents the device id for a SCSI disk. On the BSD example, the major number is 21 with the minor number varying.

All SCSI disks on the system will have the same major number. The minor number is unique on the system for each drive and each drive partition (we will explain this in the next section). The minor number determines which disk/partition you wish to use on your system.

Naming constructs for disks

System V

In the list above for the SGI system we see that the name of a disk has the name dks0d1s0. This can be broken up into it's components:

From the listing above we see that on the SGI system that for device 1 we have devices dks0d1s0, dks0d1s1,dks0d1s6,dks0d1s7, dks0d1vh, and dks0d1vol. These are the default devices shipped with each kernel. By default they correspond to the following:

In generally it is best to adhere to the idea of only using partitions s0, s1, and s6 for what they are designated for. However, partition s7 will often be re-defined so as to use just a portion of the disk. On our systems we often use partition s7 as a seperate /tmp file system. Other sites rigidily adhere to the standards above and create new partitions (a.k.a. devices) for things like /tmp. Partitions s2,s3,and s4 are available for for use once the device is created.

Making a new Device

In the /dev directory is a file name MAKEDEV. The MAKEDEV script is used to create the standard devices. Thus if you add a new disk you can use MAKEDEV to create the standard partitions. To create non-standard partitions you must use the command mknod or modify the MAKEDEV script to create additional device files other than the standard. Usually, it is not difficult to find the place in the MAKEDEV script you need to change. It is generally a for loop that looks like this:
       umask 77; while [ $$ctlr -lt $$scsictlr ] ; do \
                for targ in 1 2 3 4 5 6 7; do \
                    for i in 0 1 6 7; do \
                        minor=`expr $$i + $$targ \* 32`; \
                        mknod dsk/dks$${ctlr}d$${targ}s$$i b $$1 $$minor; \
                        mknod rdsk/dks$${ctlr}d$${targ}s$$i c $$2 $$minor; \
                    done; \
The second for loop creates the default partitons. Modifying that to be
                    for i in 0 1 2 6 7; do \
would create a s2 partition on each device you create.

In order to use the mknod command you need to understand how the system you use assigns the minor number id. The best way to do this is to read the MAKEDEV shell script and see the formula it uses. On SGI systems the formula is the (drive number*32)+partition number. Thus to create a partition S2 on drive number 1 the minor number would be (1 * 32)+ 2 or 34. Once you know the minor number you can get the major number from the full ls -l listing of similar devices. With that information we can create a device file for partition s2 with the commands:

mknod /dev/dsk/dks0d1s2 b 22 34

and mknod /dev/rdsk/dks0d1s2 c 22 34

Disk have both a block and character interface, as such we must create both the block and charcter devices.

Other things to do

For the test look at chapter 12 in the book on adding disks. Other things yet to be discussed in the notes are: