Disk Slices

Disks are divided into regions called disk slices or disk partitions. A slice is composed of a single range of contiguous blocks. It is a physical subset of the disk (except for slice 2, which represents the entire disk). A UNIX file system is built within these disk slices. The boundaries of a disk slice are defined when a disk is formatted by using the Solaris format utility, and the slice information for a particular disk can be viewed by using the prtvtoc command. Each disk slice appears to the operating system (and to the system administrator) as though it were a separate disk drive.

Note

Solaris device names use the term slice (and the letter s in the device name) to refer to the slice number. Slices were called partitions in SunOS 4.x. This book attempts to use the term slice whenever possible; however, certain interfaces, such as the format and prtvtoc commands, refer to slices as partitions.


A physical disk consists of a stack of circular platters. Data is stored on these platters in a cylindrical pattern. Cylinders can be grouped and isolated from one another. A group of cylinders is referred to as a slice. A slice is defined with start and end points, defined from the center of the stack of platters, which is called the spindle.

To define a slice, the administrator provides a starting cylinder and an ending cylinder. A disk can have up to eight slices, named 0 to 7, but it is uncommon to use partition 2 as a file system. (See Chapter 6, “Installing the Solaris 9 Software,” for a discussion of disk-storage systems and sizing partitions.)

Note

Sometimes a relational database uses an entire disk and requires one single raw partition. It’s convenient in this circumstance to use slice 2 because it represents the entire disk.


When setting up slices, remember these rules:

  • Each disk slice holds only one file system.

  • No file system can span multiple slices.

  • After a file system is created, its size cannot be increased or decreased without repartitioning the entire disk and restoring all data from a backup.

  • Slices cannot span multiple disks; however, multiple swap slices on separate disks are allowed.

When I d iscuss logical volumes later in this chapter, I’ll describe how to get around some of these limitations in file systems.

Also follow these guidelines when planning the layout of file systems:

  • Distribute the workload as evenly as possible among different I/O systems and disk drives. Distribute /home and swap directories evenly across disks. A single disk has limitations on how quickly data can be transferred. By spreading this load across more than one disk, you can improve performance exponentially. This concept is described in Chapter 11, “Device Administration and Disk Management,” where I describe striping using the Solaris volume manager.

  • Keep projects or groups within the same file system. This enables you to keep better track of data for backups, recovery, and security reasons. Some disks might have better performance than others.

  • Use the faster drives for file systems that need quick access and the slower drives for data that might not need to be retrieved as quickly.

  • Use as few file systems per disk as possible. On the system (or boot) disk, you usually have three slices: /, /usr, and a swap area. On other disks, create one or (at most) two slices. Fewer, roomier slices cause less file fragmentation than many small, overcrowded slices. Higher-capacity tape drives and the capability of ufsdump to handle multiple volumes facilitate backing up larger file systems.

  • It is not important for most sites to be concerned about keeping similar types of user files in the same file system.

  • Occasionally, you might have some users who consistently create small or large files. You might consider creating a separate file system with more I-nodes for users who consistently create small files. (See the sections on I-nodes and changing the number of bytes per I-node later in this chapter.)

Displaying Disk Configuration Information

As described earlier, disk configuration information is stored in the disk label. If you know the disk and slice number, you can display information for a disk by using the print volume table of contents (prtvtoc) command. You can specify the volume by specifying any nonzero-size slice defined on the disk (for example, /dev/rdsk/c0t3d0s2 for all of disk 3 or /dev/rdsk/c0t3d0s5 for just the sixth slice). If you know the target number of the disk but do not know how it is divided into slices, you can show information for the entire disk by specifying either slice 2 or slice 0. The following exercise shows how you can examine information stored on a disk’s label by using the prtvtoc command.

Exercise 14.1 Examining a Disk’s Label Using the prtvtoc Command

1.
Become superuser.

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

Information for the disk and slice you specify is displayed. In the following steps, information is displayed for all of disk 3:

1. Become superuser.

2. Type prtvtoc /dev/rdsk/c0t3d0s2 and press Enter.

The system responds with this:

* /dev/rdsk/c0t3d0s2 (volume "") partition map 
* 
* Dimensions: 
*     512 bytes/sector 
*      36 sectors/track 
*       9 tracks/cylinder 
*     324 sectors/cylinder 
*    1272 cylinders 
*    1254 accessible cylinders 
* 
* Flags: 
*   1: unmountable 
*  10: read-only 
* 
*                      First   Sector  Last 
* Partition Tag Flags  Sector  Count   Sector  Mount Directory 
  2          5   01    0       406296  406295 
  6          4   00    0       242352  242351 
  7          0   00    242352  163944  406295  /files7 

The prtvtoc command shows the number of cylinders and heads, as well as how the disk’s slices are arranged.

Using the format Utility to Create Slices

Before you can create a file system on a disk, the disk must be formatted, and you must divide it into slices by using the Solaris format utility. Formatting involves two separate processes:

  • Writing format information to the disk

  • Completing a surface analysis, which compiles an up-to-date list of disk defects

When a disk is formatted, header and trailer information is superimposed on the disk. When the format utility runs a surface analysis, the controller scans the disk for defects. It should be noted that defects and formatting information reduce the total disk space available for data. This is why a new disk usually holds only 90–95% of its capacity after formatting. This percentage varies according to disk geometry and decreases as the disk ages and develops more defects.

The need to perform a surface analysis on a disk drive has dropped as more manufacturers ship their disk drives formatted and partitioned. You should not need to use the format utility when adding a disk drive to an existing system unless you think disk defects are causing problems. The only other reason you should need to use format is if you want to change the partitioning scheme.

Caution

Formatting and creating slices is a destructive process, so make sure user data is backed up before you start.


The format utility searches your system for all attached disk drives and reports the following information about the disk drives it finds:

  • Target location

  • Disk geometry

  • Whether the disk is formatted

  • Whether the disk has mounted partitions

In addition, the format utility is used in disk repair operations to do the following:

  • Retrieve disk labels

  • Repair defective sectors

  • Format and analyze disks

  • Partition disks

  • Label disks (write the disk name and configuration information to the disk for future retrieval)

The Solaris installation program partitions and labels disk drives as part of installing the Solaris release. However, you might need to use the format utility when doing the following:

  • Displaying slice information

  • Dividing a disk into slices

  • Formatting a disk drive when you think disk defects are causing problems

  • Repairing a disk drive

The main reason a system administrator uses the format utility is to divide a disk into disk slices.

Exercise 14.2 Formatting a Disk

The process of creating slices follows:

1.
Become superuser.

2.
Type format.

The system responds with this:

AVAILABLE DISK SELECTIONS: 
0. c0t0d0 <SEAGATE-ST32430N-0170 cyl 3984 alt 2 hd 9 sec 117> 
/iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@0,0 
1. c0t3d0 <SEAGATE-ST32171W-0338 cyl 5116 alt 2 hd 5 sec 165> 
/iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@3,0 

3.
Specify the disk (enter its number).

The system responds with this:

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 
    !<cmd> - execute <cmd>, then return 
    quit 

4.
Type partition at the format prompt. The partition 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 

Note

It is unnecessary to type the entire command. After you type the first two characters of a command, the format utility recognizes the entire command.

5.
Type print to display the current partition map.

The system responds with this:

partition> print 
Current partition table (original): 
Total disk cylinders available: 3984 + 2 (reserved cylinders) 
Part      Tag    Flag     Cylinders        Size            Blocks 
  0       root    wm       0 -  175       90.49MB    (176/0/0)   185328 
  1       swap    wu     176 - 1051      450.40MB    (876/0/0)   922428 
  2     backup    wu       0 - 3983        2.00GB    (3984/0/0) 4195152 
  3 unassigned    wm       0               0         (0/0/0)          0 
  4        usr    wm    1052 - 1635      300.27MB    (584/0/0)   614952 
  5        usr    wm    1636 - 3982        1.18GB    (2347/0/0) 2471391 
  6 unassigned    wm       0               0         (0/0/0)          0 
  7 unassigned    wm       0               0         (0/0/0)          0 

6.
After you partition the disk, you must label it by typing label at the partition prompt:

partition> label 

You are asked for confirmation on labeling the disk as follows:

Ready to label disk, continue? 

Enter Y to continue.

Note

If you don’t label the drive, your partition changes will not be retained.

7.
After labeling the disk, type quit to exit the partition menu:

partition> quit 

8.
Type quit again to exit the format utility:

format> quit 

It’s important to point out a few undesirable things that can happen when defining disk partitions with the format utility if you’re not careful. First, be careful not to waste disk space. Wasted disk space can occur when you decrease the size of one slice and do not adjust the starting cylinder number of the next adjoining disk slice.

Second, don’t overlap disk slices. Overlapping occurs when one or more cylinders are allocated to more than one disk slice. For example, increasing the size of one slice without decreasing the size of the adjoining slice will create overlapping partitions. The format utility will not warn you of wasted disk space or overlapping partitions.

One more item of note: On standard UFS file systems, don’t change the size of disk slices that are currently in use. When a disk with existing slices is repartitioned and relabeled, any existing data will be lost. Before repartitioning a disk, first copy all the data to tape or to another disk.

The Free Hog Slice

When using the format utility to change the size of disk slices, a temporary slice is automatically designated that expands and shrinks to accommodate the slice resizing operations. This temporary slice is referred to as the “free hog,” and it represents the unused disk space on a disk drive. If a slice is decreased, the free hog expands. The free hog is then used to allocate space to slices that have been increased. It does not, however, prevent the overlapping of disk slices as described in the previous section.

The free hog slice exists only when you run the format utility. It is not saved as a permanent slice.

Using the format Utility to Modify Partitions

If you need to change the size of slices on a particular disk, you can either re-create the disk slices as outlined in the previous section or use the modify option of the format utility.

Warning

You will lose all data when changing partition sizes. Make sure that you copy your data either to another disk or to tape before continuing.


The modify option allows the root to create slices by specifying the size of each slice without having to keep track of starting cylinder boundaries. It also keeps track of any excess disk space in the temporary free hog slice.

Exercise 14.3 Modifying a Disk Slice

To modify a disk slice, follow these steps:

1.
Make a backup of your data. This process destroys the data on this disk.

2.
As root, enter the partition menu of the format utility, as described in Exercise 14.2.

3.
After printing the existing partition scheme, type modify and press Enter.

Note

If you try to modify mounted partitions, you receive an error that states “Cannot modify disk partitions while it has mounted partitions.”

When typing modify, you’ll see the following output on a disk that does not have mounted partitions:

Select partitioning base: 
        0. Current partition table (original) 
        1. All Free Hog 
Choose base (enter number) [0]? 

4.
Press Enter to select the default selection. The following is displayed:

Part      Tag   Flag   Cylinders    Size        Blocks 
0        usr    wm     0 -  194     100.26MB   (195/0/0)   205335 
1 unassigned    wu     195 - 1167   500.28MB   (973/0/0)  1024569 
2     backup    wm     0 - 3983     2.00GB     (3984/0/0) 4195152 
3 unassigned    wm     0             0         (0/0/0)          0 
4 unassigned    wm     0             0         (0/0/0)          0  
5 unassigned    wm     0             0         (0/0/0)          0 
6 unassigned    wm     0             0         (0/0/0)          0 
7 unassigned    wm     0             0         (0/0/0)          0 

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

5.
Press Enter to select the default selection. The following message is displayed:

Free Hog partition[6]? 

6.
Press Enter to select the default selection. If all the disk space is in use, the following message is displayed:

Warning: No space available from Free Hog partition. 
Continue[no]? 

7.
Type yes. You’ll be prompted to type the new size for each partition:

Enter size of partition '0' [205335b,195c,100.26mb,0.10gb]: 90m 
Enter size of partition '1' [1024569b,973c,500.28mb 0.49gb]:450m 
Enter size of partition '3' [0b, 0c, 0.00mb, 0.00gb]: <cr> 
Enter size of partition '4' [0b, 0c, 0.00mb, 0.00gb]: <cr> 
Enter size of partition '5' [0b, 0c, 0.00mb, 0.00gb]: <cr> 
Enter size of partition '7' [0b, 0c, 0.00mb, 0.00gb]: <cr> 

Note

Slice 6 is not displayed because that is the temporary free hog.

When you are finished resizing the last partition, the following is displayed, showing you the revised partition map:

Part     Tag   Flag    Cylinders      Size       Blocks 
0        usr   wm      0 -  175      90.49MB    (176/0/0)  185328 
1 unassigned   wu    176 - 1051     450.40MB    (876/0/0)  922428 
2     backup   wm      0 - 3983       2.00GB    (3984/0/0) 4195152 
3 unassigned   wm      0              0         (0/0/0)          0 
4 unassigned   wm      0              0         (0/0/0)          0 
5 unassigned   wm      0              0         (0/0/0)          0 
6 unassigned   wm   1052 - 3983      1.47GB    (2932/0/0)   3087396 
7 unassigned   wm      0              0         (0/0/0)          0 
Okay to make this the current partition table[yes]? 

Note

Slice 6, the free hog, represents the unused disk space. You might want to allocate this space to another partition so that it does not go unused, or you can save it and allocate it another time to an unused partition.

8.
Press Enter to confirm your modified partition map. You’ll see the following message displayed:

Enter table name (remember quotes): 

9.
Name the modified partition table and press Enter:

Enter table name (remember quotes): c0t3d0.2gb 

10.
After you enter the name, the following message is displayed:

Ready to label disk, continue? 

11.
Type yes and press Enter to continue.

12.
Type quit (or q) and press Enter to exit the partition menu. The main menu is displayed.

13.
Type quit and press Enter to exit the format utility.

Recovering Disk Partition Information

It’s always a good idea to save a disk’s VTOC to a file using the prtvtoc command described earlier. This information can then be used later to restore the disk label if your current VTOC becomes corrupted or accidentally changed, or if you need to replace the disk drive.

By saving the output from the prtvtoc command into a file on another disk, you can reference it when running the fmthard command. The fmthard command updates the VTOC on hard disks.

Exercise 14.4 Recovering a VTOC

To recover a VTOC, follow these steps:

1.
Run the format utility on the disk and label it with the default partition table.

2.
Use the fmthard command to write the backup VTOC information back to the disk drive. The following example uses the fmthard command to recover a corrupt label on a disk named /dev/rdsk/c0t3d0s2. The backup VTOC information is in a file named c0t3d0 in the /vtoc directory:

fmthard –s /vtoc/c0t3d0 /dev/rdsk/c0t3d0s2 

Another use for the fmthard command is partitioning several disks with the same partitioning scheme. Get the VTOC information from the disk you want to copy (c0t0d0), and write the information to the new disk (c1t0d0) as follows:

prtvtoc /dev/rdsk/c0t0d0s0 | fmthard -s - /dev/rdsk/c1t0d0s2 

Logical Volumes

On a large server with many disk drives, standard methods of disk slicing are inadequate and inefficient. File systems cannot span multiple disks, and the size of the file system is limited to the size of the disk. Another problem with standard file systems is that they cannot be increased in size without destroying data on the file system.

Sun has addressed these issues with two software packages: the Solaris volume manager (SVM), called Solstice DiskSuite in previous Solaris releases, and the Sun Enterprise volume manager. Both packages allow file systems to span multiple disks and provide for improved I/O and reliability compared to the standard Solaris file system. We refer to these types of file systems as logical volumes (LVMs).

SVM is now part of Solaris 9. The Enterprise volume manager is purchased separately and is not part of the standard Solaris operating system distribution. Typically, SVM is used on Sun’s multipacks, and the Enterprise volume manager package is used on the Sparc StorEdge arrays. LVMs, the SVM, and the Enterprise volume manager are described in Chapter 11.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset