xref: /netbsd-src/sbin/newfs/newfs.8 (revision 87ba0e2a319653af510fae24a6d2975d3589735b)
1*87ba0e2aSchs.\"	$NetBSD: newfs.8,v 1.86 2022/11/17 06:40:39 chs Exp $
20114e805Scgd.\"
3625a6892Smycroft.\" Copyright (c) 1983, 1987, 1991, 1993, 1994
4625a6892Smycroft.\"	The Regents of the University of California.  All rights reserved.
561f28255Scgd.\"
661f28255Scgd.\" Redistribution and use in source and binary forms, with or without
761f28255Scgd.\" modification, are permitted provided that the following conditions
861f28255Scgd.\" are met:
961f28255Scgd.\" 1. Redistributions of source code must retain the above copyright
1061f28255Scgd.\"    notice, this list of conditions and the following disclaimer.
1161f28255Scgd.\" 2. Redistributions in binary form must reproduce the above copyright
1261f28255Scgd.\"    notice, this list of conditions and the following disclaimer in the
1361f28255Scgd.\"    documentation and/or other materials provided with the distribution.
14276d62f6Sagc.\" 3. Neither the name of the University nor the names of its contributors
1561f28255Scgd.\"    may be used to endorse or promote products derived from this software
1661f28255Scgd.\"    without specific prior written permission.
1761f28255Scgd.\"
1861f28255Scgd.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1961f28255Scgd.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2061f28255Scgd.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2161f28255Scgd.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2261f28255Scgd.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2361f28255Scgd.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2461f28255Scgd.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2561f28255Scgd.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2661f28255Scgd.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2761f28255Scgd.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2861f28255Scgd.\" SUCH DAMAGE.
2961f28255Scgd.\"
30ec31f794Slukem.\"     @(#)newfs.8	8.6 (Berkeley) 5/3/95
31346aa5ddScgd.\"
322c4214cbSmaya.Dd April 13, 2019
3361f28255Scgd.Dt NEWFS 8
3473f545bbSwiz.Os
3561f28255Scgd.Sh NAME
3604e7d8d5Slukem.Nm newfs
3761f28255Scgd.Nd construct a new file system
3861f28255Scgd.Sh SYNOPSIS
39990562bfSwiz.Nm
40f87f7774Spooka.Op Fl FGINZ
418a207c6eSmikel.Op Fl a Ar maxcontig
424abefdc1Swiz.Op Fl B Ar byte-order
43625a6892Smycroft.Op Fl b Ar block-size
4495ffcf31Swiz.Op Fl d Ar maxbsize
45625a6892Smycroft.Op Fl e Ar maxbpg
46625a6892Smycroft.Op Fl f Ar frag-size
475c2ee586Slukem.Op Fl g Ar avgfilesize
485c2ee586Slukem.Op Fl h Ar avgfpdir
4914929f77Slukem.Op Fl i Ar bytes-per-inode
5014929f77Slukem.Op Fl m Ar free-space
51a8376531Sdsl.Op Fl n Ar inodes
524abefdc1Swiz.Op Fl O Ar filesystem-format
53625a6892Smycroft.Op Fl o Ar optimization
54063f96f3Sbouyer.Op Fl q Ar quota
554abefdc1Swiz.Op Fl S Ar sector-size
56625a6892Smycroft.Op Fl s Ar size
574abefdc1Swiz.Op Fl T Ar disk-type
5843395bd5Sdbj.Op Fl v Ar volname
59afbe178eSdsl.Op Fl V Ar verbose
6061f28255Scgd.Ar special
6161f28255Scgd.Sh DESCRIPTION
621a96f83dSlukem.Nm
633e209fc8Slukemis used to initialize and clear file systems before first use.
6461f28255ScgdBefore running
651a96f83dSlukem.Nm
6661f28255Scgdthe disk must be labeled using
6761f28255Scgd.Xr disklabel 8 .
681a96f83dSlukem.Nm
6961f28255Scgdbuilds a file system on the specified special device
7061f28255Scgdbasing its defaults on the information in the disk label.
7161f28255ScgdTypically the defaults are reasonable, however
721a96f83dSlukem.Nm
7361f28255Scgdhas numerous options to allow the defaults to be selectively overridden.
7461f28255Scgd.Pp
7514929f77SlukemOptions with numeric arguments may contain an optional (case-insensitive)
7614929f77Slukemsuffix:
7714929f77Slukem.Bl -tag -width 3n -offset indent -compact
7814929f77Slukem.It b
792fb4b1dbSwizBytes; causes no modification.
802fb4b1dbSwiz(Default)
8114929f77Slukem.It k
8240effc38SwizKilo; multiply the argument by 1024.
8314929f77Slukem.It m
8440effc38SwizMega; multiply the argument by 1048576.
8514929f77Slukem.It g
8640effc38SwizGiga; multiply the argument by 1073741824.
878e5470fdSsimonb.It t
8840effc38SwizTera; multiply the argument by 1099511627776.
8914929f77Slukem.El
9014929f77Slukem.Pp
9161f28255ScgdThe following options define the general layout policies.
9261f28255Scgd.Bl -tag -width Fl
9361f28255Scgd.It Fl a Ar maxcontig
94fb059bb1SpeterThis sets the obsolete maxcontig parameter.
954abefdc1Swiz.It Fl B Ar byte-order
964abefdc1SwizSpecify the metadata byte order of the file system to be created.
974abefdc1SwizValid byte orders are
984abefdc1Swiz.Sq be
994abefdc1Swizand
1004abefdc1Swiz.Sq le .
1014abefdc1SwizIf no byte order is specified, the file system is created in host
1024abefdc1Swizbyte order.
103625a6892Smycroft.It Fl b Ar block-size
104625a6892SmycroftThe block size of the file system, in bytes.
10586c0243fSlukemIt must be a power of two.
10614fb096dSlukemThe smallest allowable size is 4096 bytes.
10714fb096dSlukemThe default size depends upon the size of the file system:
10814fb096dSlukem.Pp
10914fb096dSlukem.Bl -tag -width "file system size" -compact -offset indent
11014fb096dSlukem.It Sy "file system size"
11114fb096dSlukem.Ar block-size
11201869ca4Swiz.It < 20 MB
11314fb096dSlukem4 KB
11401869ca4Swiz.It < 1000 MB
11514fb096dSlukem8 KB
11601869ca4Swiz.It < 128 GB
11714fb096dSlukem16 KB
11801869ca4Swiz.It >= 128 GB
119c0aba6b3Stsutsui32 KB
12014fb096dSlukem.El
12195ffcf31Swiz.It Fl d Ar maxbsize
12295ffcf31SwizSet the maximum extent size to
12395ffcf31Swiz.Ar maxbsize .
12461f28255Scgd.It Fl e Ar maxbpg
12561f28255ScgdThis indicates the maximum number of blocks any single file can
12661f28255Scgdallocate out of a cylinder group before it is forced to begin
12761f28255Scgdallocating blocks from another cylinder group.
12861f28255ScgdThe default is about one quarter of the total blocks in a cylinder group.
12961f28255ScgdSee
13061f28255Scgd.Xr tunefs 8
13161f28255Scgdfor more details on how to set this option.
1324abefdc1Swiz.It Fl F
1334abefdc1SwizCreate a file system image in
1344abefdc1Swiz.Ar special .
1354abefdc1SwizThe file system size needs to be specified with
1364abefdc1Swiz.Dq Fl s Ar size .
1374abefdc1SwizNo attempts to use or update the disk label will be made.
138625a6892Smycroft.It Fl f Ar frag-size
139625a6892SmycroftThe fragment size of the file system in bytes.
14086c0243fSlukemIt must be a power of two ranging in value between
14186c0243fSlukem.Ar block-size Ns /8
14286c0243fSlukemand
14386c0243fSlukem.Ar block-size .
14486c0243fSlukemThe optimal
1452ae34280Swiz.Ar block-size : Ns Ar frag-size
14686c0243fSlukemratio is 8:1.
14786c0243fSlukemOther ratios are possible, but are not recommended,
14886c0243fSlukemand may produce unpredictable results.
14914fb096dSlukemThe default size depends upon the size of the file system:
15014fb096dSlukem.Pp
15114fb096dSlukem.Bl -tag -width "file system size" -compact -offset indent
15214fb096dSlukem.It Sy "file system size"
15314fb096dSlukem.Ar frag-size
15401869ca4Swiz.It < 20 MB
15514fb096dSlukem0.5 KB
15601869ca4Swiz.It < 1000 MB
15714fb096dSlukem1 KB
15801869ca4Swiz.It < 128 GB
15914fb096dSlukem2 KB
16001869ca4Swiz.It >= 128 GB
161c0aba6b3Stsutsui4 KB
16214fb096dSlukem.El
163f87f7774Spooka.It Fl G
164f87f7774SpookaTreat garbage parameters as non-fatal.
165f87f7774SpookaUsing this option may result in a file system which causes a kernel
166f87f7774Spookapanic and should only be used for testing.
167ed08a55dSwiz.It Fl g Ar avgfilesize
168ed08a55dSwizThe expected average file size for the file system.
1695c2ee586Slukem.It Fl h Ar avgfpdir
1705c2ee586SlukemThe expected average number of files per directory on the file system.
1714abefdc1Swiz.It Fl I
1724abefdc1SwizDo not require that the file system type listed in the disk label is
1734abefdc1Swiz.Ql 4.2BSD
1744abefdc1Swizor
1754abefdc1Swiz.Ql Apple UFS .
17614929f77Slukem.It Fl i Ar bytes-per-inode
17761f28255ScgdThis specifies the density of inodes in the file system.
17861f28255ScgdIf fewer inodes are desired, a larger number should be used;
17961f28255Scgdto create more inodes a smaller number should be given.
18014fb096dSlukemThe default is to create an inode for every
18114fb096dSlukem.Pq 4 * Ar frag-size
18214fb096dSlukembytes of data space:
18314fb096dSlukem.Pp
18414fb096dSlukem.Bl -tag -width "file system size" -compact -offset indent
18514fb096dSlukem.It Sy "file system size"
18614fb096dSlukem.Ar bytes-per-inode
18701869ca4Swiz.It < 20 MB
18814fb096dSlukem2 KB
18901869ca4Swiz.It < 1000 MB
19014fb096dSlukem4 KB
19101869ca4Swiz.It < 128 GB
19214fb096dSlukem8 KB
19301869ca4Swiz.It >= 128 GB
194c0aba6b3Stsutsui16 KB
19514fb096dSlukem.El
19614929f77Slukem.It Fl m Ar free-space
197625a6892SmycroftThe percentage of space reserved from normal users; the minimum free
198625a6892Smycroftspace threshold.
1999be9a14cSmrgThe default value used is 5%.
200625a6892SmycroftSee
201625a6892Smycroft.Xr tunefs 8
202625a6892Smycroftfor more details on how to set this option.
2034abefdc1Swiz.It Fl N
2044abefdc1SwizCauses the file system parameters to be printed out
2054abefdc1Swizwithout really creating the file system.
206a8376531Sdsl.It Fl n Ar inodes
207a8376531SdslThis specifies the number of inodes for the filesystem.
208a8376531SdslIf both
209a8376531Sdsl.Fl i
210a8376531Sdsland
211a8376531Sdsl.Fl n
212a8376531Sdslare specified then
213a8376531Sdsl.Fl n
214a8376531Sdsltakes precedence.
2154abefdc1Swiz.It Fl O Ar filesystem-format
21640effc38SwizSelect the filesystem-format.
2174abefdc1Swiz.Bl -tag -width 3n -offset indent -compact
2184abefdc1Swiz.It 0
2194abefdc1Swiz4.3BSD; This option is primarily used to build root file systems that can be
2204abefdc1Swizunderstood by older boot ROMs.
221aae84c3aSdhollandThis generates an FFSv1 file system with level 1 format.
2224abefdc1Swiz.It 1
223aae84c3aSdhollandFFSv1; normal Fast File System, level 4 format.
224aae84c3aSdhollandAlso known as
2252a895843Slukem.Sq FFS ,
2262a895843Slukem.Sq UFS ,
2272a895843Slukemor
2282a895843Slukem.Sq UFS1 .
229aae84c3aSdhollandThis is the default.
2304abefdc1Swiz.It 2
231aae84c3aSdhollandFFSv2; enhanced Fast File System, suited for more than 1 Terabyte capacity.
2322a895843SlukemThis is also known as
2332a895843Slukem.Sq UFS2 .
234*87ba0e2aSchs.It 2ea
235*87ba0e2aSchsFFSv2 plus support for extended attributes and access control lists.
2364abefdc1Swiz.El
237aae84c3aSdhollandSee
238aae84c3aSdholland.Xr fsck_ffs 8
239aae84c3aSdhollandfor more information about format levels.
240aae84c3aSdholland.Pp
24104dec52cSdslTo create an LFS filesystem see
24204dec52cSdsl.Xr newfs_lfs 8 .
2431a64f420SwizTo create a Linux ext2 filesystem see
244f4f8fe5fStsutsui.Xr newfs_ext2fs 8 .
24514929f77Slukem.It Fl o Ar optimization
24614929f77SlukemOptimization preference; either
24714929f77Slukem.Dq space
24814929f77Slukemor
24914929f77Slukem.Dq time .
250625a6892SmycroftThe file system can either be instructed to try to minimize the time spent
251625a6892Smycroftallocating blocks, or to try to minimize the space fragmentation on the disk.
2529be9a14cSmrgIf the value of minfree (see above) is less than 5%,
253625a6892Smycroftthe default is to optimize for space;
2549be9a14cSmrgif the value of minfree is greater than or equal to 5%,
255625a6892Smycroftthe default is to optimize for time.
256625a6892SmycroftSee
257625a6892Smycroft.Xr tunefs 8
258625a6892Smycroftfor more details on how to set this option.
259063f96f3Sbouyer.It Fl q Ar quota
260063f96f3Sbouyerenable a quota.
261063f96f3Sbouyer.Ar quota
262063f96f3Sbouyercan be one of
263063f96f3Sbouyer.Li user
264063f96f3Sbouyeror
265063f96f3Sbouyer.Li group
266d2eb4c30Swizto enable the specified quota type.
267d2eb4c30SwizMultiple
268063f96f3Sbouyer.Fl q
269063f96f3Sbouyercan be used to enable all types at once.
27061f28255Scgd.It Fl s Ar size
27114929f77SlukemThe size of the file system in sectors.
27214929f77SlukemAn
27314929f77Slukem.Sq s
27414929f77Slukemsuffix will be interpreted as the number of sectors (the default).
27514929f77SlukemAll other suffixes are interpreted as per other numeric arguments,
27614929f77Slukemexcept that the number is converted into sectors by dividing by the
27714929f77Slukemsector size (as specified by
27814929f77Slukem.Fl S Ar secsize )
27914929f77Slukemafter suffix interpretation.
2804302f279Sdsl.Pp
2814302f279SdslIf no
2824302f279Sdsl.Fl s Ar size
2834302f279Sdslis specified then the filesystem size defaults to that of the partition, or,
2844302f279Sdslif
2854302f279Sdsl.Fl F
2864302f279Sdslis specified, the existing file.
2874302f279Sdsl.Pp
2884302f279SdslIf
2894302f279Sdsl.Ar size
2904302f279Sdslis negative the specified size is subtracted from the default size
2914302f279Sdsl(reserving space at the end of the partition).
2924abefdc1Swiz.It Fl T Ar disk-type
2934abefdc1SwizUses information for the specified disk from
2944abefdc1Swiz.Pa /etc/disktab
2954abefdc1Swizinstead of trying to get the information from the disk label.
296afbe178eSdsl.It Fl V Ar verbose
297afbe178eSdslThis controls the amount of information written to stdout:
298afbe178eSdsl.Bl -tag -width 3n -offset indent -compact
299afbe178eSdsl.It 0
30040effc38SwizNo output.
301afbe178eSdsl.It 1
302afbe178eSdslOverall size and cylinder group details.
303afbe178eSdsl.It 2
304afbe178eSdslA progress bar (dots ending at right hand margin).
305afbe178eSdsl.It 3
306afbe178eSdslThe first few super-block backup sector numbers are displayed before the
307afbe178eSdslprogress bar.
308afbe178eSdsl.It 4
309afbe178eSdslAll the super-block backup sector numbers are displayed (no progress bar).
310afbe178eSdsl.El
311afbe178eSdslThe default is 3.
312afbe178eSdslIf
313afbe178eSdsl.Fl N
31440effc38Swizis specified
315afbe178eSdsl.Nm
316afbe178eSdslstops before outputting the progress bar.
317ed08a55dSwiz.It Fl v Ar volname
318ed08a55dSwizThis specifies that an Apple UFS filesystem should be created
319ed08a55dSwizwith the given volume name.
3204abefdc1Swiz.It Fl Z
3214abefdc1SwizPre-zeros the file system image created with
3224abefdc1Swiz.Fl F .
323625a6892Smycroft.El
32461f28255Scgd.Pp
3254abefdc1SwizThe following option overrides the standard sizes for the disk geometry.
3264abefdc1SwizThe default value is taken from the disk label.
3274abefdc1SwizChanging this default is useful only when using
3281a96f83dSlukem.Nm
329625a6892Smycroftto build a file system whose raw image will eventually be used on a
330625a6892Smycroftdifferent type of disk than the one on which it is initially created
331625a6892Smycroft(for example on a write-once disk).
3324abefdc1SwizNote that changing this value from its default will make
333625a6892Smycroftit impossible for
3343d7afc6dSfair.Xr fsck_ffs 8
33580c0d60fSmouseto find the alternative superblocks if the standard superblock is lost.
336625a6892Smycroft.Bl -tag -width Fl
33761f28255Scgd.It Fl S Ar sector-size
33861f28255ScgdThe size of a sector in bytes (almost never anything but 512).
33914929f77SlukemDefaults to 512.
34061f28255Scgd.El
34164a1f388Sad.Sh NOTES
342426b1023SdslThe file system is created with
343426b1023Sdsl.Sq random
344426b1023Sdslinode generation numbers to improve NFS security.
345f2c170edSwrstuden.Pp
34640effc38SwizThe owner and group IDs of the root node of the new file system
34740effc38Swizare set to the effective UID and GID of the user initializing
348f2c170edSwrstudenthe file system.
34964a1f388Sad.Pp
35064a1f388SadFor the
35164a1f388Sad.Nm
35264a1f388Sadcommand to succeed,
35364a1f388Sadthe disk label should first be updated such that the fstype field for the
35464a1f388Sadpartition is set to
35543395bd5Sdbj.Ql 4.2BSD
35643395bd5Sdbjor
35743395bd5Sdbj.Ql Apple UFS ,
358d45e6662Slukemunless
359d45e6662Slukem.Fl F
360d45e6662Slukemor
361d45e6662Slukem.Fl I
362d45e6662Slukemis used.
36304dec52cSdsl.Pp
36404dec52cSdslTo create and populate a filesystem image within a file use the
36504dec52cSdsl.Xr makefs 8
36604dec52cSdslutility.
3674302f279Sdsl.Pp
3684302f279SdslThe partition size is found using
36940effc38Swiz.Xr fstat 2 ,
3704302f279Sdslnot by inspecting the disk label.
3714302f279SdslThe block size and fragment size will be written back to the disk label
3724302f279Sdslonly if the last character of
3734302f279Sdsl.Ar special
3744302f279Sdslreferences the same partition as the minor device number.
375bc6c0589Spooka.Pp
376bc6c0589SpookaUnless
377bc6c0589Spooka.Fl F
378bc6c0589Spookais specified,
379bc6c0589Spooka.Ar special
380bc6c0589Spookamust be a raw device.
381bc6c0589SpookaThis means that for example
382bc6c0589Spooka.Pa wd0a
383bc6c0589Spookaor
384bc6c0589Spooka.Pa /dev/rwd0a
385bc6c0589Spookamust be specified instead of
386bc6c0589Spooka.Pa /dev/wd0a .
38761f28255Scgd.Sh SEE ALSO
3884302f279Sdsl.Xr fstat 2 ,
38961f28255Scgd.Xr disktab 5 ,
39061f28255Scgd.Xr fs 5 ,
39161f28255Scgd.Xr disklabel 8 ,
39261f28255Scgd.Xr diskpart 8 ,
393c8fa8a4dSwiz.Xr dumpfs 8 ,
3946fccda72Swiz.\" .Xr format 8 ,
39589e1507eSmycroft.Xr fsck_ffs 8 ,
396426b1023Sdsl.\" .Xr fsirand 8 ,
39704dec52cSdsl.Xr makefs 8 ,
398625a6892Smycroft.Xr mount 8 ,
39904e7d8d5Slukem.Xr mount_mfs 8 ,
400f4f8fe5fStsutsui.Xr newfs_ext2fs 8 ,
40104dec52cSdsl.Xr newfs_lfs 8 ,
402cfc5c552Shubertf.Xr newfs_msdos 8 ,
4034738a033Schristos.Xr tunefs 8
40461f28255Scgd.Rs
40561f28255Scgd.%A M. McKusick
40661f28255Scgd.%A W. Joy
40761f28255Scgd.%A S. Leffler
40861f28255Scgd.%A R. Fabry
40961f28255Scgd.%T A Fast File System for UNIX ,
41061f28255Scgd.%J ACM Transactions on Computer Systems 2
41161f28255Scgd.%V 3
41261f28255Scgd.%P pp 181-197
41361f28255Scgd.%D August 1984
41461f28255Scgd.%O (reprinted in the BSD System Manager's Manual)
41561f28255Scgd.Re
4162a895843Slukem.Rs
4172a895843Slukem.%A M. McKusick
4182a895843Slukem.%T Enhancements to the fast filesystem to support multi-terabyte storage systems
4192a895843Slukem.%J Proceedings of the BSD Conference 2003
4202a895843Slukem.%P pp 79-90
4212a895843Slukem.%D September 2003
4222a895843Slukem.Re
42361f28255Scgd.Sh HISTORY
42461f28255ScgdThe
42561f28255Scgd.Nm
42661f28255Scgdcommand appeared in
42761f28255Scgd.Bx 4.2 .
428