System Administration Guide: Devices and File Systems

Commands for Creating a Customized File System

This section describes the two commands that 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 syntax is as follows:


/usr/sbin/newfs [-NTv] [mkfs_options] raw_device

The following table describes the options and arguments for the newfs command.

Table 21–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 that were used to create an existing file system. 

-T

Set the parameters of the file system to allow eventual growth to over a terabyte in total file system size. This option sets fragsize to be the same as bsize, and sets nbpi to 1 Mbyte, unless the -i option is used to make it even larger. If you use the -f or -i options to specify a fragsize or nbpi that is incompatible with this option, the user-supplied value of fragsize or nbpi is ignored.

-v

Displays the parameters that are passed to the mkfs command.

mkfs-options

Use the options in this table, from -a apc to -t track, to set the mkfs parameters. Separate the options with spaces.

-a apc

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

This option is not applicable for disks with EFI labels and is ignored. 

-b bsize

The logical block size of the file system, which is either 4096 or 8192 bytes. The default is 8192 bytes. The sun4u architecture does not support the 4096 block size. 

-c cgsize

The number of cylinders per cylinder group, which ranges from 16 to 256. The default value is calculated by dividing the number of sectors in the file system by the number of sectors in 1 Gbyte. Then, the result is multiplied by 32. The default value is always between 16 to 256. 

Use the mkfs command to override the default value.

This option is not applicable for disks with EFI labels and is ignored. 

-C maxcontig

The maximum number of logical blocks, belonging to one file, that are allocated contiguously. The default is calculated as follows: 

maxcontig = disk drive maximum transfer size / disk block size

If the disk drive maximum transfer size cannot be determined, the default value for maxcontig is calculated as follows:

If maxphys is less than ufs_maxmaxphys, which is typically 1 Mbyte, then maxcontig is set to maxphys. Otherwise, maxcontig is set to ufs_maxmaxphys.

You can set maxcontig to any positive integer value.

The actual value will be the lesser of what has been specified and what the hardware supports. 

You can subsequently change this parameter by using the tunefs command. For more information, seetunefs(1M).

-d gap

Rotational delay. This option is obsolete. The value is always set to 0, regardless of the input value. 

-f fragsize

The smallest amount of disk space in bytes that can be allocated to a file. fragsize must be a power of 2 divisor of bsize, where:

bsize / fragsize is 1, 2, 4, or 8.

This means that if the logical block size is 4096, legal values for fragsize are 512, 1024, 2048, and 4096. When the logical block size is 8192, legal values are 1024, 2048, 4096, and 8192. The default value is 1024.

For file systems greater than 1 terabyte or for file systems created with the -T option, fragsize is forced to match block size (bsize).

-i nbpi

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 number of inodes to create. 

This value should reflect the expected average size of files in the file system. If fewer inodes are needed, specify a larger number. To create more inodes, specify a smaller number. 

For the default values, see Number of Inodes (Files).

-m free

The minimum percentage of free space to maintain in the file system (between 0% and 99%, inclusively). This space is off– limits to regular users. Once the file system is filled to this threshold, only the superuser can continue writing to the file system. 

The default is ((64 Mbytes/partition size) * 100), rounded down to the nearest integer and limited between 1% and 10%, inclusively. 

This parameter can be modified after the file system is created by using the tunefs command.

-n nrpos

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

This option is not applicable for disks with EFI labels and is ignored. 

-o opt

Optimization type, space or time. The file system can either be instructed to try to minimize the time spent allocating blocks, or to try to minimize the space fragmentation on the disk. The default is time.

-r rpm

The rotational speed of the disk in revolutions per minute. This setting is driver- or device-specific. 

This parameter is converted to revolutions per second before it is passed to the mkfs command.

This option is not applicable for disks with EFI labels and is ignored. 

-s size

The size of the file system in sectors. The default is to use the entire partition. 

-t ntrack

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

This option is not applicable for disks with EFI labels and is ignored. 

raw_device

The name of a raw special device residing in the /dev directory (for example, /dev/rdsk/c0t0d0s6) on which to create the file system. This argument is required.


Example 21–1 newfs Command Options and Arguments

This example shows how to use 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 command, which then creates a file system of a specified type on a specified disk slice. Although the mkfs command can support different types of file systems, in practice you would use it to create UFS, UDFS, 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 the mkfs command directly. The mkfs command is called by the newfs command.

The generic mkfs command is located in the /usr/sbin directory. For a description of the arguments and options, see mkfs(1M).