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.
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.
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
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.