1.\" Copyright (c) 1983, 1987, 1991, 1993, 1994 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)newfs.8 8.6 (Berkeley) 5/3/95 33.\" $FreeBSD$ 34.\" 35.Dd May 29, 2001 36.Dt NEWFS 8 37.Os 38.Sh NAME 39.Nm newfs , 40.Nd construct a new file system 41.Sh SYNOPSIS 42.Nm 43.Op Fl NOU 44.Op Fl S Ar sector-size 45.Op Fl T Ar disktype 46.Op Fl a Ar maxcontig 47.Op Fl b Ar block-size 48.Op Fl c Ar cylinders 49.Op Fl d Ar rotdelay 50.Op Fl e Ar maxbpg 51.Op Fl f Ar frag-size 52.Op Fl g Ar avgfilesize 53.Op Fl h Ar avfpdir 54.Op Fl i Ar bytes 55.Op Fl k Ar skew 56.Op Fl l Ar interleave 57.Op Fl m Ar free space 58.Op Fl n Ar rotational positions 59.Op Fl o Ar optimization 60.Op Fl p Ar sectors 61.Op Fl r Ar revolutions 62.Op Fl s Ar size 63.Op Fl t Ar tracks 64.Op Fl u Ar sectors 65.Op Fl v 66.Op Fl x Ar sectors 67.Ar special 68.Sh DESCRIPTION 69.Nm Newfs 70is used to initialize and clear filesystems before first use. 71Before running 72.Nm 73the disk must be labeled using 74.Xr disklabel 8 . 75.Nm Newfs 76builds a file system on the specified special file. 77(We often refer to the 78.Dq special file 79as the 80.Dq disk , 81although the special file need not be a physical disk. 82In fact, it need not even be special.) 83Typically the defaults are reasonable, however 84.Nm 85has numerous options to allow the defaults to be selectively overridden. 86.Pp 87The following options define the general layout policies: 88.Bl -tag -width indent 89.It Fl T Ar disktype 90For backward compatibility. 91.It Fl N 92Cause the file system parameters to be printed out 93without really creating the file system. 94.It Fl O 95Create a 96.Bx 4.3 97format filesystem. 98This options is primarily used to build root filesystems 99that can be understood by older boot ROMs. 100.It Fl U 101Enables soft updates on the new filesystem. 102.It Fl a Ar maxcontig 103Specify the maximum number of contiguous blocks that will be 104laid out before forcing a rotational delay (see the 105.Fl d 106option). 107The default value is 1. 108See 109.Xr tunefs 8 110for more details on how to set this option. 111.It Fl b Ar block-size 112The block size of the file system, in bytes. It must be a power of 2. The 113default size is 16384 bytes, and the smallest allowable size is 4096 bytes. 114The optimal block:fragment ratio is 8:1. 115Other ratios are possible, but are not recommended, 116and may produce unpredictable results. 117.It Fl c Ar #cylinders/group 118The number of cylinders per cylinder group in a file system. The default 119is to compute the maximum allowed by the other parameters. This value is 120dependent on a number of other parameters, in particular the block size 121and the number of bytes per inode. 122.It Fl d Ar rotdelay 123This parameter once specified the minimum time in milliseconds required to 124initiate another disk transfer on the same cylinder. It was used in determining 125the rotationally optimal layout for disk blocks within a file. Modern disks 126with read/write-behind achieve higher performance with this feature disabled, so 127this value should be left at the default value of 0 milliseconds. See 128.Xr tunefs 8 129for more details on how to set this option. 130.It Fl e Ar maxbpg 131Indicate the maximum number of blocks any single file can 132allocate out of a cylinder group before it is forced to begin 133allocating blocks from another cylinder group. 134The default is about one quarter of the total blocks in a cylinder group. 135See 136.Xr tunefs 8 137for more details on how to set this option. 138.It Fl f Ar frag-size 139The fragment size of the file system in bytes. It must be a power of two 140ranging in value between 141.Ar blocksize Ns /8 142and 143.Ar blocksize . 144The default is 2048 bytes. 145.It Fl g Ar avgfilesize 146The expected average file size for the file system. 147.It Fl h Ar avgfpdir 148The expected average number of files per directory on the file system. 149.It Fl i Ar number of bytes per inode 150Specify the density of inodes in the file system. 151The default is to create an inode for every 152.Pq 4 * Ar frag-size 153bytes of data space. 154If fewer inodes are desired, a larger number should be used; 155to create more inodes a smaller number should be given. 156One inode is required for each distinct file, so this value effectively 157specifies the average file size on the file system. 158.It Fl m Ar free space \&% 159The percentage of space reserved from normal users; the minimum free 160space threshold. 161The default value used is 162defined by 163.Dv MINFREE 164from 165.Aq Pa ufs/ffs/fs.h , 166currently 8%. 167See 168.Xr tunefs 8 169for more details on how to set this option. 170.It Fl n Ar number of distinguished rotational positions 171UFS has the ability to keep track of the availability of blocks at different 172rotational positions, so that it could lay out the data to be picked up with 173minimum rotational latency. This parameter specifies the default number of 174rotational positions to distinguish. 175.Pp 176Nowadays this value should be set to 1 (which essentially disables the 177rotational position table) because modern drives with read-ahead and 178write-behind do better without the rotational position table. 179.It Fl o Ar optimization\ preference 180.Pq Ar space No or Ar time . 181The file system can either be instructed to try to minimize the time spent 182allocating blocks, or to try to minimize the space fragmentation on the disk. 183If the value of minfree (see above) is less than 8%, 184the default is to optimize for 185.Ar space ; 186if the value of minfree is greater than or equal to 8%, 187the default is to optimize for 188.Ar time . 189See 190.Xr tunefs 8 191for more details on how to set this option. 192.It Fl s Ar size 193The size of the file system in sectors. This value defaults to the size of the 194raw partition specified in 195.Ar special 196(in other words, 197.Nm 198will use the entire partition for the file system). 199.It Fl v 200Specify that the disk does not contain any partitions, and that 201.Nm 202should build a file system on the whole disk. 203This option is useful for synthetic disks such as 204.Nm vinum . 205.El 206.Pp 207The following options override the standard sizes for the disk geometry. 208Their default values are taken from the disk label. 209Changing these defaults is useful only when using 210.Nm 211to build a file system whose raw image will eventually be used on a 212different type of disk than the one on which it is initially created 213(for example on a write-once disk). 214Note that changing any of these values from their defaults will make 215it impossible for 216.Xr fsck 8 217to find the alternate superblocks if the standard superblock is lost. 218.Bl -tag -width indent 219.It Fl S Ar sector-size 220The size of a sector in bytes (almost never anything but 512). 221.It Fl k Ar sector \&0 skew , per track 222Used to describe perturbations in the media format to compensate for 223a slow controller. 224Track skew is the offset of sector 0 on track N relative to sector 0 225on track N-1 on the same cylinder. 226This option is of historical importance only; modern controllers are always fast 227enough to handle operations back-to-back. 228.It Fl l Ar hardware sector interleave 229Used to describe perturbations in the media format to compensate for 230a slow controller. 231Interleave is physical sector interleave on each track, 232specified as the denominator of the ratio: 233.Dl sectors read/sectors passed over 234Thus an interleave of 1/1 implies contiguous layout, while 1/2 implies 235logical sector 0 is separated by one sector from logical sector 1. 236This option is of historical importance only; the physical sector layout of 237modern disks is not visible from outside. 238.It Fl p Ar spare sectors per track 239Spare sectors (bad sector replacements) are physical sectors that occupy 240space at the end of each track. 241They are not counted as part of the sectors/track 242.Pq Fl u 243since they are not available to the file system for data allocation. 244This option is of historical importance only. Modern disks perform their own 245bad sector allocation. 246.It Fl r Ar revolutions/minute 247The speed of the disk in revolutions per minute. This value is no longer of 248interest, since all the parameters which depend on it are usually disabled. 249.It Fl t Ar #tracks/cylinder 250The number of tracks/cylinder available for data allocation by the file 251system. 252The default is 1. 253If zero is specified, the value from the disklabel will be used. 254.It Fl u Ar sectors/track 255The number of sectors per track available for data allocation by the file 256system. 257The default is 4096. 258If zero is specified, the value from the disklabel will be used. 259This does not include sectors reserved at the end of each track for bad 260block replacement (see the 261.Fl p 262option). 263.It Fl x Ar spare sectors per cylinder 264Spare sectors (bad sector replacements) are physical sectors that occupy 265space at the end of the last track in the cylinder. 266They are deducted from the sectors/track 267.Pq Fl u 268of the last track of each cylinder since they are not available to the file 269system for data allocation. 270This option is of historical importance only. Modern disks perform their own 271bad sector allocation. 272.El 273.Sh EXAMPLES 274.Dl newfs /dev/ad3s1a 275.Pp 276Creates a new ufs file system on 277.Pa ad3s1a . 278.Nm 279will use a block size of 16384 bytes, a fragment size of 2048 bytes 280and the largest possible number of cylinders per group. 281These values tend to produce better performance for most applications 282than the historical defaults 283(8192 byte block size and 1024 byte fragment size). 284This large fragment size 285may lead to large amounts of wasted space 286on filesystems that contain a large number of small files. 287.Sh SEE ALSO 288.Xr fdformat 1 , 289.Xr disktab 5 , 290.Xr fs 5 , 291.Xr camcontrol 8 , 292.Xr disklabel 8 , 293.Xr diskpart 8 , 294.Xr dumpfs 8 , 295.Xr fsck 8 , 296.Xr mount 8 , 297.Xr tunefs 8 , 298.Xr vinum 8 299.Rs 300.%A M. McKusick 301.%A W. Joy 302.%A S. Leffler 303.%A R. Fabry 304.%T A Fast File System for UNIX 305.%J ACM Transactions on Computer Systems 2 306.%V 3 307.%P pp 181-197 308.%D August 1984 309.%O (reprinted in the BSD System Manager's Manual) 310.Re 311.Sh HISTORY 312The 313.Nm 314command appeared in 315.Bx 4.2 . 316