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 March 21, 2008 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 EJNUln 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 p Ar partition 56.Op Fl r Ar reserved 57.Op Fl s Ar size 58.Ar special 59.Sh DESCRIPTION 60The 61.Nm 62utility is used to initialize and clear file systems before first use. 63The 64.Nm 65utility builds a file system on the specified special file. 66(We often refer to the 67.Dq special file 68as the 69.Dq disk , 70although the special file need not be a physical disk. 71In fact, it need not even be special.) 72Typically the defaults are reasonable, however 73.Nm 74has numerous options to allow the defaults to be selectively overridden. 75.Pp 76The following options define the general layout policies: 77.Bl -tag -width indent 78.It Fl E 79Erase the content of the disk before making the filesystem. 80The reserved area in front of the superblock (for bootcode) will not be erased. 81 82This is a relevant option for flash based storage devices that use 83wear levelling algorithms. 84 85NB: Erasing may take as long time as writing every sector on the disk. 86.It Fl J 87Enable journaling on the new file system via gjournal. 88.It Fl L Ar volname 89Add a volume label to the new file system. 90.It Fl N 91Cause the file system parameters to be printed out 92without really creating the file system. 93.It Fl O Ar filesystem-type 94Use 1 to specify that a UFS1 format file system be built; 95use 2 to specify that a UFS2 format file system be built. 96The default format is UFS2. 97.It Fl T Ar disktype 98For backward compatibility. 99.It Fl U 100Enable soft updates on the new file system. 101.It Fl a Ar maxcontig 102Specify the maximum number of contiguous blocks that will be 103laid out before forcing a rotational delay. 104The default value is 16. 105See 106.Xr tunefs 8 107for more details on how to set this option. 108.It Fl b Ar block-size 109The block size of the file system, in bytes. 110It must be a power of 2. 111The 112default size is 16384 bytes, and the smallest allowable size is 4096 bytes. 113The optimal block:fragment ratio is 8:1. 114Other ratios are possible, but are not recommended, 115and may produce poor results. 116.It Fl c Ar blocks-per-cylinder-group 117The number of blocks per cylinder group in a file system. 118The default is to compute the maximum allowed by the other parameters. 119This 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 max-extent-size 123The file system may choose to store large files using extents. 124This parameter specifies the largest extent size that may be used. 125It is presently limited to its default value which is 16 times 126the file system blocksize. 127.It Fl e Ar maxbpg 128Indicate the maximum number of blocks any single file can 129allocate out of a cylinder group before it is forced to begin 130allocating blocks from another cylinder group. 131The default is about one quarter of the total blocks in a cylinder group. 132See 133.Xr tunefs 8 134for more details on how to set this option. 135.It Fl f Ar frag-size 136The fragment size of the file system in bytes. 137It must be a power of two 138ranging in value between 139.Ar blocksize Ns /8 140and 141.Ar blocksize . 142The default is 2048 bytes. 143.It Fl g Ar avgfilesize 144The expected average file size for the file system. 145.It Fl h Ar avgfpdir 146The expected average number of files per directory on the file system. 147.It Fl i Ar bytes 148Specify the density of inodes in the file system. 149The default is to create an inode for every 150.Pq 4 * Ar frag-size 151bytes of data space. 152If fewer inodes are desired, a larger number should be used; 153to create more inodes a smaller number should be given. 154One inode is required for each distinct file, so this value effectively 155specifies the average file size on the file system. 156.It Fl l 157Enable multilabel MAC on the new 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.In ufs/ffs/fs.h , 166currently 8%. 167See 168.Xr tunefs 8 169for more details on how to set this option. 170.It Fl n 171Do not create a 172.Pa .snap 173directory on the new file system. 174The resulting file system will not support snapshot generation, so 175.Xr dump 8 176in live mode and background 177.Xr fsck 8 178will not function properly. 179The traditional 180.Xr fsck 8 181and offline 182.Xr dump 8 183will work on the file system. 184This option is intended primarily for memory or vnode-backed file systems that 185do not require 186.Xr dump 8 187or 188.Xr fsck 8 189support. 190.It Fl o Ar optimization 191.Cm ( space 192or 193.Cm time ) . 194The file system can either be instructed to try to minimize the time spent 195allocating blocks, or to try to minimize the space fragmentation on the disk. 196If the value of minfree (see above) is less than 8%, 197the default is to optimize for 198.Cm space ; 199if the value of minfree is greater than or equal to 8%, 200the default is to optimize for 201.Cm time . 202See 203.Xr tunefs 8 204for more details on how to set this option. 205.It Fl p Ar partition 206The partition name (a..h) you want to use in case the underlying image 207is a file, so you don't have access to individual partitions through the 208filesystem. 209Can also be used with a device, e.g. 210.Nm 211.Fl p Ar f 212.Ar /dev/da1s3 213is equivalent to 214.Nm 215.Ar /dev/da1s3f . 216.It Fl r Ar reserved 217The size, in sectors, of reserved space 218at the end of the partition specified in 219.Ar special . 220This space will not be occupied by the file system; 221it can be used by other consumers such as 222.Xr geom 4 . 223Defaults to 0. 224.It Fl s Ar size 225The size of the file system in sectors. 226This value defaults to the size of the 227raw partition specified in 228.Ar special 229less the 230.Ar reserved 231space at its end (see 232.Fl r ) . 233A 234.Ar size 235of 0 can also be used to choose the default value. 236A valid 237.Ar size 238value cannot be larger than the default one, 239which means that the file system cannot extend into the reserved space. 240.El 241.Pp 242The following options override the standard sizes for the disk geometry. 243Their default values are taken from the disk label. 244Changing these defaults is useful only when using 245.Nm 246to build a file system whose raw image will eventually be used on a 247different type of disk than the one on which it is initially created 248(for example on a write-once disk). 249Note that changing any of these values from their defaults will make 250it impossible for 251.Xr fsck 8 252to find the alternate superblocks if the standard superblock is lost. 253.Bl -tag -width indent 254.It Fl S Ar sector-size 255The size of a sector in bytes (almost never anything but 512). 256.El 257.Sh EXAMPLES 258.Dl newfs /dev/ad3s1a 259.Pp 260Creates a new ufs file system on 261.Pa ad3s1a . 262The 263.Nm 264utility will use a block size of 16384 bytes, a fragment size of 2048 bytes 265and the largest possible number of blocks per cylinders group. 266These values tend to produce better performance for most applications 267than the historical defaults 268(8192 byte block size and 1024 byte fragment size). 269This large fragment size may lead to much wasted space 270on file systems that contain many small files. 271.Sh SEE ALSO 272.Xr fdformat 1 , 273.Xr geom 4 , 274.Xr disktab 5 , 275.Xr fs 5 , 276.Xr bsdlabel 8 , 277.Xr camcontrol 8 , 278.Xr dump 8 , 279.Xr dumpfs 8 , 280.Xr fsck 8 , 281.Xr mount 8 , 282.Xr tunefs 8 , 283.Xr gvinum 8 284.Rs 285.%A M. McKusick 286.%A W. Joy 287.%A S. Leffler 288.%A R. Fabry 289.%T A Fast File System for UNIX 290.%J ACM Transactions on Computer Systems 2 291.%V 3 292.%P pp 181-197 293.%D August 1984 294.%O (reprinted in the BSD System Manager's Manual) 295.Re 296.Sh HISTORY 297The 298.Nm 299utility appeared in 300.Bx 4.2 . 301