xref: /netbsd-src/sbin/newfs/newfs.8 (revision d536862b7d93d77932ef5de7eebdc48d76921b77)
1.\"	$NetBSD: newfs.8,v 1.85 2019/04/13 19:29:27 maya 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 April 13, 2019
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 < 20 MB
1134 KB
114.It < 1000 MB
1158 KB
116.It < 128 GB
11716 KB
118.It >= 128 GB
11932 KB
120.El
121.It Fl d Ar maxbsize
122Set the maximum extent size to
123.Ar maxbsize .
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 < 20 MB
1550.5 KB
156.It < 1000 MB
1571 KB
158.It < 128 GB
1592 KB
160.It >= 128 GB
1614 KB
162.El
163.It Fl G
164Treat garbage parameters as non-fatal.
165Using this option may result in a file system which causes a kernel
166panic and should only be used for testing.
167.It Fl g Ar avgfilesize
168The expected average file size for the file system.
169.It Fl h Ar avgfpdir
170The expected average number of files per directory on the file system.
171.It Fl I
172Do not require that the file system type listed in the disk label is
173.Ql 4.2BSD
174or
175.Ql Apple UFS .
176.It Fl i Ar bytes-per-inode
177This specifies the density of inodes in the file system.
178If fewer inodes are desired, a larger number should be used;
179to create more inodes a smaller number should be given.
180The default is to create an inode for every
181.Pq 4 * Ar frag-size
182bytes of data space:
183.Pp
184.Bl -tag -width "file system size" -compact -offset indent
185.It Sy "file system size"
186.Ar bytes-per-inode
187.It < 20 MB
1882 KB
189.It < 1000 MB
1904 KB
191.It < 128 GB
1928 KB
193.It >= 128 GB
19416 KB
195.El
196.It Fl m Ar free-space
197The percentage of space reserved from normal users; the minimum free
198space threshold.
199The default value used is 5%.
200See
201.Xr tunefs 8
202for more details on how to set this option.
203.It Fl N
204Causes the file system parameters to be printed out
205without really creating the file system.
206.It Fl n Ar inodes
207This specifies the number of inodes for the filesystem.
208If both
209.Fl i
210and
211.Fl n
212are specified then
213.Fl n
214takes precedence.
215.It Fl O Ar filesystem-format
216Select the filesystem-format.
217.Bl -tag -width 3n -offset indent -compact
218.It 0
2194.3BSD; This option is primarily used to build root file systems that can be
220understood by older boot ROMs.
221This generates an FFSv1 file system with level 1 format.
222.It 1
223FFSv1; normal Fast File System, level 4 format.
224Also known as
225.Sq FFS ,
226.Sq UFS ,
227or
228.Sq UFS1 .
229This is the default.
230.It 2
231FFSv2; enhanced Fast File System, suited for more than 1 Terabyte capacity.
232.\" Supports access control lists.
233This is also known as
234.Sq UFS2 .
235.El
236See
237.Xr fsck_ffs 8
238for more information about format levels.
239.Pp
240To create an LFS filesystem see
241.Xr newfs_lfs 8 .
242To create a Linux ext2 filesystem see
243.Xr newfs_ext2fs 8 .
244.It Fl o Ar optimization
245Optimization preference; either
246.Dq space
247or
248.Dq time .
249The file system can either be instructed to try to minimize the time spent
250allocating blocks, or to try to minimize the space fragmentation on the disk.
251If the value of minfree (see above) is less than 5%,
252the default is to optimize for space;
253if the value of minfree is greater than or equal to 5%,
254the default is to optimize for time.
255See
256.Xr tunefs 8
257for more details on how to set this option.
258.It Fl q Ar quota
259enable a quota.
260.Ar quota
261can be one of
262.Li user
263or
264.Li group
265to enable the specified quota type.
266Multiple
267.Fl q
268can be used to enable all types at once.
269.It Fl s Ar size
270The size of the file system in sectors.
271An
272.Sq s
273suffix will be interpreted as the number of sectors (the default).
274All other suffixes are interpreted as per other numeric arguments,
275except that the number is converted into sectors by dividing by the
276sector size (as specified by
277.Fl S Ar secsize )
278after suffix interpretation.
279.Pp
280If no
281.Fl s Ar size
282is specified then the filesystem size defaults to that of the partition, or,
283if
284.Fl F
285is specified, the existing file.
286.Pp
287If
288.Ar size
289is negative the specified size is subtracted from the default size
290(reserving space at the end of the partition).
291.It Fl T Ar disk-type
292Uses information for the specified disk from
293.Pa /etc/disktab
294instead of trying to get the information from the disk label.
295.It Fl V Ar verbose
296This controls the amount of information written to stdout:
297.Bl -tag -width 3n -offset indent -compact
298.It 0
299No output.
300.It 1
301Overall size and cylinder group details.
302.It 2
303A progress bar (dots ending at right hand margin).
304.It 3
305The first few super-block backup sector numbers are displayed before the
306progress bar.
307.It 4
308All the super-block backup sector numbers are displayed (no progress bar).
309.El
310The default is 3.
311If
312.Fl N
313is specified
314.Nm
315stops before outputting the progress bar.
316.It Fl v Ar volname
317This specifies that an Apple UFS filesystem should be created
318with the given volume name.
319.It Fl Z
320Pre-zeros the file system image created with
321.Fl F .
322.El
323.Pp
324The following option overrides the standard sizes for the disk geometry.
325The default value is taken from the disk label.
326Changing this default is useful only when using
327.Nm
328to build a file system whose raw image will eventually be used on a
329different type of disk than the one on which it is initially created
330(for example on a write-once disk).
331Note that changing this value from its default will make
332it impossible for
333.Xr fsck_ffs 8
334to find the alternative superblocks if the standard superblock is lost.
335.Bl -tag -width Fl
336.It Fl S Ar sector-size
337The size of a sector in bytes (almost never anything but 512).
338Defaults to 512.
339.El
340.Sh NOTES
341The file system is created with
342.Sq random
343inode generation numbers to improve NFS security.
344.Pp
345The owner and group IDs of the root node of the new file system
346are set to the effective UID and GID of the user initializing
347the file system.
348.Pp
349For the
350.Nm
351command to succeed,
352the disk label should first be updated such that the fstype field for the
353partition is set to
354.Ql 4.2BSD
355or
356.Ql Apple UFS ,
357unless
358.Fl F
359or
360.Fl I
361is used.
362.Pp
363To create and populate a filesystem image within a file use the
364.Xr makefs 8
365utility.
366.Pp
367The partition size is found using
368.Xr fstat 2 ,
369not by inspecting the disk label.
370The block size and fragment size will be written back to the disk label
371only if the last character of
372.Ar special
373references the same partition as the minor device number.
374.Pp
375Unless
376.Fl F
377is specified,
378.Ar special
379must be a raw device.
380This means that for example
381.Pa wd0a
382or
383.Pa /dev/rwd0a
384must be specified instead of
385.Pa /dev/wd0a .
386.Sh SEE ALSO
387.Xr fstat 2 ,
388.Xr disktab 5 ,
389.Xr fs 5 ,
390.Xr disklabel 8 ,
391.Xr diskpart 8 ,
392.Xr dumpfs 8 ,
393.\" .Xr format 8 ,
394.Xr fsck_ffs 8 ,
395.\" .Xr fsirand 8 ,
396.Xr makefs 8 ,
397.Xr mount 8 ,
398.Xr mount_mfs 8 ,
399.Xr newfs_ext2fs 8 ,
400.Xr newfs_lfs 8 ,
401.Xr newfs_msdos 8 ,
402.Xr tunefs 8
403.Rs
404.%A M. McKusick
405.%A W. Joy
406.%A S. Leffler
407.%A R. Fabry
408.%T A Fast File System for UNIX ,
409.%J ACM Transactions on Computer Systems 2
410.%V 3
411.%P pp 181-197
412.%D August 1984
413.%O (reprinted in the BSD System Manager's Manual)
414.Re
415.Rs
416.%A M. McKusick
417.%T Enhancements to the fast filesystem to support multi-terabyte storage systems
418.%J Proceedings of the BSD Conference 2003
419.%P pp 79-90
420.%D September 2003
421.Re
422.Sh HISTORY
423The
424.Nm
425command appeared in
426.Bx 4.2 .
427