System Administration Guide

The UFS File System

UFS is the default disk-based file system in Solaris system software. Most of the time, when you administer a disk-based file system, you will be administering UFS. UFS provides the following features:


Note -

Solaris device names use the term slice (and the letter "s" in the device name) to refer to the slice number. Slices used to be called "partitions" in SunOS 4.x.


Figure 26-1 shows how a disk slice can be formatted to contain a UFS file system.

Figure 26-1 How a Disk Slice Is Formatted for a UFS File System

Graphic

The following sections describe how a disk is divided into slices and cylinder groups, and structured as a UFS file system.

Disk Slices

A slice is composed of a single range of contiguous blocks. It is a physical subset of the disk (except for slice 2, which customarily represents the entire disk). Before you can create a file system on a disk, you must format it and divide it into slices. See Part VII for complete information on installing and formatting disks, and dividing disks into slices.

A slice can be used as a raw device for swap space or to hold one UFS file system. A disk can be divided into as many as eight slices. See Part VII for a list of customary disk slice assignments.

This example shows disk information for /dev/dsk/c0t3d0. Note that the format command does not show slice information as part of the available disk selections. It shows the controller, target, and disk number for each disk.


Example 26-1 Using the format Command


$ su
Password:
# format
AVAILABLE DISK SELECTIONS:
 0. c0t0d0 at scsibus0 slave 24
 sd0: <SUN0207 cyl 1254 alt 2 hd 9 sec 36>
 1. c0t3d0 at scsibus0 slave 0: veryloud
 sd3: <SUN0207 cyl 1254 alt 2 hd 9 sec 36>
Specify disk (enter its number): 1
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> 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> print
Volume: veryloud
Current partition table (original sd3):
Part      Tag   Flag     Cylinders        Size       Blocks
  0       root    wm       0 - 39        14.06MB     (40/0/0)
  1       swap    wu       40 - 199      56.25MB    (160/0/0)
  2     backup    wm       0 - 1150     404.65MB   (1151/0/0)
  3 unassigned    wm       0               0          (0/0/0)
  4 unassigned    wm       0               0          (0/0/0)
  5          -    wm       0             10.20MB     (29/0/0)
  6        usr    wm       200 - 228    121.29MB    (345/0/0)
  7       home    wm       574 - 1150   202.85MB    (577/0/0
partition> quit
format> quit
#

If you know the disk and slice number, you can display information for a disk using the prtvtoc (print volume table of contents) command. You can specify the volume by specifying any non-zero-size slice defined on the disk (for example, /dev/rdsk/c0t3d0s2 for all of disk 3, or /dev/rdsk/c0t3d0s7 for the eighth slice of disk 3). 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.

Cylinder Groups

You create a UFS file system on a disk slice, which is divided into one or more areas called cylinder groups. A cylinder group is composed of one or more consecutive disk cylinders (the set of tracks on a group of platters that have the same radial distance from the center of the platter). See Chapter 21, Disk Management (Overview) for a complete description of disk geometry.

A cylinder group map is created for each cylinder group. The cylinder group map records the block usage and available blocks.

Types of Blocks

Cylinder groups are divided into blocks to control and organize the structure of the files within the cylinder group. Each type of block has a specific function in the file system. A UFS file system has four types of addressable blocks and additional information management disk areas. The four types of blocks are:

See Chapter 32, File System Reference for more detailed information about each type of block.

If you want to customize a file system using arguments to the newfs command or with the mkfs command, see Chapter 32, File System Reference for information about altering these parameters.

Size Restrictions on UFS File Systems

Total Size

The limit on the total size of a file system is 1 Tbyte. A UFS file system can be as big as the slice that holds it.

Maximum File Size

The maximum size for any one file in a UFS file system depends on the way the file system is configured.

Maximum Number of Files

The maximum number of files per UFS file system is determined by the number of inodes allocated for a file system. The number of inodes depends on how much disk space is allocated for each inode and the total size of the file system. By default, one inode is allocated for each 2 Kbyte of data space. You can change the default allocation using the -i option of the newfs command.

Logical Block and Fragment Size

Fragments are small logical blocks that are created to save space by reducing unused portions of logical blocks. The maximum logical block and fragment size is 8192 bytes, although fragments are typically less than or equal to the size of logical blocks.