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.\" 4. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.\" @(#)newfs.8 8.6 (Berkeley) 5/3/95 29.\" $FreeBSD$ 30.\" 31.Dd January 21, 2005 32.Dt NEWFS 8 33.Os 34.Sh NAME 35.Nm newfs 36.Nd construct a new UFS1/UFS2 file system 37.Sh SYNOPSIS 38.Nm 39.Op Fl JNUln 40.Op Fl L Ar volname 41.Op Fl O Ar filesystem-type 42.Op Fl S Ar sector-size 43.Op Fl T Ar disktype 44.Op Fl a Ar maxcontig 45.Op Fl b Ar block-size 46.Op Fl c Ar blocks-per-cylinder-group 47.Op Fl d Ar max-extent-size 48.Op Fl e Ar maxbpg 49.Op Fl f Ar frag-size 50.Op Fl g Ar avgfilesize 51.Op Fl h Ar avgfpdir 52.Op Fl i Ar bytes 53.Op Fl m Ar free-space 54.Op Fl o Ar optimization 55.Op Fl r Ar reserved 56.Op Fl s Ar size 57.Ar special 58.Sh DESCRIPTION 59The 60.Nm 61utility is used to initialize and clear file systems before first use. 62Before running 63.Nm 64the disk must be labeled using 65.Xr bsdlabel 8 . 66The 67.Nm 68utility builds a file system on the specified special file. 69(We often refer to the 70.Dq special file 71as the 72.Dq disk , 73although the special file need not be a physical disk. 74In fact, it need not even be special.) 75Typically the defaults are reasonable, however 76.Nm 77has numerous options to allow the defaults to be selectively overridden. 78.Pp 79The following options define the general layout policies: 80.Bl -tag -width indent 81.It Fl J 82Enable journaling on the new file system via gjournal. 83.It Fl L Ar volname 84Add a volume label to the new file system. 85.It Fl N 86Cause the file system parameters to be printed out 87without really creating the file system. 88.It Fl O Ar filesystem-type 89Use 1 to specify that a UFS1 format file system be built; 90use 2 to specify that a UFS2 format file system be built. 91The default format is UFS2. 92.It Fl T Ar disktype 93For backward compatibility. 94.It Fl U 95Enable soft updates on the new file system. 96.It Fl a Ar maxcontig 97Specify the maximum number of contiguous blocks that will be 98laid out before forcing a rotational delay. 99The default value is 16. 100See 101.Xr tunefs 8 102for more details on how to set this option. 103.It Fl b Ar block-size 104The block size of the file system, in bytes. 105It must be a power of 2. 106The 107default size is 16384 bytes, and the smallest allowable size is 4096 bytes. 108The optimal block:fragment ratio is 8:1. 109Other ratios are possible, but are not recommended, 110and may produce poor results. 111.It Fl c Ar blocks-per-cylinder-group 112The number of blocks per cylinder group in a file system. 113The default is to compute the maximum allowed by the other parameters. 114This value is 115dependent on a number of other parameters, in particular the block size 116and the number of bytes per inode. 117.It Fl d Ar max-extent-size 118The file system may choose to store large files using extents. 119This parameter specifies the largest extent size that may be used. 120It is presently limited to its default value which is 16 times 121the file system blocksize. 122.It Fl e Ar maxbpg 123Indicate the maximum number of blocks any single file can 124allocate out of a cylinder group before it is forced to begin 125allocating blocks from another cylinder group. 126The default is about one quarter of the total blocks in a cylinder group. 127See 128.Xr tunefs 8 129for more details on how to set this option. 130.It Fl f Ar frag-size 131The fragment size of the file system in bytes. 132It must be a power of two 133ranging in value between 134.Ar blocksize Ns /8 135and 136.Ar blocksize . 137The default is 2048 bytes. 138.It Fl g Ar avgfilesize 139The expected average file size for the file system. 140.It Fl h Ar avgfpdir 141The expected average number of files per directory on the file system. 142.It Fl i Ar bytes 143Specify the density of inodes in the file system. 144The default is to create an inode for every 145.Pq 4 * Ar frag-size 146bytes of data space. 147If fewer inodes are desired, a larger number should be used; 148to create more inodes a smaller number should be given. 149One inode is required for each distinct file, so this value effectively 150specifies the average file size on the file system. 151.It Fl l 152Enable multilabel MAC on the new file system. 153.It Fl m Ar free-space 154The percentage of space reserved from normal users; the minimum free 155space threshold. 156The default value used is 157defined by 158.Dv MINFREE 159from 160.In ufs/ffs/fs.h , 161currently 8%. 162See 163.Xr tunefs 8 164for more details on how to set this option. 165.It Fl n 166Do not create a 167.Pa .snap 168directory on the new file system. 169The resulting file system will not support snapshot generation, so 170.Xr dump 8 171in live mode and background 172.Xr fsck 8 173will not function properly. 174The traditional 175.Xr fsck 8 176and offline 177.Xr dump 8 178will work on the file system. 179This option is intended primarily for memory or vnode-backed file systems that 180do not require 181.Xr dump 8 182or 183.Xr fsck 8 184support. 185.It Fl o Ar optimization 186.Cm ( space 187or 188.Cm time ) . 189The file system can either be instructed to try to minimize the time spent 190allocating blocks, or to try to minimize the space fragmentation on the disk. 191If the value of minfree (see above) is less than 8%, 192the default is to optimize for 193.Cm space ; 194if the value of minfree is greater than or equal to 8%, 195the default is to optimize for 196.Cm time . 197See 198.Xr tunefs 8 199for more details on how to set this option. 200.It Fl r Ar reserved 201The size, in sectors, of reserved space 202at the end of the partition specified in 203.Ar special . 204This space will not be occupied by the file system; 205it can be used by other consumers such as 206.Xr geom 4 . 207Defaults to 0. 208.It Fl s Ar size 209The size of the file system in sectors. 210This value defaults to the size of the 211raw partition specified in 212.Ar special 213less the 214.Ar reserved 215space at its end (see 216.Fl r ) . 217A 218.Ar size 219of 0 can also be used to choose the default value. 220A valid 221.Ar size 222value cannot be larger than the default one, 223which means that the file system cannot extend into the reserved space. 224.El 225.Pp 226The following options override the standard sizes for the disk geometry. 227Their default values are taken from the disk label. 228Changing these defaults is useful only when using 229.Nm 230to build a file system whose raw image will eventually be used on a 231different type of disk than the one on which it is initially created 232(for example on a write-once disk). 233Note that changing any of these values from their defaults will make 234it impossible for 235.Xr fsck 8 236to find the alternate superblocks if the standard superblock is lost. 237.Bl -tag -width indent 238.It Fl S Ar sector-size 239The size of a sector in bytes (almost never anything but 512). 240.El 241.Sh EXAMPLES 242.Dl newfs /dev/ad3s1a 243.Pp 244Creates a new ufs file system on 245.Pa ad3s1a . 246The 247.Nm 248utility will use a block size of 16384 bytes, a fragment size of 2048 bytes 249and the largest possible number of blocks per cylinders group. 250These values tend to produce better performance for most applications 251than the historical defaults 252(8192 byte block size and 1024 byte fragment size). 253This large fragment size may lead to much wasted space 254on file systems that contain many small files. 255.Sh SEE ALSO 256.Xr fdformat 1 , 257.Xr geom 4 , 258.Xr disktab 5 , 259.Xr fs 5 , 260.Xr bsdlabel 8 , 261.Xr camcontrol 8 , 262.Xr dump 8 , 263.Xr dumpfs 8 , 264.Xr fsck 8 , 265.Xr mount 8 , 266.Xr tunefs 8 , 267.Xr vinum 8 268.Rs 269.%A M. McKusick 270.%A W. Joy 271.%A S. Leffler 272.%A R. Fabry 273.%T A Fast File System for UNIX 274.%J ACM Transactions on Computer Systems 2 275.%V 3 276.%P pp 181-197 277.%D August 1984 278.%O (reprinted in the BSD System Manager's Manual) 279.Re 280.Sh HISTORY 281The 282.Nm 283utility appeared in 284.Bx 4.2 . 285