xref: /netbsd-src/sbin/newfs/newfs.8 (revision 4b896b232495b7a9b8b94a1cf1e21873296d53b8)
1.\"	$NetBSD: newfs.8,v 1.63 2003/11/01 18:38:59 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. 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 November 1, 2003
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 FINZ
41.Op Fl a Ar maxcontig
42.Op Fl B Ar byte-order
43.Op Fl b Ar block-size
44.Op Fl e Ar maxbpg
45.Op Fl f Ar frag-size
46.Op Fl g Ar avgfilesize
47.Op Fl h Ar avgfpdir
48.Op Fl i Ar bytes-per-inode
49.Op Fl m Ar free-space
50.Op Fl n Ar inodes
51.Op Fl O Ar filesystem-format
52.Op Fl o Ar optimization
53.Op Fl S Ar sector-size
54.Op Fl s Ar size
55.Op Fl T Ar disk-type
56.Op Fl v Ar volname
57.Ar special
58.Sh DESCRIPTION
59.Nm
60is used to initialize and clear file systems before first use.
61Before running
62.Nm
63the disk must be labeled using
64.Xr disklabel 8 .
65.Nm
66builds a file system on the specified special device
67basing its defaults on the information in the disk label.
68Typically the defaults are reasonable, however
69.Nm
70has numerous options to allow the defaults to be selectively overridden.
71.Pp
72Options with numeric arguments may contain an optional (case-insensitive)
73suffix:
74.Bl -tag -width 3n -offset indent -compact
75.It b
76Bytes; causes no modification.
77(Default)
78.It k
79Kilo; multiply the argument by 1024
80.It m
81Mega; multiply the argument by 1048576
82.It g
83Giga; multiply the argument by 1073741824
84.El
85.Pp
86The following options define the general layout policies.
87.Bl -tag -width Fl
88.It Fl a Ar maxcontig
89This specifies the maximum number of contiguous blocks that will be
90laid out before forcing a rotational delay (see the
91.Fl d
92option).
93The default value is 8.
94See
95.Xr tunefs 8
96for more details on how to set this option.
97.It Fl B Ar byte-order
98Specify the metadata byte order of the file system to be created.
99Valid byte orders are
100.Sq be
101and
102.Sq le .
103If no byte order is specified, the file system is created in host
104byte order.
105.It Fl b Ar block-size
106The block size of the file system, in bytes.
107It must be a power of two.
108The smallest allowable size is 4096 bytes.
109The default size depends upon the size of the file system:
110.Pp
111.Bl -tag -width "file system size" -compact -offset indent
112.It Sy "file system size"
113.Ar block-size
114.It \*[Lt] 20 MB
1154 KB
116.It \*[Lt] 1024 MB
1178 KB
118.It \*[Gt]= 1024 MB
11916 KB
120.El
121.It Fl e Ar maxbpg
122This indicates the maximum number of blocks any single file can
123allocate out of a cylinder group before it is forced to begin
124allocating blocks from another cylinder group.
125The default is about one quarter of the total blocks in a cylinder group.
126See
127.Xr tunefs 8
128for more details on how to set this option.
129.It Fl F
130Create a file system image in
131.Ar special .
132The file system size needs to be specified with
133.Dq Fl s Ar size .
134No attempts to use or update the disk label will be made.
135.It Fl f Ar frag-size
136The fragment size of the file system in bytes.
137It must be a power of two ranging in value between
138.Ar block-size Ns /8
139and
140.Ar block-size .
141The optimal
142.Ar block-size : Ns Ar frag-size
143ratio is 8:1.
144Other ratios are possible, but are not recommended,
145and may produce unpredictable results.
146The default size depends upon the size of the file system:
147.Pp
148.Bl -tag -width "file system size" -compact -offset indent
149.It Sy "file system size"
150.Ar frag-size
151.It \*[Lt] 20 MB
1520.5 KB
153.It \*[Lt] 1024 MB
1541 KB
155.It \*[Gt]= 1024 MB
1562 KB
157.El
158.It Fl g Ar avgfilesize
159The expected average file size for the file system.
160.It Fl h Ar avgfpdir
161The expected average number of files per directory on the file system.
162.It Fl I
163Do not require that the file system type listed in the disk label is
164.Ql 4.2BSD
165or
166.Ql Apple UFS .
167.It Fl i Ar bytes-per-inode
168This specifies the density of inodes in the file system.
169If fewer inodes are desired, a larger number should be used;
170to create more inodes a smaller number should be given.
171The default is to create an inode for every
172.Pq 4 * Ar frag-size
173bytes of data space:
174.Pp
175.Bl -tag -width "file system size" -compact -offset indent
176.It Sy "file system size"
177.Ar bytes-per-inode
178.It \*[Lt] 20 MB
1792 KB
180.It \*[Lt] 1024 MB
1814 KB
182.It \*[Gt]= 1024 MB
1838 KB
184.El
185.It Fl m Ar free-space
186The percentage of space reserved from normal users; the minimum free
187space threshold.
188The default value used is 5%.
189See
190.Xr tunefs 8
191for more details on how to set this option.
192.It Fl N
193Causes the file system parameters to be printed out
194without really creating the file system.
195.It Fl n Ar inodes
196This specifies the number of inodes for the filesystem.
197If both
198.Fl i
199and
200.Fl n
201are specified then
202.Fl n
203takes precedence.
204.It Fl O Ar filesystem-format
205Select the filesystem-format
206.Bl -tag -width 3n -offset indent -compact
207.It 0
2084.3BSD; This option is primarily used to build root file systems that can be
209understood by older boot ROMs.
210.It 1
211FFS; normal fast-filesystem (default).
212.It 2
213UFS2; enhanced fast-filesystem (suited for more than 1 Terabyte capacity,
214access control lists).
215.El
216To create an LFS filesystem see
217.Xr newfs_lfs 8 .
218.It Fl o Ar optimization
219Optimization preference; either
220.Dq space
221or
222.Dq time .
223The file system can either be instructed to try to minimize the time spent
224allocating blocks, or to try to minimize the space fragmentation on the disk.
225If the value of minfree (see above) is less than 5%,
226the default is to optimize for space;
227if the value of minfree is greater than or equal to 5%,
228the default is to optimize for time.
229See
230.Xr tunefs 8
231for more details on how to set this option.
232.It Fl s Ar size
233The size of the file system in sectors.
234An
235.Sq s
236suffix will be interpreted as the number of sectors (the default).
237All other suffixes are interpreted as per other numeric arguments,
238except that the number is converted into sectors by dividing by the
239sector size (as specified by
240.Fl S Ar secsize )
241after suffix interpretation.
242.Pp
243If no
244.Fl s Ar size
245is specified then the filesystem size defaults to that of the partition, or,
246if
247.Fl F
248is specified, the existing file.
249.Pp
250If
251.Ar size
252is negative the specified size is subtracted from the default size
253(reserving space at the end of the partition).
254.It Fl T Ar disk-type
255Uses information for the specified disk from
256.Pa /etc/disktab
257instead of trying to get the information from the disk label.
258.It Fl v Ar volname
259This specifies that an Apple UFS filesystem should be created
260with the given volume name.
261.It Fl Z
262Pre-zeros the file system image created with
263.Fl F .
264This is necessary if the image is to be used by
265.Xr vnd 4
266(which doesn't support file systems with
267.Sq holes ) .
268.El
269.Pp
270The following option overrides the standard sizes for the disk geometry.
271The default value is taken from the disk label.
272Changing this default is useful only when using
273.Nm
274to build a file system whose raw image will eventually be used on a
275different type of disk than the one on which it is initially created
276(for example on a write-once disk).
277Note that changing this value from its default will make
278it impossible for
279.Xr fsck_ffs 8
280to find the alternative superblocks if the standard superblock is lost.
281.Bl -tag -width Fl
282.It Fl S Ar sector-size
283The size of a sector in bytes (almost never anything but 512).
284Defaults to 512.
285.El
286.Sh NOTES
287The file system is created with
288.Sq random
289inode generation numbers to improve NFS security.
290.Pp
291The owner and group ids of the root node of the new file system
292are set to the effective uid and gid of the user initializing
293the file system.
294.Pp
295For the
296.Nm
297command to succeed,
298the disk label should first be updated such that the fstype field for the
299partition is set to
300.Ql 4.2BSD
301or
302.Ql Apple UFS ,
303unless
304.Fl F
305or
306.Fl I
307is used.
308.Pp
309To create and populate a filesystem image within a file use the
310.Xr makefs 8
311utility.
312.Pp
313The partition size is found using
314.Xr fstat 2
315not by inspecting the disklabel.
316The block size and fragment size will be written back to the disklabel
317only if the last character of
318.Ar special
319references the same partition as the minor device number.
320This is true for normal disk devices, but not for certain other drivers
321(e.g.,
322.Xr vinum 4 )
323that provide disk like block and character devices.
324.Sh SEE ALSO
325.Xr fstat 2 ,
326.Xr disktab 5 ,
327.Xr fs 5 ,
328.Xr disklabel 8 ,
329.Xr diskpart 8 ,
330.Xr dumpfs 8 ,
331.\" .Xr format 8 ,
332.Xr fsck_ffs 8 ,
333.\" .Xr fsirand 8 ,
334.Xr makefs 8 ,
335.Xr mount 8 ,
336.Xr mount_mfs 8 ,
337.Xr newfs_lfs 8 ,
338.Xr tunefs 8 ,
339.Xr vinum 8
340.Rs
341.%A M. McKusick
342.%A W. Joy
343.%A S. Leffler
344.%A R. Fabry
345.%T A Fast File System for UNIX ,
346.%J ACM Transactions on Computer Systems 2
347.%V 3
348.%P pp 181-197
349.%D August 1984
350.%O (reprinted in the BSD System Manager's Manual)
351.Re
352.Sh HISTORY
353The
354.Nm
355command appeared in
356.Bx 4.2 .
357