Previous Page
Next Page

Understanding Custom File System Parameters

Before you choose to alter the default file system parameters assigned by the newfs command, you need to understand them. This section describes each of these parameters:

  • Logical block size

  • Fragment size

  • Minimum free space

  • Rotational delay (gap)

  • Optimization type

  • Number of inodes and bytes per inode

Logical Block Size

The logical block size is the size of the blocks that the Unix kernel uses to read or write files. The logical block size is usually different from the physical block size (usually 512 bytes), which is the size of the smallest block that the disk controller can read or write.

You can specify the logical block size of the file system. After the file system is created, you cannot change this parameter without rebuilding the file system. You can have file systems with different logical block sizes on the same disk.

By default, the logical block size is 8192 bytes (8KB) for UFS file systems. The UFS supports block sizes of 4096 or 8192 bytes (4KB or 8KB, with 8KB being the recommended logical block size).

To choose the best logical block size for your system, consider both the performance desired and the available space. For most UFS systems, an 8KB file system provides the best performance, offering a good balance between disk performance and use of space in primary memory and on disk.

Note

sun4u Only The sun4u architecture does not support the 4KB block size.


As a general rule, a larger logical block size increases efficiency for file systems in which most of the files are large. Use a smaller logical block size for file systems in which most of the files are small. You can use the quot -c file system command on a file system to display a complete report on the distribution of files by block size.

Fragment Size

As files are created or expanded, they are allocated disk space in either full logical blocks or portions of logical blocks called fragments. When disk space is needed to hold data for a file, full blocks are allocated first, and then one or more fragments of a block are allocated for the remainder. For small files, allocation begins with fragments.

The capability to allocate fragments of blocks to files rather than whole blocks saves space by reducing the fragmentation of disk space that results from unused holes in blocks.

You define the fragment size when you create a UFS. The default fragment size is 1KB. Each block can be divided into one, two, four, or eight fragments, resulting in fragment sizes from 512 bytes (for 4KB file systems) to 8192 bytes (for 8KB file systems only). The lower boundary is actually tied to the disk sector size, typically 512 bytes.

Note

Fragment Size for Large Files The upper boundary might equal the full block size, in which case the fragment is not a fragment at all. This configuration might be optimal for file systems with large files when you are more concerned with speed than with space.


When choosing a fragment size, look at the trade-off between time and space: A small fragment size saves space but requires more time to allocate. As a general rule, a larger fragment size increases efficiency for file systems in which most of the files are large. Use a smaller fragment size for file systems in which most of the files are small.

Minimum Free Space

The minimum free space is the percentage of the total disk space held in reserve when you create the file system. Before Solaris 7, the default reserve was always 10%. Since Solaris 7, the minimum free space is automatically determined. This new method of calculating free space results in less wasted disk space on large file systems.

Free space is important because file access becomes less efficient as a file system gets full. As long as the amount of free space is adequate, UFS file systems operate efficiently. When a file system becomes full, using up the available user space, only root can access the reserved free space.

Commands such as df report the percentage of space available to users, excluding the percentage allocated as the minimum free space. When the command reports that more than 100% of the disk space in the file system is in use, some of the reserve has been used by root.

If you impose quotas on users, the amount of space available to the users does not include the free space reserve. You can change the value of the minimum free space for an existing file system by using the tunefs command.

Optimization Type

The optimization type is either space or time. When you select space optimization, disk blocks are allocated to minimize fragmentation and optimize disk use.

When you select time optimization, disk blocks are allocated as quickly as possible, with less emphasis on their placement. With enough free space, the disk blocks can be allocated effectively with minimal fragmentation. Time is the default.

You can change the value of the optimization type parameter for an existing file system by using the tunefs command.

Number of inodes and Bytes per inode

The number of inodes determines the number of files you can have in the file system because each file has one inode. The number of bytes per inode determines the total number of inodes created when the file system is made: the total size of the file system divided by the number of bytes per inode.

A file system with many symbolic links will have a lower average file size and the file system will require more inodes than a file system with a few very large files. If your file system will have many small files, you can use the -i option with newfs to specify the number of bytes per inode, which will determine the number of inodes in the file system. For a file system with very large files, give this parameter a lower value.

Note

Number of inodes Having too many inodes is much better than running out of them. If you have too few inodes, you could reach the maximum number of files on a disk slice that is practically empty.


The mkfs Command

Exam Alert

Expect to see several questions on creating, fixing, and managing file systems. All questions related to creating file systems will use newfs. It's important to understand the file system options described in this mkfs section, but don't be too concerned about understanding the mkfs method of creating file systems. Most system administrators use newfs and that is what you will be tested on.


Although it's highly recommended that the newfs command be used to create file systems, it's also important to see what is happening "behind the scenes" with the mkfs utility. The syntax for mkfs is as follows:

/usr/sbin/mkfs <options> <character device name>

The mkfs options are described in Table 1.10.

Table 1.10. The mkfs Command

Option

Description

-F

Used to specify the file system type. If this option is omitted, the /etc/vfstab and /etc/default/fs files are checked to determine a file system type.

-m

Shows the command line that was used to create the specified file system. No changes are made to the file system.

-v

Verbose. Shows the command line, but does not execute anything.

-o <specific options>

A list of options specific to the type of file system. The list must have the following format: -o followed by a space, followed by a series of keyword [=value] pairs, separated by commas, with no intervening spaces.

apc=<n>Reserved space for bad block replacement on SCSI devices. The default is 0.

NPrints the file system parameters without actually creating the file system.

nsect=<n>The number of sectors per track on the disk. The default is 32.

ntrack=<n>The number of tracks per cylinder on the disk. The default is 16.

bsize=<n>Logical block size, either 4096 (4KB) or 8192 (8KB). The default is 8192. The sun4u architecture does not support the 4096 block size.

fragsize=<bytes>The smallest amount of disk space, in bytes, to allocate to a file. The value must be a power of 2 with a minimum value of 512 and a maximum of the logical block size. Thus, if the logical block size is 4096, legal values are 512, 1024, 2048, and 4096. If the logical block size is 8192, 8192 is also a legal value. The default is 1024.

cgsize=<cyls>The number of cylinders per cylinder group. The default is 16.

free=<n>The minimum percentage of free space to maintain in the file system. This space is off-limits to normal users. After the file system is filled to this threshold, only the superuser can continue writing to the file system. This parameter can be subsequently changed using the tunefs command. The default is 10%; however, on large file systems, the minfree value is determined automatically.

rps=<rps>The rotational speed of the disk, specified in revolutions per second. The default is 60.

nbpi=<value>The value specified is the number of bytes per inode, which specifies the density of inodes in the file system. The number is divided into the total size of the file system to determine the fixed number of inodes to create. It should reflect the expected average size of files in the file system. If fewer inodes are desired, a larger number should be used. To create more inodes, a smaller number should be given. The default is 2048.

opt=<value>Space or time optimization preference. The value can be s or t. Specify s to optimize for disk space. Specify t to optimize for speed (time). The default is t. Generally, you should optimize for time unless the file system is more than 90% full.

gap=<milliseconds>Rotational delay. This option is obsolete in Solaris 10. The value is always set to 0.

nrpos=<n>The number of different rotational positions into which to divide a cylinder group. The default is 8.

maxcontig=<blocks>The maximum number of blocks belonging to one file that are allocated contiguously before inserting a rotational delay. For a 4KB file system, the default is 14; for an 8KB file system, the default is 7. This parameter can subsequently be changed using the tunefs command.


mkfs constructs a file system on the character (or raw) device found in the /dev/rdsk directory. Again, it is highly recommended that you do not run the mkfs command directly, but instead use the friendlier newfs command, which automatically determines all the necessary parameters required by mkfs to construct the file system. In the following example, the -v option to the newfs command outputs all the parameters passed to the mkfs utility. Type the following:

newfs -v /dev/rdsk/c2t4d0s1

The system outputs the following information and creates a new file system on /dev/rdsk/c2t4d0s1:

newfs: construct a new file system /dev/rdsk/c2t4d0s1: (y/n)? y

The following output appears on the screen:

mkfs -F ufs /dev/rdsk/c2t4d0s1 8359200 135 16 8192 1024 96 1 120 8192 t 0 -1 8 128 n
/dev/rdsk/c2t4d0s1:     8359200 sectors in 3870 cylinders of 16 tracks, 135 sectors
        4081.6MB in 85 cyl groups (46 c/g, 48.52MB/g, 6080 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 99536, 199040, 298544, 398048, 497552, 597056, 696560, 796064, 895568,
 7453616, 7553120, 7652624, 7752128, 7851632, 7948832, 8048336, 8147840,
 8247344, 8346848,

You'll see in the output that all the mkfs parameters used to create the file system are displayed. The second line of output describes the disk. The third line describes the UFS file system being created. The remaining lines of output list the beginning sector locations of the backup superblocks.

The newfs command also creates a lost+found directory for the UFS file system. This directory is used by the fsck command and described later in this chapter.

The fstyp Command

A good command to use to view file system parameters is the fstyp command. Use the -v option to obtain a full listing of a file system's parameters:

fstyp -v /dev/rdsk/c0t0d0s6

The system responds with this:

ufs
magic   11954   format  dynamic time    Fri Jul 19 18:51:52 2002
sblkno  16      cblkno  24      iblkno  32      dblkno  480
sbsize  3072    cgsize  2048    cgoffset 32     cgmask  0xfffffff0
ncg     28      size    205065  blocks  192056
bsize   8192    shift   13      mask    0xffffe000
fsize   1024    shift   10      mask    0xfffffc00
frag    8       shift   3       fsbtodb 1
minfree 10%     maxbpg  2048    optim   time
maxcontig 16    rotdelay 0ms    rps     90
csaddr  480     cssize  1024    shift   9       mask    0xfffffe00
ntrak   15      nsect   63      spc     945     ncyl    434
cpg     16      bpg     945     fpg     7560    ipg     3584
nindir  2048    inopb   64      nspf    2
nbfree  23678   ndir    50      nifree  100200  nffree  161
cgrotor 2       fmod    0       ronly   0       logbno  0
fs_reclaim is not set
file system state is valid, fsclean is 2
blocks available in each rotational position
cylinder number 0:
   position 0:      0    4    8   12   16   20   24   28
   position 1:     32   36   40   44   48   52   56
   position 2:      1    5    9   13   17   21   25   29
   position 3:     33   37   41   45   49   53   57
   position 4:      2    6   10   14   18   22   26   30
   position 5:     34   38   42   46   50   54   58
   position 6:      3    7   11   15   19   23   27   31
   position 7:     35   39   43   47   51   55   59
cylinder number 1:
   position 0:      63   67   71   75   79   83   87   91
   position 1:      60   95   99  103  107  111  115
   position 2:      64   68   72   76   80   84   88   92
   position 3:      61   96  100  104  108  112  116

*Output has been truncated.

Note

Copy the mkfs Options It's always a good idea to print the mkfs options used on a file system along with information provided by the prtvtoc command. Put the printout in your system log so that if you ever need to rebuild a file system because of a hard drive failure, you can re-create it exactly as it was before.



Previous Page
Next Page