Solaris Handbook for Sun Peripherals

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