Solaris Handbook for Sun Peripherals

Chapter 2 Setting Up a Disk Drive

This chapter describes how to configure disk drive devices using the SolarisTM operating environment.

This chapter contains the following information:

Requirements

Before you configure the operating environment for a new disk drive, you must:


Note -

If you did not follow the procedures in "Shut Down the System", the operating system may not recognize the new disk drive.


Disk Drives

Disk drives are common devices to add to a system. There are three major steps involved when adding a disk drive:

The last step may not be necessary if you plan to use special (Redundant Array of Inexpensive Disks) applications such as Veritas Volume Manager or Solstice DiskSuiteTM software to manage the data on the disk.

To Add a Disk Drive
  1. Shut down your system.

    See "Shut Down the System".

  2. Check that the address switch for the disk drive has been correctly set.

    Each SCSI target ID determines the logical device name that the Solaris operating environment assigns to the drive. For more information about SCSI addressing refer to Appendix A, SCSI Addressing" in the appendix and to the System Administration Guide.


    Caution - Caution -

    Each disk drive must have a unique SCSI target ID setting.


  3. Install the disk drive.

    For installation information, refer to the documentation that accompanies your hardware.

  4. Turn the power on to the system and all the peripheral devices.

    In most cases, this will cause the system to boot. If the /reconfigure file is present (as described in "To Prepare the System"" in Chapter 1), then the operating system automatically assigns a logical device name and initializes the appropriate device drivers for the new device. If the /reconfigure file does not exist, you can achieve the same effect by performing a boot -r. See Appendix B, Booting Your System" for more information.

  5. Prepare the disk, if necessary.

    See "Preparing the Disk".

Preparing the Disk

Before the a newly installed disk drive can be used it must be formatted, partitioned and labeled. Use the format utility to perform each of these activities as needed.

The format Utility

The format utility is a menu driven disk maintenance program that is used to format, partition, and label disk drives as well as manage defective sectors. When you start the format utility, it probes your system for disk drives, reads each label on each disk, and displays a disk list. Once you choose a disk to work with, format provides a menu with selectable routines.


Caution - Caution -

Many routines in the format utility will overwrite data on disk drives. Always back up all of your data on all disk drives before using the format utility.


The format utility uses a disk statistic file called /etc/format.dat to determine default disk drive configuration parameters. However, format can automatically configure and label the SCSI disk drives, even if your specific type of drive is not described in the /etc/format.dat file. This lets you format, partition, and label any disk drive compliant with SCSI-2 without having to edit the /etc/format.dat file.

You must be superuser to use the format utility. If you are not superuser, you will see the following error message when you try to use format.


# format
Searching for disk...done
No permission (or no disk found)!

To use the format utility, refer to the following sections of this manual:


Note -

For additional information about the format utility, refer to the System Administration Guide.


Formatting a Disk

When you format a disk you create disk sectors on the media and compile a list of defective sectors. The disk must be formatted before any data can be written on it. In most cases, disks are formatted by the manufacturer or reseller and do not need to be reformatted when you install the drive. To determine whether or not a disk is formatted, as well as to actually format a disk, use the format utility as described here.


Caution - Caution -

Formatting a disk is destructive to data that might be on the disk.



Note -

Not all menu information appears exactly as shown. If you have a SPARCstorage Array you must load the SPARCstorageTM Array drivers before using the format utility.


  1. Become superuser.

  2. Start the format utility.

    # format

    If the disks are already labeled, the system displays information similar to the following:


    Searching for disks...done
    AVAILABLE DISK SELECTIONS:
    	0.		c0t3d0 <SUN0207 cyl  1214 alt 2 hd 9 sec 36>
    			/sbus@1,f8000000/esp@0,8000000/sd@3,0
    	1.		c0t0d0 <SUN0207 cyl  1214 alt 2 hd 9 sec 36>
    			/sbus@1,f8000000/esp@0,8000000/sd@0,0
    	2.		c1t1d0 <SUN0207 cyl  1214 alt 2 hd 9 sec 36>
    			/sbus@1,f8000000/esp@0,8000000/sd@1,0
    	3.		c1t2d0 <SUN0207 cyl  1214 alt 2 hd 9 sec 36>
    			/sbus@1,f8000000/esp@0,8000000/sd@2,0
    Specify disk (enter its number):2
    

    In the above example:

    • Disk drives 2 (c1t1d0) and 3 (c1t2d0) are newly installed disk drives.

    • 2 is specified as the disk to work with at this time.

    After you format the first new disk, format the second new disk the same way.

  3. Select the disk that you want to format from the list displayed on your screen.


    Caution - Caution -

    Make sure that you choose the correct disk. If you choose a disk that has data on it, that data will be overwritten.


    The format utility will display a message indicating whether the disk is formatted or not:


    Selecting c1t1d0
    [disk formatted]
    

    If your disk is not formatted, proceed to the Step 4. If your disk is formatted, proceed to the "To Partition a Disk" procedure later in this chapter.


    Caution - Caution -

    If you see the following message: Warning: Current Disk has mounted partitions.Do not proceed. Type q to exit the format utility. Go back to Step 2 and make sure that you are selecting the correct disk drive.


  4. At the format> prompt, type format, and confirm the command by typing y.


    format> format
     
    Ready to format. Formatting cannot be interrupted.
    Continue? y
    Beginning format. The current time is Fri Sept 11 14:56:51
    1993
    Formatting ...
    done
     
    Verifying media ...
    pass 0 - pattern = 0xc6dec6de
    pass 1 - pattern = 0x6db6db6d
    total of 0 defective blocks repaired.
    format>
    

    Format performs two operations:

    • It formats the disk to write the sectors on the medium.

    • It runs two verification passes to analyze the disk for possible defects and compiles a list of defective sectors for non-use.

    It is not possible to predict how long formatting will take because it depends on may variables such as the size of the disk, your CPU and amount of memory, as well as other system activity. Times range from one minute to more than an hour.


    Caution - Caution -

    Do not interrupt the formatting of a disk drive. An interruption at a critical moment could cause disk corruption.


To Partition a Disk

Partitioning a disk involves dividing a disk into subsections called partitions or slices. Each individual partition appears to the operating system (and to the system administrator) as though it were a separate disk drive. File systems, swap partitions, and databases are created on partitions.

There are eight possible partitions represented by numbers 0 through 7. However, partition 2 is reserved as a single partition that always represents the entire disk drive. You can configure a disk with as many as seven individual partitions (numbered 0, 1, 3, 4, 5, 6, and 7 with partition 2 for the whole drive), or with as few as one single partition, or any combination between. How you choose to partition your disk depends on the plans that you have for your new disk. Consider how much data will be installed in a given partition, the rate that data will increase, and plan to have approximately 10% as free space that will never be used (there are exceptions to the 10% free space rule, see the System Administration Guide for more details).

Sometimes the manufacturer creates default partitions on the disk. However, due to the wide variety of storage space needs, the default partitions on the disk may not suit your needs. If this is the case, now is the time to re-partition the disk.


Caution - Caution -

Partitioning a disk is destructive to data that might be on the disk.


  1. Become superuser and start the format utility.

  2. Type partition at the format prompt.

    The following menu is displayed:


    format> partition
    PARTITION MENU:
            0      - change `0' partition
            1      - change `1' partition
            2      - change `2' partition
            3      - change `3' partition
            4      - change `4' partition
            5      - change `5' partition
            6      - change `6' partition
            7      - change `7' partition
            select - select a predefined table
            modify - modify a predefined partition table
            name   - name the current table
            print  - display the current table
            label  - write partition map and label to the disk
            !<cmd> - execute <cmd>, then return
            quit
    partition> 
    

  3. Type modify.

    The following menu is displayed.


    Select partitioning base:
     0. Default partition for selected drive
     1. Current partition table (original sd3)
     2. All Free Hog
    Choose base (enter number) [0]? 2
    


    Note -

    Not all menu information appears exactly as shown. For disk drives greater than 2.1-Gbytes there is no default partitioning table available.


  4. Select the number that corresponds to "All Free Hog" (2 in this example).

    By choosing All Free Hog you will start the partitioning session with a blank partition table. All partition values (except partition 2) will be set to zero. This way no pre-existing partition values will interfere with your new partition values.

    Once you have selected your partitioning base, the following table is displayed:


    Part      Tag    Flag      Cylinders      Size        Blocks
    0        -      -          0              0         (0/0/0)
    1        -      -          0              0         (00/0/0)
    2        -      -          0 - 1253       198.39MB  (1254/0/0)
    3        -      -          0              0         (0/0/0)
    4        -      -          0              0         (0/0/0)
    5        -      -          0              0         (0/0/0)
    6        -      -          0              0         (0/0/0)
    7        -      -          0              0         (0/0/0)
    

    These are your current partition table values. Partition 2 values represent the entire disk drive. Never attempt to change partition 2 values. In fact, this modify routine will not allow it.

  5. Type y to continue:


    Do you wish to continue creating a new partition
    table based on above table[yes]? y
    

  6. Select one of the seven partitions as a free hog partition:


    Free Hog partition[6]? 6
    

    When you use the format utility to change the size of one or more disk partitions, you must designate a temporary partition, the free hog, that can expand and shrink to accommodate resizing. This partition frees space when you expand a partition, and receives or hogs the discarded space when you shrink a partition. By the end of the modify session, the designated free hog partition must have space left in it and this partition will be a valid partition on your disk.

    However, the free hog designation exists only during a given partitioning session. There is no permanent free hog partition during day-to-day operations.

    Partition 6 is used in this example. Do not specify partition 2 as the free hog.

  7. Specify the size of each partition in megabytes by changing any of the displayed sizes.

    You are asked to specify the size of each partition. Type 0 to assign zero space to any unwanted partitions. Type a size followed by mb (for megabytes) for all desired partitions. You will not be asked for a size for partition 2 nor for the free hog partition (6 in this example).


    Enter size of partition `0`  [0b, 0c, 0.00mb]: 0
    Enter size of partition `1`  [0b, 0c, 0.00mb]: 0
    Enter size of partition `3`  [0b, 0c, 0.00mb]: 0
    Enter size of partition `4`  [0b, 0c, 0.00mb]: 0
    Enter size of partition `5`  [0b, 0c, 0.00mb]: 0
    Enter size of partition `7`  [0b, 0c, 0.00mb]: 80mb
    

    The sizes have been changed as displayed:


    Part      Tag    Flag      Cylinders      Size        Blocks
    0        -      -          0              0         (0/0/0)
    1        -      -          0              0         (00/0/0)
    2        -      -          0 - 1253       198.39MB  (1254/0/0)
    3        -      -          0              0         (0/0/0)
    4        -      -          0              0         (0/0/0)
    5        -      -          0              0         (0/0/0)
    6        -      -        0 - 747        118.34MB    (748/0/0)
    7        -      -        748 - 1253     80.05MB     (506/0/0)
    

    In this example, the disk is set up to have two individual partitions; 6 and 7. Partition 2 is a special partition that represents the entire disk, sometimes referred to as the overlap partition.


    Caution - Caution -

    Do not change partition 2. Reducing the size of partition 2 decreases available disk space.


  8. Type y to confirm:


    Okay to make this the current partition table [yes]? y
    

  9. Type a name for the new partition table:


    Enter table name (remember quotes): "table1"
    

    This name is a temporary name used by the format utility to keep track of partition tables as they are created.

  10. Type y to write the new partition table to the disk label:


    Ready to label disk, continue? y
    

    The label is where the partition table is stored. If you type n for no, you will lose the partition values that you just assigned and the previous partition table will remain in effect.

  11. Type q to quit the partition routine, and another q to quit the format utility.


    partition> q
       .
       .
       .
    format> q
    

To Label a Disk

Labeling a disk involves using the format utility to write information to a special reserved area on a disk. This information is referred to as a disk label or VTOC (Volume Table of Contents). Each disk must have a disk label for the operating system to be able to use the disk.

A disk label contains two key pieces of information:

A label is often created by the manufacturer, so you usually only need to label a disk when you change the partition information. If you use the modify routine as described in" "To Partition a Disk"", you will be asked to label your disk and you do not need to perform the steps listed in this section.

If the Solaris operating envronment is unable to find a valid label on a drive, (as shown for c1t2d0 below) the system displays information similar to the following:


# format
Searching for disks...done

c1t2d0:  configured with capacity of 198 MB
AVAILABLE DISK SELECTIONS:
	0.		c0t3d0 <SUN0207 cyl  1214 alt 2 hd 9 sec 36>
			/sbus@1,f8000000/esp@0,8000000/sd@3,0
	1.		c0t0d0 <SUN0207 cyl  1214 alt 2 hd 9 sec 36>
			/sbus@1,f8000000/esp@0,8000000/sd@0,0
	2.		c1t1d0 <SUN0207 cyl  1214 alt 2 hd 9 sec 36>
			/sbus@1,f8000000/esp@0,8000000/sd@1,0
	3.		c1t2d0 <Unable to read disk label>
			/sbus@1,f8000000/esp@0,8000000/sd@2,0
Specify disk (enter its number):3
 
Selecting c1t2d0
[disk formatted]
Disk not labeled. Label it now? y

The configured with capacity message and the Label it now? prompt are displayed for a disk without a valid label or for a new, unlabeled disk.

  1. Type y to label the disk:


    Disk not labeled. Label it now? y
    

Creating and Mounting File Systems

You need to create a file system for a partition when you have:

You must know the logical device name of the disk drive and partition for which you want to create a file system. Refer to Appendix A, SCSI Addressing" for more information on logical device names.


Note -

The disk for which you plan to create a file system must already be formatted and partitioned.


To Create a File System
  1. Become superuser.

  2. Use the newfs command to create a new file system on a partition:


    # newfs /dev/rdsk/cntndnsn
    


    Caution - Caution -

    Make sure that you have specified the correct logical device name before you create a new file system. If you specify the wrong logical device name you will render the data on that partition inaccessible. See "Logical Device Names" for details.


  3. Type y to confirm:


    newfs: construct a new file system /dev/rdsk/cx
    txdx
    sx (y/n)? y
    

    Newfs creates the necessary file system structures and a lost+found directory on the disk partition. Repeat these steps for each partition that will be used to contain a file system. Only one file system can be created per partition.

To Mount a File System

Once you have created a file system, you need to make it available to others by mounting it. A mounted file system is attached to the system directory tree at the specified mount point (a directory), and becomes available to the system and users. The root file system is always mounted. Any other file system can be connected (mounted) or disconnected (unmounted) from the root (/) file system.

To mount a file system, follow these steps:

  1. Edit the /etc/vfstab file with vi or any text editor.

    1. Add the entry by separating each field with a space or a tab. If a field has no value, enter a dash (-) as a field placeholder. There are seven fields and each field must have an entry.


      #device      device       mount        FS   fsck    mount
        mount
      #to mount    to fsck      point        type pass    at
      boot options
      #
      #/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr  ufs  1      yes
          -
      fd      -       /dev/fd fd      -       no      -
      /proc   -       /proc   proc    -       no      -
      /dev/dsk/c0t0d0s1       -       -       swap    -    no
           -
      /dev/dsk/c0t0d0s0    /dev/rdsk/c0t0d0s0      /   ufs  
        1 no -
      swap    -       /tmp   tmpfs   -       yes     -
      /dev/dsk/c0t1d0s6  /dev/rdsk/c0t1d0s6   /abc   ufs   2    yes     -
      /dev/dsk/c0t1d0s7  /dev/rdsk/c0t1d0s7   /def   ufs   2    yes     -
      


      Caution - Caution -

      Be careful when editing this system configuration file. The field columns do not line up. It is very easy to make a mistake. The system reads this file at boot time and when mount and fsck commands are run. If an error resides in this file, these commands may fail, leaving the system in an undesirable state.


      In this example, the bottom two lines were added, one line for each new file system. Each field was entered based on the following field information:

      Table 2-1 fields/etc/vfstab

      Field  

      Field Heading 

      Description 

      device to mount

      Specify the logical device name for the file system that will be mounted, usually from the /dev/dsk directory.

      device to fsck

      Specify the logical device name of the device that fsck runs on, usually from the /dev/rdsk directory.

      mount point

      Specify the directory to use as the file system mount point. 

      FS type

      Specify the file system type, usually ufs for local file systems.

      fsck pass

      Specify a number that controls the way that fsck runs:

      1=run fsck one file system at a time, in the order listed.

      2=run fsck simultaneously on file systems.-=do not run fsck

      mount at boot

      Specify yes or no. yes=this file system should be mounted at boot time and with the mountall command. no= this file system should not be mounted at boot time nor with the mountall command.

      mount options

      Specify mount options separated by a comma but no whitespace, or place a dash (-) in this field for no options.

    2. Save the /etc/vfstab file with the modifications.


    Note -

    For more information about writing entries in the /etc/vfstab file, see man Pages(4): File Formats and the System Administration Guide.


  2. Create the directories that you want to use as mount points:


    # mkdir  /abc  /def
    

    The mount point directory must be created prior to mounting a file system. Two mount points (directories) are created for this example.

  3. Type:


    # mount /abc /def
    

    The mount command will read the /etc/vfstab entries for these file systems and mount them accordingly. Also, each time you boot the system the /etc/vfstab file is read and all appropriate file systems, including the new ones, will be mounted.


    Note -

    Be sure not to mount any partition that you intend to use as swap space or as an unmounted partition.


  4. Use the df command to see all file systems that are mounted:


    # df -k
    Filesystem            kbytes    used   avail capacity 
    Mounted on
    /dev/dsk/c0t0d0s0    1759982  779007  975109    45%    /
    /proc                      0       0       0     0%   
    /proc
    fd                         0       0       0     0%   
    /dev/fd
    swap                  217808     384  217424     1%   
    /tmp
    /dev/dsk/c0t1d0s6     118344	       4  118340	     0% 
      /abc
    /dev/dsk/c0t1d0s7      80059	       4   80055     0%  
     /def
    

  1. To unmount a file system use the umount command:


    # umount /abc
    

    You must be superuser to mount and unmount file systems.

    The operating system will not permit you to unmount the / or /usr file systems.

    If your current working directory is in the file system that you wish to unmount, you must change (cd) to another directory or the system will report device is busy.