xref: /netbsd-src/sbin/newfs/newfs.8 (revision 87ba0e2a319653af510fae24a6d2975d3589735b)
1.\"	$NetBSD: newfs.8,v 1.86 2022/11/17 06:40:39 chs 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.
232This is also known as
233.Sq UFS2 .
234.It 2ea
235FFSv2 plus support for extended attributes and access control lists.
236.El
237See
238.Xr fsck_ffs 8
239for more information about format levels.
240.Pp
241To create an LFS filesystem see
242.Xr newfs_lfs 8 .
243To create a Linux ext2 filesystem see
244.Xr newfs_ext2fs 8 .
245.It Fl o Ar optimization
246Optimization preference; either
247.Dq space
248or
249.Dq time .
250The file system can either be instructed to try to minimize the time spent
251allocating blocks, or to try to minimize the space fragmentation on the disk.
252If the value of minfree (see above) is less than 5%,
253the default is to optimize for space;
254if the value of minfree is greater than or equal to 5%,
255the default is to optimize for time.
256See
257.Xr tunefs 8
258for more details on how to set this option.
259.It Fl q Ar quota
260enable a quota.
261.Ar quota
262can be one of
263.Li user
264or
265.Li group
266to enable the specified quota type.
267Multiple
268.Fl q
269can be used to enable all types at once.
270.It Fl s Ar size
271The size of the file system in sectors.
272An
273.Sq s
274suffix will be interpreted as the number of sectors (the default).
275All other suffixes are interpreted as per other numeric arguments,
276except that the number is converted into sectors by dividing by the
277sector size (as specified by
278.Fl S Ar secsize )
279after suffix interpretation.
280.Pp
281If no
282.Fl s Ar size
283is specified then the filesystem size defaults to that of the partition, or,
284if
285.Fl F
286is specified, the existing file.
287.Pp
288If
289.Ar size
290is negative the specified size is subtracted from the default size
291(reserving space at the end of the partition).
292.It Fl T Ar disk-type
293Uses information for the specified disk from
294.Pa /etc/disktab
295instead of trying to get the information from the disk label.
296.It Fl V Ar verbose
297This controls the amount of information written to stdout:
298.Bl -tag -width 3n -offset indent -compact
299.It 0
300No output.
301.It 1
302Overall size and cylinder group details.
303.It 2
304A progress bar (dots ending at right hand margin).
305.It 3
306The first few super-block backup sector numbers are displayed before the
307progress bar.
308.It 4
309All the super-block backup sector numbers are displayed (no progress bar).
310.El
311The default is 3.
312If
313.Fl N
314is specified
315.Nm
316stops before outputting the progress bar.
317.It Fl v Ar volname
318This specifies that an Apple UFS filesystem should be created
319with the given volume name.
320.It Fl Z
321Pre-zeros the file system image created with
322.Fl F .
323.El
324.Pp
325The following option overrides the standard sizes for the disk geometry.
326The default value is taken from the disk label.
327Changing this default is useful only when using
328.Nm
329to build a file system whose raw image will eventually be used on a
330different type of disk than the one on which it is initially created
331(for example on a write-once disk).
332Note that changing this value from its default will make
333it impossible for
334.Xr fsck_ffs 8
335to find the alternative superblocks if the standard superblock is lost.
336.Bl -tag -width Fl
337.It Fl S Ar sector-size
338The size of a sector in bytes (almost never anything but 512).
339Defaults to 512.
340.El
341.Sh NOTES
342The file system is created with
343.Sq random
344inode generation numbers to improve NFS security.
345.Pp
346The owner and group IDs of the root node of the new file system
347are set to the effective UID and GID of the user initializing
348the file system.
349.Pp
350For the
351.Nm
352command to succeed,
353the disk label should first be updated such that the fstype field for the
354partition is set to
355.Ql 4.2BSD
356or
357.Ql Apple UFS ,
358unless
359.Fl F
360or
361.Fl I
362is used.
363.Pp
364To create and populate a filesystem image within a file use the
365.Xr makefs 8
366utility.
367.Pp
368The partition size is found using
369.Xr fstat 2 ,
370not by inspecting the disk label.
371The block size and fragment size will be written back to the disk label
372only if the last character of
373.Ar special
374references the same partition as the minor device number.
375.Pp
376Unless
377.Fl F
378is specified,
379.Ar special
380must be a raw device.
381This means that for example
382.Pa wd0a
383or
384.Pa /dev/rwd0a
385must be specified instead of
386.Pa /dev/wd0a .
387.Sh SEE ALSO
388.Xr fstat 2 ,
389.Xr disktab 5 ,
390.Xr fs 5 ,
391.Xr disklabel 8 ,
392.Xr diskpart 8 ,
393.Xr dumpfs 8 ,
394.\" .Xr format 8 ,
395.Xr fsck_ffs 8 ,
396.\" .Xr fsirand 8 ,
397.Xr makefs 8 ,
398.Xr mount 8 ,
399.Xr mount_mfs 8 ,
400.Xr newfs_ext2fs 8 ,
401.Xr newfs_lfs 8 ,
402.Xr newfs_msdos 8 ,
403.Xr tunefs 8
404.Rs
405.%A M. McKusick
406.%A W. Joy
407.%A S. Leffler
408.%A R. Fabry
409.%T A Fast File System for UNIX ,
410.%J ACM Transactions on Computer Systems 2
411.%V 3
412.%P pp 181-197
413.%D August 1984
414.%O (reprinted in the BSD System Manager's Manual)
415.Re
416.Rs
417.%A M. McKusick
418.%T Enhancements to the fast filesystem to support multi-terabyte storage systems
419.%J Proceedings of the BSD Conference 2003
420.%P pp 79-90
421.%D September 2003
422.Re
423.Sh HISTORY
424The
425.Nm
426command appeared in
427.Bx 4.2 .
428