[ Team LiB ] Previous Section Next Section

Administering Disks

The following sections describe the Solaris disk-naming conventions, commands for finding disk information (du, prtvtoc), and ways to repair or replace a bad disk.

Disk-Naming Conventions

Solaris disks have both block and raw (character) device files. The device name is the same, regardless of whether the command requires the block or raw device file.

Each type of device file has its own subdirectory in /dev: /dev/dsk (the block interface) or /dev/rdsk (the raw interface).

Some commands, such as mount, use the block interface device name from the /dev/dsk directory to specify the disk device. Other commands, such as newfs, require the raw interface device name from the /dev/rdsk directory to specify the disk device.

graphics/new.gif

Raw device interfaces transfer only small amounts of data at a time. To use a raw device, you specify the device in the /dev/rdsk subdirectory. The r in rdisk stands for raw.

graphics/new.gif

Block device interfaces include a buffer from which large blocks of data are read at one time. When a command requires the block device interface, you specify the /dev/dsk subdirectory.

The device name you use to identify a specific disk with either type of interface depends on the controller type: bus-oriented (SCSI) or direct. You refer to a disk device by specifying the subdirectory to which it is symbolically linked (either /dev/dsk or /dev/rdsk) followed by a string identifying the particular controller, disk, and slice.


/dev/[r]dsk/cwtxdysz

cw is the controller number, tx is the target number, dy is the drive number, and sz is the slice identifier. For SCSI drives, the drive number is the equivalent of the Logical Unit Number (LUN) of the drive.

Table 69 shows which interface to use for a few frequently used disk and file system commands.

Table 69. Device Interface Type for Some Frequently Used Commands

Command

Interface Type

Example

df(1M)

Block

df /dev/dsk/c0t1d0s0

fsck

Raw

fsck -p /dev/rdsk/c0t0d0s0

mount(1M)

Block

mount /dev/dsk/c1t0d0s7 /export/home

newfs(1M)

Raw

newfs /dev/rdsk/c0t0d1s1

prtvtoc(1M)

Raw

prtvtoc /dev/rdsk/c0t0d0s2

Using Disks with Bus Controllers

Figure 15 shows the device-naming convention for SPARC disks with bus controllers.

Figure 15. Naming Conventions for SPARC Disks with Bus Controllers

graphics/08fig14.gif

Figure 16 shows naming conventions for IA disks with SCSI controllers.

Figure 16. Naming Conventions for IA Disks with Bus Controllers

graphics/08fig15.gif

Each file system on a disk is assigned to a slice—a group of cylinders set aside for use by that file system. To specify a slice (partition) on a disk with a bus controller (either SCSI or IPI), use a device name with these conventions: /dev/dsk/cWtXdYsZ (the block interface) or /dev/rdsk/cWtXdYsZ (the raw interface).

NOTE. Solaris disk device names use the term slice (and the letter s in the device name) to refer to the slice number. Slice is simply another name for a disk partition.


Use the following guidelines to determine the values for the device file name.

  • If you have only one controller on your system, W is always 0.

  • For SCSI controllers, X is the target address set by the switch on the back of or inside the unit.

  • Y is the Logical Unit Number (LUN) of the drive attached to the target. If the disk has an embedded controller, Y is always 0.

  • Z is the slice (partition) number, with a value ranging from 0 to 7. Slice 2 is known as the backup slice and should never be used directly. Table 70 shows conventional assignments of slice (partition) numbers for the disk on which root is found.

Table 70. Conventional Assignments of Slices for Boot Disk

Slice

File

System Use

0

root

Operating system.

1

swap

Virtual memory space.

2

-

Entire disk.

3–5

 

Available for use according to your administrative policy.

6

/usr

Executable programs, program libraries, and documentation.

Table 71 shows some examples of raw device names for disks with bus-oriented controllers.

Table 71. Examples of Device Names for Disks with Bus-Oriented Controllers

Device Name

Description

/dev/rdsk/c0t0d0s0

Raw interface to the first slice (root) on the first LUN (disk) at the first SCSI target address on the first controller.

/dev/rdsk/c0t0d0s2

Raw interface to the third LUN (which represents the whole disk) on the first disk at the first SCSI target address on the first controller.

/dev/rdsk/c0t1d0s6

Raw interface to seventh (/usr) slice on the first LUN (disk) at the second SCSI target address on the first controller.

NOTE. In releases before the Solaris 7 Operating Environment, SCSI support on the Intel platform was handled by the cmdk driver. Starting with the Solaris 7 release, this support is handled by the sd driver. This driver is similar to the SCSI disk driver on Solaris SPARC platforms, which is also named sd.

There is no change in the administration of these devices. You will see references to sd instead of cmdk in the output of the prtconf, sysdef, dmesg, and format commands.

Features and functionality are a superset of the features supplied by cmdk, so applications that use logical disk names in /dev/dsk are not affected by the driver change. IA systems with IDE devices still use the cmdk driver.


Using Disks with Direct Controllers

Disks with direct controllers do not have a target entry as part of the device name. To specify a slice (partition) on a disk with a direct controller, use a device name with the following conventions: /dev/dsk/cXdYsZ (the block interface) or /dev/rdsk/cXdY s Z (the raw interface).

Figure 17 shows the naming convention for SPARC-based disks with direct controllers. If you have only one controller on your system, X is always 0. Slice 2 is a guide to the size of the entire disk.

Figure 17. Naming Conventions for SPARC-Based Disks with Direct Controllers

graphics/08fig16.gif

Figure 18 shows the naming convention for IA-based disks with direct controllers.

Figure 18. Naming Conventions for IA-Based Disks with Direct Controllers

graphics/08fig17.gif

Use slice 2 (s2) to specify the entire Solaris fdisk partition.

Setting Up Disk Slices

Files are stored within file systems. Each disk slice is treated as a separate disk drive both by the operating system and by the system administrator. When setting up slices, be aware of the following constraints.

  • Any disk slice can have a file system written on it.

  • No file system can span multiple slices.

You set up slices differently on SPARC and IA platforms, as described in Table 72.

Table 72. Slice Differences on Platforms

SPARC Platform

IA Platform

Entire disk is used for Solaris environment.

Disk is divided into fdisk partitions, one per operating environment.

Disk is divided into eight slices, numbered 0–7.

The Solaris fdisk partition is divided into 10 slices, numbered 0–9.

SPARC Disk Slices

graphics/new.gif

For SPARC-based systems, Sun recommends that you define only three disk slices, root (/), swap, and the backup slice (slice 2). Table 73 describes additional slice conventions that you can use if you choose.

Table 73. SPARC Disk Slice Conventions

Slice

File System

Client/Server

Description

0

root

Both

Hold files and directories that make up the operating system.

1

swap

Both

Provide virtual memory or swap space.

2

 

Both

By convention, refer to the entire disk. The entire disk is defined automatically by the format command and the Solaris installation programs. Do not change the size of this slice.

5

/opt

Both

Hold applications software added to a system. If a slice is not allocated for this file system during installation, the /opt directory is merged into the slice that contains the root (/) file system.

6

/usr

Both

Hold operating system commands—also known as executables—designed to be run by users. This slice also holds documentation, system programs such as init and syslogd, and library routines. If a slice is not allocated for this file system during installation, the /usr directory is merged into the slice that contains the root (/) file system.

graphics/new.gif

NOTE. There is no longer a conventional use for slices 3 and 4.


IA Disk Slices

On IA-based systems, you divide disks into fdisk partitions. Each fdisk partition is a section of the disk reserved for a particular operating environment. For a Solaris fdisk partition, you can define 10 slices, numbered from 0 through 9 and assign each to a conventional use. The uses for slices 0–2 and 5–7 are the same as on Solaris systems, described in Table 73. Table 74 describes slices 8 and 9.

Table 74. IA Conventions for Slices 8 and 9

Slice

File System

Client/Server

Description

8

Both

Contain the boot slice information at the beginning of the Solaris partition that enables Solaris to boot from the hard disk.

9

Both

Provide an area reserved for alternative disk blocks. Slice 9 is known as the alternative sector slice.

Determining Which Slices to Use

When you set up file systems for a disk, you choose not only the size of each slice but also which slices to use. Your decisions depend on the configuration of the system and the software you want to install on the disk. System types are defined by how they access the root (/) and /usr file systems, including the swap area. For example, stand-alone and server systems mount these file systems from a local disk; other clients mount the file system remotely.

In previous releases, you could set up the following five system configurations.

  • Servers.

  • Diskless clients.

  • Stand-alone systems.

  • Dataless clients.

  • Solstice AutoClient systems.

With the Solaris 8 release, the system configurations are simplified to servers, stand-alone systems, and JavaStations. The JavaStation is a client designed for zero administration. It optimizes Java technology and takes full advantage of the network to deliver everything from Java applications and services to complete, integrated system and network management. You do no local administration for a JavaStation. The server handles booting, administration, and data storage.

Table 75 summarizes the three system types.

Table 75. System Configurations and Slice Requirements

System Type

Local File Systems

Local Swap

Remote File Systems

Network Use

Server

root (/)

Yes

None

High

 

/usr

   
 

/home

   
 

/opt

   
 

/export/home

   
 

/export/root

   

Stand-alone

root(/)

Yes

None

Low

 

/usr

   
 

/export/home

   

JavaStation

None

No

/home

High

Disks and SMC

graphics/new.gif

SMC provides two tools in the Storage category, described in Table 76, that you can use to display and format disks.

Table 76. SMC Disks Tools in the Storage Category

Tool

Description

Disks

Display disk information, display partition information, partition disks, copy disk layouts from one disk to a disk of the same size and manufacturer, create fdisk partitions, and change the active fdisk partition on an IA computer.

Enhanced Storage

Create and manage RAID0 volumes, including stripes and concatenation; RAID1 volumes, including mirrors; RAID5 volumes; soft partitions; hot spare pools; disksets; and the state configuration database (the metadb). New in SMC 2.1.

Disk Use Check (du)

To find the number of 512-byte disk blocks used per file or directory, type du and press Return. When directories contain subdirectories, the subdirectories and their contents are included in the block count, as shown in the following example.


oak% du
2913     ./3.0templates
639      ./Art
347      ./Howto
1998     ./Clipart
607      ./Newtemplates
38       ./Modemstuff
2004     ./Config/Art
6593     ./Config
13280    .
oak%

The output is displayed in 512-byte blocks. To convert to megabytes, divide by 2048. In the preceding example, 13280/2048 = 6.48 Mbytes.

graphics/new.gif

Starting with the Solaris 9 release, the du command has an -h option that you can use to display the output in a user-friendly format, as shown in the following example.


mopoke% du -h
   2K   ./.dt/sessionlogs
   1K   ./.dt/types/fp_dynamic
   2K   ./.dt/types
   1K   ./.dt/icons
   1K   ./.dt/appmanager
  19K   ./.dt/help/winsor-mopoke-0
  20K   ./.dt/help
  11K   ./.dt/sessions/current
  17K   ./.dt/sessions
   1K   ./.dt/tmp
   1K   ./.dt/Trash
   1K   ./.dt/Desktop
   1K   ./.dt/palettes
   2K   ./.dt/.Printers
  56K   ./.dt
   1K   ./.java/.userPrefs
   2K   ./.java
   2K   ./.solregis
  17K   ./.netscape/cache
   1K   ./.netscape/archive
   1K   ./.netscape/xover-cache/host-news
   2K   ./.netscape/xover-cache
 331K   ./.netscape
   1K   ./nsmail
 1.1G   .
mopoke%



Disk Information Check (prtvtoc)

Use the prtvtoc (print volume table of contents) command to display information about disk partitioning. If you use the standard slice-naming conventions, specifying slice 2 displays the contents of the entire disk.

Use the following steps to display information about disk partitioning.

  1. Become superuser.

  2. Type prtvtoc /dev/rdsk/ cntndnsn and press Return.

    Information for the disk you specify is displayed, as shown in the following example.


paperbark% su
Password:
# prtvtoc /dev/rdsk/c0t0d0s2
* /dev/rdsk/c0t0d0s2 partition map
*
* Dimensions:
*     512 bytes/sector
*      80 sectors/track
*      19 tracks/cylinder
*    1520 sectors/cylinder
*    3500 cylinders
*    2733 accessible cylinders
*
* Flags:
*   1: unmountable
*  10: read-only
*
*                          First     Sector      Last
* Partition Tag Flags      Sector     Count      Sector  Mount Directory
       0     2   00      1048800   2865200     3913999   /
       1     3   01            0   1048800     1048799
       2     5   00            0   4154160     4154159
       7     8   00      3914000    240160     4154159   /export/home



Bad-Disk Repair

The following sections describe the steps for repairing a bad disk or reinstalling a new one.

Try Archiving the Files

If you can access the drive, do a ufsdump of all the file systems on the disk. See "Backing Up and Restoring File Systems" on page 211 for information on how to use the ufsdump command.

Try Copying Data from the Disk

If you cannot run ufsdump on the disk, find another disk of the same type, connect it to the system, and use either the dd or volcopy commands to copy the data from the bad disk. See the dd(1M) and volcopy(1M) manual pages for complete information on how to use these commands.

The dd command makes a literal (block) copy of a complete UFS file system to another file system or to a tape. By default, the dd command copies its standard input to its standard output.

NOTE. Do not use the dd command with variable-length tape drives.


You can specify a device name in place of the standard input, the standard output, or both. The following example copies contents of a diskette to a file in the /tmp directory.


oak% dd < /floppy/floppy0 > /tmp/output.file
2400+0 records in
2400+0 records out
oak%

The dd command reports on the number of blocks it reads and writes. The number after the + is a count of the partial blocks that were copied.

The dd command syntax is different from most other commands. You specify options as keyword=value pairs, where keyword is the option you want to set and value is the argument for that option. For example, you can replace the standard input and output with the following syntax.


dd if=input-file of=output-file

The following example uses the keyword=value pairs instead of the redirect symbols in the previous example.


oak% dd if=/floppy/floppy0 of=/tmp/output.file

Use the following steps to clone a disk with the dd command.

  1. Make sure the source and destination disks have the same geometry.

  2. Become superuser.

  3. On the system with the master disk, type touch /reconfigure and press Return.

    The /reconfigure file is required on the system with the master disk so that it recognizes the clone disk once it is rebooted.

  4. Type init 0 and press Return to shut down the system.

  5. Attach the clone disk to the system and turn on the system.

  6. At the ok prompt, type boot and press Return.

  7. All on one line, type dd if=/dev/dsk/ device-name of=/dev/dsk/ device-name bs= blocksize and press Return.

    The input file, if, is the master disk device. The output file, of, is the clone disk device.

  8. Type fsck /dev/rdsk/ device-name and press Return to check the new file system.

  9. Type mount /dev/rdsk/ device-name /mnt and press Return to mount the clone disk's root file system.

  10. Edit the /etc/vfstab file on the clone disk to reference the correct device names.

  11. Type umount /mnt and press Return to unmount the clone disk's root file system.

  12. Type init 0 and press Return to shut down the system.

  13. Type boot disk n -s and press Return to boot the clone disk in single-user mode.

    The OpenBoot PROM creates certain well-known disk aliases for disks it expects to be attached to a system. And, the system administrator may have created additional disk aliases when attaching extra disks to a system. Use the appropriate alias for the cloned disk as the disk n argument.

  14. Type sys-unconfig and press Return to unconfigure the clone disk.

    The system is shut down after the disk is unconfigured.

  15. Type boot disk n and press Return to boot the clone disk.

  16. Provide the relevant system information such as host name, time zone, and so on.

  17. Log in as root to verify the system information once the system has booted, as shown in the following example.


oak% su
Password
# dd < /floppy/floppy0 > /tmp/output.file
# boot
(Boot messages)
# dd if=/dev/dsk/c0t0d0s2 of=/dev/dsk/c0t2d0s2 bs=100k
# fsck /dev/rdsk/c0t2d0s2
# mount /dev/dsk/c0t2d0s2 /mnt
# cd /mnt/etc
# vi vfstab
(Modify entries for the new disk)
# cd /
# umount /mnt
# init 0
(Shutdown messages)
# boot disk2 -s
(Boot messages)
# sys-unconfig
# boot disk2



Try Repairing Any Bad Blocks

If the disk has bad blocks, you may be able to repair them with the format command. See the format(1M) manual page for more information.

Try Reformatting the Disk

If the disk is bad, reformatting it may fix the problem. Use the format command to reformat a disk. See the format(1M) manual page for more information.

CAUTION. Remember that formatting the disk destroys all data.


Replacing the Bad Disk

If reformatting and repairing bad blocks do not work, replace the disk. See the disk installation manual for more information.

Adding Defect List, Format, Partition, and Label Disk (format)

Use the following steps to put a defect list on a new disk and to format, partition, and label it.

CAUTION. You must format the disk after you add the defect list. Any data on the disk is destroyed by formatting. If the disk is not new, be sure the data is backed up before you proceed. See "Backing Up and Restoring File Systems" on page 211 for complete information on how to back up and restore file systems.


  1. Become superuser.

  2. Type format and press Return.

  3. A list of available disks is displayed, as shown in the following example.

    
    
    paperbark% su
    # format
    Searching for disks...done
    
    AVAILABLE DISK SELECTIONS:
           0. c0t0d0 <SUN2.1G cyl 2733 alt 2 hd 19 sec 80>
              /sbus@1f,0/SUNW,fas@e,8800000/sd@0,0
           1. c0t1d0 <SUN2.1G cyl 2733 alt 2 hd 19 sec 80>
              /sbus@1f,0/SUNW,fas@e,8800000/sd@1,0
    Specify disk (enter its number):
    
    
    
    
  4. Type the number of the new disk from the list that is displayed.

    The Format menu and the format> prompt are displayed.

  5. Type defect and press Return.

  6. Type primary and press Return.

    The original defect list is added to the disk, as shown in the following example.

    
    
    defect> primary
    Extracting primary defect list . . . Extraction complete.
    Current Defect List updated, \
    total of 30 defects.
    
    
    
    
  7. Type quit and press Return.

    The format> prompt is displayed.

  8. Type format and press Return.

    The disk begins formatting. Formatting takes about 10 minutes for a 107-Mbyte disk, longer for bigger disks.

  9. When the format> prompt is redisplayed, type partition and press Return.

  10. Re-create the partitions to match the partitions on the defective disk.

  11. Type label and press Return.

    The disk is labeled.

  12. Type quit and press Return.

    The Format menu and format> prompt are redisplayed.

  13. Type quit and press Return.

    The shell prompt is redisplayed, as shown in the following example.


oak% su
Password:
# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
        0. sd0 at esp0 slave 24
           sd0: <SUN0207 cyl 1254 alt 2 hd 9 sec 36>
        1. sd2 at esp0 slave 16
           sd2: <SUN0207 cyl 1254 alt 2 hd 9 sec 36>
Specify disk (enter its number): 1
selecting c0t0d0
[disk formatted]
FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        quit
format > defect
defect > primary
Extracting primary defect list . . . Extraction complete.
Current Defect List updated, total of 30 defects.
defect > quit
format > format
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
        quit
partition> <partition the disk>
partition> label
partition> quit
format > quit
#



Remaking the File Systems (newfs)

A disk must be formatted, partitioned, and labeled before you can create UFS file systems on it. If you are re-creating an existing UFS file system, unmount the file system before performing the following steps.

  1. Become superuser.

  2. Type newfs /dev/rdsk/cntndnsn and press Return.

    You are asked if you want to proceed.

    CAUTION. Be sure you have specified the correct device name for the partition before performing the next step. If you specify the wrong partition, you will erase its contents when the new file system is created.


  3. Type y to confirm.

    The newfs command uses optimized default values to create the file system.

The following example creates a file system on /dev/rdsk/c0t3d0s7.


oak% su
Password:
# newfs /dev/rdsk/c0t3d0s7
newfs: construct a new file system /dev/rdsk/c0t3d0s7 (y/n)? y
/dev/rdsk/c0t3d0s7:     163944 sectors in 506 cylinders of 9 tracks, 36
 sectors
       83.9MB in 32 cyl groups (16 c/g, 2.65MB/g, 1216 i/g)
super-block backups (for fsck -b #) at:
 32, 5264, 10496, 15728, 20960, 26192, 31424, 36656, 41888,
 47120, 52352, 57584, 62816, 68048, 73280, 78512, 82976, 88208,
 93440, 98672, 103904, 109136, 114368, 119600, 124832, 130064, 135296,
 140528, 145760, 150992, 156224, 161456,
#



Mounting the File System on a Temporary Mount Point (mount)

Type mount /dev/dsk/ cntndnsn /mnt and press Return. The file system is mounted on the /mnt temporary mount point. To mount the disk, specify the block device directory (/dev/dsk), not the raw device directory.

Restoring Files to the File System (ufsrestore)

Restore the contents of the latest full backup, and then restore subsequent incremental backups from lowest to highest level (ufsrestore), by using the following steps.

  1. As superuser, type cd /mnt and press Return. You have changed to the mount point directory.

  2. Write-protect the tapes for safety.

  3. Insert the first volume of the level 0 tape into the tape drive.

  4. Type ufsrestore rvf /dev/rmt/ unit and press Return.

    If this is a multivolume restore, when prompted, remove the first tape and insert the last tape in the tape drive. Follow instructions about the order of the rest of the tapes. The level 0 tape is restored.

  5. Remove the tape and load the next-lowest-level tape in the drive.

    Always restore tapes starting with 0 and continuing until you reach the highest level.

  6. Type ufsrestore rvf /dev/rmt/ unit and press Return.

    The next-level tape is restored.

  7. Repeat steps 5 and 6 for each additional tape.

  8. Type ls and press Return.

  9. A list of files in the directory is displayed. Check the listing to verify that all the files are restored.

  10. Type rm restoresymtable and press Return.

    The restoresymtable created by ufsrestore is removed.

Unmounting the File System from Its Temporary Mount Point (umount)

Use the following steps to unmount the file system from its temporary mount point.

  1. As superuser, type cd / and press Return.

  2. Type umount /mnt and press Return.

    The file system is unmounted from the temporary mount point.

Checking the File System for Inconsistencies (fsck)

Type fsck /dev/rdsk/cntndnsn and press Return. The file system is checked for consistency.

Performing a Level 0 Backup of the Restored File System (ufsdump)

You always should do an immediate backup of a newly created file system because ufsrestore repositions the files and changes the inode allocation.

Use the following steps to perform a level 0 backup of the restored file system.

  1. Remove the last tape and insert a new write-enabled tape in the tape drive.

  2. Type ufsdump 0uf /dev/rmt/ unit /dev/rdsk/cntndnsn and press Return.

Mounting the File System at Its Permanent Mount Point (mount)

Type mount /dev/dsk/cntndnsn and press Return. The restored file system is mounted and available for use.

    [ Team LiB ] Previous Section Next Section