1.\" $NetBSD: newfs.8,v 1.82 2011/05/14 19:46:10 dholland 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. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" @(#)newfs.8 8.6 (Berkeley) 5/3/95 31.\" 32.Dd May 14, 2011 33.Dt NEWFS 8 34.Os 35.Sh NAME 36.Nm newfs 37.Nd construct a new file system 38.Sh SYNOPSIS 39.Nm 40.Op Fl FGINZ 41.Op Fl a Ar maxcontig 42.Op Fl B Ar byte-order 43.Op Fl b Ar block-size 44.Op Fl d Ar maxbsize 45.Op Fl e Ar maxbpg 46.Op Fl f Ar frag-size 47.Op Fl g Ar avgfilesize 48.Op Fl h Ar avgfpdir 49.Op Fl i Ar bytes-per-inode 50.Op Fl m Ar free-space 51.Op Fl n Ar inodes 52.Op Fl O Ar filesystem-format 53.Op Fl o Ar optimization 54.Op Fl q Ar quota 55.Op Fl S Ar sector-size 56.Op Fl s Ar size 57.Op Fl T Ar disk-type 58.Op Fl v Ar volname 59.Op Fl V Ar verbose 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.It t 88Tera; multiply the argument by 1099511627776. 89.El 90.Pp 91The following options define the general layout policies. 92.Bl -tag -width Fl 93.It Fl a Ar maxcontig 94This sets the obsolete maxcontig parameter. 95.It Fl B Ar byte-order 96Specify the metadata byte order of the file system to be created. 97Valid byte orders are 98.Sq be 99and 100.Sq le . 101If no byte order is specified, the file system is created in host 102byte order. 103.It Fl b Ar block-size 104The block size of the file system, in bytes. 105It must be a power of two. 106The smallest allowable size is 4096 bytes. 107The default size depends upon the size of the file system: 108.Pp 109.Bl -tag -width "file system size" -compact -offset indent 110.It Sy "file system size" 111.Ar block-size 112.It \*[Lt] 20 MB 1134 KB 114.It \*[Lt] 1024 MB 1158 KB 116.It \*[Gt]= 1024 MB 11716 KB 118.El 119.It Fl d Ar maxbsize 120Set the maximum extent size to 121.Ar maxbsize . 122.It Fl e Ar maxbpg 123This indicates 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 131Create a file system image in 132.Ar special . 133The file system size needs to be specified with 134.Dq Fl s Ar size . 135No attempts to use or update the disk label will be made. 136.It Fl f Ar frag-size 137The fragment size of the file system in bytes. 138It must be a power of two ranging in value between 139.Ar block-size Ns /8 140and 141.Ar block-size . 142The optimal 143.Ar block-size : Ns Ar frag-size 144ratio is 8:1. 145Other ratios are possible, but are not recommended, 146and may produce unpredictable results. 147The default size depends upon the size of the file system: 148.Pp 149.Bl -tag -width "file system size" -compact -offset indent 150.It Sy "file system size" 151.Ar frag-size 152.It \*[Lt] 20 MB 1530.5 KB 154.It \*[Lt] 1024 MB 1551 KB 156.It \*[Gt]= 1024 MB 1572 KB 158.El 159.It Fl G 160Treat garbage parameters as non-fatal. 161Using this option may result in a file system which causes a kernel 162panic and should only be used for testing. 163.It Fl g Ar avgfilesize 164The expected average file size for the file system. 165.It Fl h Ar avgfpdir 166The expected average number of files per directory on the file system. 167.It Fl I 168Do not require that the file system type listed in the disk label is 169.Ql 4.2BSD 170or 171.Ql Apple UFS . 172.It Fl i Ar bytes-per-inode 173This specifies the density of inodes in the file system. 174If fewer inodes are desired, a larger number should be used; 175to create more inodes a smaller number should be given. 176The default is to create an inode for every 177.Pq 4 * Ar frag-size 178bytes of data space: 179.Pp 180.Bl -tag -width "file system size" -compact -offset indent 181.It Sy "file system size" 182.Ar bytes-per-inode 183.It \*[Lt] 20 MB 1842 KB 185.It \*[Lt] 1024 MB 1864 KB 187.It \*[Gt]= 1024 MB 1888 KB 189.El 190.It Fl m Ar free-space 191The percentage of space reserved from normal users; the minimum free 192space threshold. 193The default value used is 5%. 194See 195.Xr tunefs 8 196for more details on how to set this option. 197.It Fl N 198Causes the file system parameters to be printed out 199without really creating the file system. 200.It Fl n Ar inodes 201This specifies the number of inodes for the filesystem. 202If both 203.Fl i 204and 205.Fl n 206are specified then 207.Fl n 208takes precedence. 209.It Fl O Ar filesystem-format 210Select the filesystem-format. 211.Bl -tag -width 3n -offset indent -compact 212.It 0 2134.3BSD; This option is primarily used to build root file systems that can be 214understood by older boot ROMs. 215This generates an FFSv1 file system with level 1 format. 216.It 1 217FFSv1; normal Fast File System, level 4 format. 218Also known as 219.Sq FFS , 220.Sq UFS , 221or 222.Sq UFS1 . 223This is the default. 224.It 2 225FFSv2; enhanced Fast File System, suited for more than 1 Terabyte capacity. 226.\" Supports access control lists. 227This is also known as 228.Sq UFS2 . 229.El 230See 231.Xr fsck_ffs 8 232for more information about format levels. 233.Pp 234To create an LFS filesystem see 235.Xr newfs_lfs 8 . 236To create a Linux ext2 filesystem see 237.Xr newfs_ext2fs 8 . 238.It Fl o Ar optimization 239Optimization preference; either 240.Dq space 241or 242.Dq time . 243The file system can either be instructed to try to minimize the time spent 244allocating blocks, or to try to minimize the space fragmentation on the disk. 245If the value of minfree (see above) is less than 5%, 246the default is to optimize for space; 247if the value of minfree is greater than or equal to 5%, 248the default is to optimize for time. 249See 250.Xr tunefs 8 251for more details on how to set this option. 252.It Fl q Ar quota 253enable a quota. 254.Ar quota 255can be one of 256.Li user 257or 258.Li group 259to enable the specified quota type. 260Multiple 261.Fl q 262can be used to enable all types at once. 263.It Fl s Ar size 264The size of the file system in sectors. 265An 266.Sq s 267suffix will be interpreted as the number of sectors (the default). 268All other suffixes are interpreted as per other numeric arguments, 269except that the number is converted into sectors by dividing by the 270sector size (as specified by 271.Fl S Ar secsize ) 272after suffix interpretation. 273.Pp 274If no 275.Fl s Ar size 276is specified then the filesystem size defaults to that of the partition, or, 277if 278.Fl F 279is specified, the existing file. 280.Pp 281If 282.Ar size 283is negative the specified size is subtracted from the default size 284(reserving space at the end of the partition). 285.It Fl T Ar disk-type 286Uses information for the specified disk from 287.Pa /etc/disktab 288instead of trying to get the information from the disk label. 289.It Fl V Ar verbose 290This controls the amount of information written to stdout: 291.Bl -tag -width 3n -offset indent -compact 292.It 0 293No output. 294.It 1 295Overall size and cylinder group details. 296.It 2 297A progress bar (dots ending at right hand margin). 298.It 3 299The first few super-block backup sector numbers are displayed before the 300progress bar. 301.It 4 302All the super-block backup sector numbers are displayed (no progress bar). 303.El 304The default is 3. 305If 306.Fl N 307is specified 308.Nm 309stops before outputting the progress bar. 310.It Fl v Ar volname 311This specifies that an Apple UFS filesystem should be created 312with the given volume name. 313.It Fl Z 314Pre-zeros the file system image created with 315.Fl F . 316This is necessary if the image is to be used by 317.Xr vnd 4 318(which doesn't support file systems with 319.Sq holes ) . 320.El 321.Pp 322The following option overrides the standard sizes for the disk geometry. 323The default value is taken from the disk label. 324Changing this default is useful only when using 325.Nm 326to build a file system whose raw image will eventually be used on a 327different type of disk than the one on which it is initially created 328(for example on a write-once disk). 329Note that changing this value from its default will make 330it impossible for 331.Xr fsck_ffs 8 332to find the alternative superblocks if the standard superblock is lost. 333.Bl -tag -width Fl 334.It Fl S Ar sector-size 335The size of a sector in bytes (almost never anything but 512). 336Defaults to 512. 337.El 338.Sh NOTES 339The file system is created with 340.Sq random 341inode generation numbers to improve NFS security. 342.Pp 343The owner and group IDs of the root node of the new file system 344are set to the effective UID and GID of the user initializing 345the file system. 346.Pp 347For the 348.Nm 349command to succeed, 350the disk label should first be updated such that the fstype field for the 351partition is set to 352.Ql 4.2BSD 353or 354.Ql Apple UFS , 355unless 356.Fl F 357or 358.Fl I 359is used. 360.Pp 361To create and populate a filesystem image within a file use the 362.Xr makefs 8 363utility. 364.Pp 365The partition size is found using 366.Xr fstat 2 , 367not by inspecting the disk label. 368The block size and fragment size will be written back to the disk label 369only if the last character of 370.Ar special 371references the same partition as the minor device number. 372.Pp 373Unless 374.Fl F 375is specified, 376.Ar special 377must be a raw device. 378This means that for example 379.Pa wd0a 380or 381.Pa /dev/rwd0a 382must be specified instead of 383.Pa /dev/wd0a . 384.Sh SEE ALSO 385.Xr fstat 2 , 386.Xr disktab 5 , 387.Xr fs 5 , 388.Xr disklabel 8 , 389.Xr diskpart 8 , 390.Xr dumpfs 8 , 391.\" .Xr format 8 , 392.Xr fsck_ffs 8 , 393.\" .Xr fsirand 8 , 394.Xr makefs 8 , 395.Xr mount 8 , 396.Xr mount_mfs 8 , 397.Xr newfs_ext2fs 8 , 398.Xr newfs_lfs 8 , 399.Xr newfs_msdos 8 , 400.Xr tunefs 8 401.Rs 402.%A M. McKusick 403.%A W. Joy 404.%A S. Leffler 405.%A R. Fabry 406.%T A Fast File System for UNIX , 407.%J ACM Transactions on Computer Systems 2 408.%V 3 409.%P pp 181-197 410.%D August 1984 411.%O (reprinted in the BSD System Manager's Manual) 412.Re 413.Rs 414.%A M. McKusick 415.%T Enhancements to the fast filesystem to support multi-terabyte storage systems 416.%J Proceedings of the BSD Conference 2003 417.%P pp 79-90 418.%D September 2003 419.Re 420.Sh HISTORY 421The 422.Nm 423command appeared in 424.Bx 4.2 . 425