The mkfs Command

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> 

Its options are described in Table 14.2.

Table 14.2. 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.
N Prints 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 selected from the range 512 to the logical block size. 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 percent; 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 I-node, which specifies the density of I-nodes in the file system. The number is divided into the total size of the file system to determine the fixed number of I-nodes to create. It should reflect the expected average size of files in the file system. If fewer I-nodes are desired, a larger number should be used. To create more I-nodes, 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 percent full.
gap=<milliseconds> Rotational delay, specified in milliseconds. Indicates the expected time (in milliseconds) required to service a transfer completion interrupt and to initiate a new transfer on the same disk.The value is used to decide how much rotational spacing to place between successive blocks in a file.The actual disk used determines the default.
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 is 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/c0t0d0s0 

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

newfs: construct a new file system /dev/rdsk/c0t0d0s0: (y/n)? y 
mkfs -F ufs /dev/rdsk/c0t0d0s0 2097576 117 9 8192 1024 32 6 90 4096 t 0 -1 8 15 
/dev/rdsk/c0t0d0s0: 2097576 sectors in 1992 cylinders of 9 tracks, 117 sectors 
1024.2MB in 63 cyl groups (32 c/g, 16.45MB/g, 4096 i/g) 
super-block backups (for fsck -F ufs -o b=#) at: 
32, 33856, 67680, 101504, 135328, 169152, 202976, 236800, 270624, 304448, 
338272, 372096, 405920, 439744, 473568, 507392, 539168, 572992, 606816, 
640640, 674464, 708288, 742112, 775936, 809760, 843584, 877408, 911232, 
945056, 978880, 1012704, 1046528, 1078304, 1112128, 1145952, 1179776, 1213600, 
1247424, 1281248, 1315072, 1348896, 1382720, 1416544, 1450368, 1484192, 
1518016, 1551840, 1585664, 1617440, 1651264, 1685088, 1718912, 1752736, 
1786560, 1820384, 1854208, 1888032, 1921856, 1955680, 1989504, 2023328, 
2057152, 2090976, 

You’ll see in the output that all the mkfs parameters used to create the file system are displayed, as is the location of each backup copy of the superblock.

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

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.


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

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