System Administration Guide, Volume 1

Commands for Creating a Customized File System

This section describes the two commands you use to create a customized file system:

The newfs Command Syntax, Options, and Arguments

The newfs command is a friendlier version of the mkfs command that is used to create file systems. The newfs command is located in the /usr/sbin directory.

The syntax is:


newfs [-Nv] [mkfs_options] raw_device

The table below describes the options and arguments to the newfs command.

Table 40-4 The newfs Command Options and Arguments

Option 

Description 

-N

Displays the file system parameters that would be used in creating the file system without actually creating it. This option does not display the parameters used to create an existing file system. 

-v

Displays the parameters that are passed to the mkfs command.

mkfs-options

Use the following options to set the parameters passed to the mkfs command. The options are listed below in the order they are passed to mkfs. Separate the options with spaces.

-s size

The size of the file system in sectors. The default is automatically determined from the disk label. 

-t ntrack

The number of tracks per cylinder on the disk. The default is determined from the disk label. 

-b bsize

The logical block size in bytes to use for data transfers. Specify the size of 4096 or 8192 (4 or 8 Kbytes). The default is 8192 bytes (8 Kbytes). 

-f fragsize

The smallest amount of disk space in bytes that is allocated to a file. Specify the fragment size in powers of two in the range from 512 to 8192 bytes. The default is 1024 bytes (1 Kbyte). 

-c cgsize

The number of disk cylinders per cylinder group. The default value is calculated by dividing the number of sectors in the file system by the number of sectors in a gigabyte, and then multiplying the result by 32. The default value ranges from 16 to 256.  

-m free

The minimum percentage of free disk space to allow. The default is ((64 Mbytes/partition size) * 100), rounded down to the nearest integer and limited between 1% and 10%, inclusively. 

-r rpm

The speed of the disk, in revolutions per minute. This setting is driver- or device-specific. If the drive can report how fast it spins, mkfs uses this value. If not, the default is 3600. This parameter is converted to revolutions per second before it is passed to mkfs.

-i nbpi

The number of bytes per inode to use in computing how many inodes to create. See the section above for the default values. 

-o opt

Optimization type to use for allocating disk blocks to files: space or time. The default is time.

-a apc

The number of alternate blocks per disk cylinder (SCSI devices only) to reserve for bad block placement. The default is 0. 

-d gap

(Rotational delay) The expected minimum number of milliseconds it takes the CPU to complete a data transfer and initiate a new data transfer on the same disk cylinder. The default is zero. 

-n nrpos

The number of different rotation positions in which to divide a cylinder group. The default is 8. 

-C maxcontig

The maximum number of blocks, belonging to one file, that will be allocated contiguously before inserting a rotational delay. The default varies from drive to drive. Drives without internal (track) buffers (or drives/controllers that don't advertise the existence of an internal buffer) default to 1. Drives with buffers default to 7. 

This parameter is limited in the following way: 

blocksize x maxcontig must be <= maxphys

maxphys is a read-only kernel variable that specifies the maximum block transfer size (in bytes) that the I/O subsystem is capable of satisfying. (This limit is enforced by mount, not by newfs or mkfs.)

This parameter also controls clustering. Regardless of the value of rotdelay, clustering is enabled only when maxcontig is greater than 1. Clustering allows higher I/O rates for sequential I/O and is described in tunefs(1M).

raw_device

The special character (raw) device file name of the partition to contain the file system. This argument is required. 

Examples--newfs Command Options and Arguments

This newfs example uses the -N option to display file system information, including the backup superblocks.


# newfs -N /dev/rdsk/c0t0d0s0
/dev/rdsk/c0t0d0s0:  37260 sectors in 115 cylinders of 9 tracks, 36 sectors
        19.1MB in 8 cyl groups (16 c/g, 2.65MB/g, 1216 i/g)
superblock backups (for fsck -b #) at:
 32, 5264, 10496, 15728, 20960, 26192, 31424, 36656,
#

The Generic mkfs Command

The generic mkfs command calls a file system-specific mkfs, which then creates a file system of a specified type on a specified disk slice. Although mkfs can support different types of file systems, in practice you would use it to create UFS or PCFS file systems. To make other types of file systems, you would have to write the software for the file system-specific versions of the mkfs command to use. Normally, you do not run mkfs directly; it is called by the newfs command.

The generic mkfs command is located in /usr/sbin. See mkfs(1M) for a description of the arguments and options.

UFS Direct Input/Output (I/O)

Direct I/O is intended to boost bulk I/O operations. Bulk I/O operations use large buffer sizes to transfer large files (larger than 256 Kbytes).

An example of a bulk I/O operation is downloading satellite data, which writes large amounts of data to a file. Direct I/O data is read or written into memory without using the overhead of the operating system's page caching mechanism.

There is a potential penalty on direct I/O startup. If a file requested for I/O is already mapped by another application, the pages will have to be flushed out of memory before the direct I/O operation can begin.

See directio(3C) for more information.

Direct I/O can also be enabled on a file system by using the forcedirectio option to the mount command. Enabling direct I/O is a performance benefit only when a file system is transferring large amounts of sequential data.

When a file system is mounted with this option, data is transferred directly between a user's address space and the disk. When forced direct I/O is not enabled for a file system, data transferred between a user's address space and the disk is first buffered in the kernel address space.

The default behavior is no forced direct I/O on a UFS file system. See mount_ufs(1M) for more information.

How to Enable Forced Direct I/O on a UFS File System

  1. Become superuser.

  2. Mount a file system with the forcedirectio mount option.


    # mount -F ufs -o forcedirectio /dev/dsk/c0t3d0s7 /datab
    
  3. Verify the mounted file system has forced direct I/O enabled.


    # mount
                        .
                        .
                        .
    /export/home on /dev/dsk/c0t3d0s7 read/write/setuid/forcedirectio ...