1.\" $NetBSD: newfs.8,v 1.51 2003/04/03 14:50:35 wiz Exp $ 2.\" 3.\" Copyright (c) 1983, 1987, 1991, 1993, 1994 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)newfs.8 8.6 (Berkeley) 5/3/95 35.\" 36.Dd April 3, 2003 37.Dt NEWFS 8 38.Os 39.Sh NAME 40.Nm newfs 41.Nd construct a new file system 42.Sh SYNOPSIS 43.Nm 44.Op Fl FINZ 45.Op Fl a Ar maxcontig 46.Op Fl B Ar byte-order 47.Op Fl b Ar block-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-per-inode 53.Op Fl m Ar free-space 54.Op Fl O Ar filesystem-format 55.Op Fl o Ar optimization 56.Op Fl S Ar sector-size 57.Op Fl s Ar size 58.Op Fl T Ar disk-type 59.Op Fl v Ar volname 60.Ar special 61.Sh DESCRIPTION 62.Nm 63is used to initialize and clear file systems before first use. 64Before running 65.Nm 66the disk must be labeled using 67.Xr disklabel 8 . 68.Nm 69builds a file system on the specified special device 70basing its defaults on the information in the disk label. 71Typically the defaults are reasonable, however 72.Nm 73has numerous options to allow the defaults to be selectively overridden. 74.Pp 75Options with numeric arguments may contain an optional (case-insensitive) 76suffix: 77.Bl -tag -width 3n -offset indent -compact 78.It b 79Bytes; causes no modification. 80(Default) 81.It k 82Kilo; multiply the argument by 1024 83.It m 84Mega; multiply the argument by 1048576 85.It g 86Giga; multiply the argument by 1073741824 87.El 88.Pp 89The following options define the general layout policies. 90.Bl -tag -width Fl 91.It Fl a Ar maxcontig 92This specifies the maximum number of contiguous blocks that will be 93laid out before forcing a rotational delay (see the 94.Fl d 95option). 96The default value is 8. 97See 98.Xr tunefs 8 99for more details on how to set this option. 100.It Fl B Ar byte-order 101Specify the metadata byte order of the file system to be created. 102Valid byte orders are 103.Sq be 104and 105.Sq le . 106If no byte order is specified, the file system is created in host 107byte order. 108.It Fl b Ar block-size 109The block size of the file system, in bytes. 110It must be a power of two. 111The smallest allowable size is 4096 bytes. 112The default size depends upon the size of the file system: 113.Pp 114.Bl -tag -width "file system size" -compact -offset indent 115.It Sy "file system size" 116.Ar block-size 117.It \*[Lt] 20 MB 1184 KB 119.It \*[Lt] 1024 MB 1208 KB 121.It \*[Gt]= 1024 MB 12216 KB 123.El 124.It Fl e Ar maxbpg 125This indicates the maximum number of blocks any single file can 126allocate out of a cylinder group before it is forced to begin 127allocating blocks from another cylinder group. 128The default is about one quarter of the total blocks in a cylinder group. 129See 130.Xr tunefs 8 131for more details on how to set this option. 132.It Fl F 133Create a file system image in 134.Ar special . 135The file system size needs to be specified with 136.Dq Fl s Ar size . 137No attempts to use or update the disk label will be made. 138.It Fl f Ar frag-size 139The fragment size of the file system in bytes. 140It must be a power of two ranging in value between 141.Ar block-size Ns /8 142and 143.Ar block-size . 144The optimal 145.Ar block-size : Ns Ar frag-size 146ratio is 8:1. 147Other ratios are possible, but are not recommended, 148and may produce unpredictable results. 149The default size depends upon the size of the file system: 150.Pp 151.Bl -tag -width "file system size" -compact -offset indent 152.It Sy "file system size" 153.Ar frag-size 154.It \*[Lt] 20 MB 1550.5 KB 156.It \*[Lt] 1024 MB 1571 KB 158.It \*[Gt]= 1024 MB 1592 KB 160.El 161.It Fl g Ar avgfilesize 162The expected average file size for the file system. 163.It Fl h Ar avgfpdir 164The expected average number of files per directory on the file system. 165.It Fl I 166Do not require that the file system type listed in the disk label is 167.Ql 4.2BSD 168or 169.Ql Apple UFS . 170.It Fl i Ar bytes-per-inode 171This specifies the density of inodes in the file system. 172If fewer inodes are desired, a larger number should be used; 173to create more inodes a smaller number should be given. 174The default is to create an inode for every 175.Pq 4 * Ar frag-size 176bytes of data space: 177.Pp 178.Bl -tag -width "file system size" -compact -offset indent 179.It Sy "file system size" 180.Ar bytes-per-inode 181.It \*[Lt] 20 MB 1822 KB 183.It \*[Lt] 1024 MB 1844 KB 185.It \*[Gt]= 1024 MB 1868 KB 187.El 188.It Fl m Ar free-space 189The percentage of space reserved from normal users; the minimum free 190space threshold. 191The default value used is 5%. 192See 193.Xr tunefs 8 194for more details on how to set this option. 195.It Fl N 196Causes the file system parameters to be printed out 197without really creating the file system. 198.It Fl O Ar filesystem-format 199Select the filesystem-format 200.Bl -tag -width 3n -offset indent -compact 201.It 0 2024.3BSD; This option is primarily used to build root file systems that can be 203understood by older boot ROMs. 204.It 1 205FFS; normal fast-filesystem (default). 206.It 2 207UFS2; enhanced fast-filesystem (suited for more than 1 Terabyte capacity, 208access control lists). 209.El 210.It Fl o Ar optimization 211Optimization preference; either 212.Dq space 213or 214.Dq time . 215The file system can either be instructed to try to minimize the time spent 216allocating blocks, or to try to minimize the space fragmentation on the disk. 217If the value of minfree (see above) is less than 5%, 218the default is to optimize for space; 219if the value of minfree is greater than or equal to 5%, 220the default is to optimize for time. 221See 222.Xr tunefs 8 223for more details on how to set this option. 224.It Fl s Ar size 225The size of the file system in sectors. 226An 227.Sq s 228suffix will be interpreted as the number of sectors (the default). 229All other suffixes are interpreted as per other numeric arguments, 230except that the number is converted into sectors by dividing by the 231sector size (as specified by 232.Fl S Ar secsize ) 233after suffix interpretation. 234.It Fl T Ar disk-type 235Uses information for the specified disk from 236.Pa /etc/disktab 237instead of trying to get the information from the disk label. 238.It Fl v Ar volname 239This specifies that an Apple UFS filesystem should be created 240with the given volume name. 241.It Fl Z 242Pre-zeros the file system image created with 243.Fl F . 244This is necessary if the image is to be used by 245.Xr vnd 4 246(which doesn't support file systems with 247.Sq holes ) . 248.El 249.Pp 250The following option overrides the standard sizes for the disk geometry. 251The default value is taken from the disk label. 252Changing this default is useful only when using 253.Nm 254to build a file system whose raw image will eventually be used on a 255different type of disk than the one on which it is initially created 256(for example on a write-once disk). 257Note that changing this value from its default will make 258it impossible for 259.Xr fsck_ffs 8 260to find the alternative superblocks if the standard superblock is lost. 261.Bl -tag -width Fl 262.It Fl S Ar sector-size 263The size of a sector in bytes (almost never anything but 512). 264Defaults to 512. 265.El 266.Sh NOTES 267If the file system will be exported over NFS, the 268.Xr fsirand 8 269utility should be run after 270.Nm 271to improve security. 272.Pp 273The owner and group ids of the root node of the new file system 274are set to the effective uid and gid of the user initializing 275the file system. 276.Pp 277For the 278.Nm 279command to succeed, 280the disk label should first be updated such that the fstype field for the 281partition is set to 282.Ql 4.2BSD 283or 284.Ql Apple UFS , 285unless 286.Fl F 287or 288.Fl I 289is used. 290.Sh SEE ALSO 291.Xr disktab 5 , 292.Xr fs 5 , 293.Xr disklabel 8 , 294.Xr diskpart 8 , 295.Xr dumpfs 8 , 296.\" .Xr format 8 , 297.Xr fsck_ffs 8 , 298.Xr fsirand 8 , 299.Xr mount 8 , 300.Xr mount_mfs 8 , 301.Xr tunefs 8 302.Rs 303.%A M. McKusick 304.%A W. Joy 305.%A S. Leffler 306.%A R. Fabry 307.%T A Fast File System for UNIX , 308.%J ACM Transactions on Computer Systems 2 309.%V 3 310.%P pp 181-197 311.%D August 1984 312.%O (reprinted in the BSD System Manager's Manual) 313.Re 314.Sh HISTORY 315The 316.Nm 317command appeared in 318.Bx 4.2 . 319