xref: /netbsd-src/sbin/newfs/newfs.8 (revision abb0f93cd77b67f080613360c65701f85e5f5cfe)
1.\"	$NetBSD: newfs.8,v 1.75 2009/12/01 10:56:33 pooka 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 December 1, 2009
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 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 S Ar sector-size
55.Op Fl s Ar size
56.Op Fl T Ar disk-type
57.Op Fl v Ar volname
58.Op Fl V Ar verbose
59.Ar special
60.Sh DESCRIPTION
61.Nm
62is used to initialize and clear file systems before first use.
63Before running
64.Nm
65the disk must be labeled using
66.Xr disklabel 8 .
67.Nm
68builds a file system on the specified special device
69basing its defaults on the information in the disk label.
70Typically the defaults are reasonable, however
71.Nm
72has numerous options to allow the defaults to be selectively overridden.
73.Pp
74Options with numeric arguments may contain an optional (case-insensitive)
75suffix:
76.Bl -tag -width 3n -offset indent -compact
77.It b
78Bytes; causes no modification.
79(Default)
80.It k
81Kilo; multiply the argument by 1024
82.It m
83Mega; multiply the argument by 1048576
84.It g
85Giga; multiply the argument by 1073741824
86.It t
87Tera; multiply the argument by 1099511627776
88.El
89.Pp
90The following options define the general layout policies.
91.Bl -tag -width Fl
92.It Fl a Ar maxcontig
93This sets the obsolete maxcontig parameter.
94.It Fl B Ar byte-order
95Specify the metadata byte order of the file system to be created.
96Valid byte orders are
97.Sq be
98and
99.Sq le .
100If no byte order is specified, the file system is created in host
101byte order.
102.It Fl b Ar block-size
103The block size of the file system, in bytes.
104It must be a power of two.
105The smallest allowable size is 4096 bytes.
106The default size depends upon the size of the file system:
107.Pp
108.Bl -tag -width "file system size" -compact -offset indent
109.It Sy "file system size"
110.Ar block-size
111.It \*[Lt] 20 MB
1124 KB
113.It \*[Lt] 1024 MB
1148 KB
115.It \*[Gt]= 1024 MB
11616 KB
117.El
118.It Fl d Ar maxbsize
119Set the maximum extent size to
120.Ar maxbsize .
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
211FFSv1; normal fast-filesystem (default).
212This is also known as
213.Sq FFS ,
214.Sq UFS ,
215or
216.Sq UFS1 .
217.It 2
218FFSv2; enhanced fast-filesystem (suited for more than 1 Terabyte capacity,
219access control lists).
220This is also known as
221.Sq UFS2 .
222.El
223To create an LFS filesystem see
224.Xr newfs_lfs 8 .
225To create a Linux Ext2 filesystem see
226.Xr newfs_ext2fs 8 .
227.It Fl o Ar optimization
228Optimization preference; either
229.Dq space
230or
231.Dq time .
232The file system can either be instructed to try to minimize the time spent
233allocating blocks, or to try to minimize the space fragmentation on the disk.
234If the value of minfree (see above) is less than 5%,
235the default is to optimize for space;
236if the value of minfree is greater than or equal to 5%,
237the default is to optimize for time.
238See
239.Xr tunefs 8
240for more details on how to set this option.
241.It Fl s Ar size
242The size of the file system in sectors.
243An
244.Sq s
245suffix will be interpreted as the number of sectors (the default).
246All other suffixes are interpreted as per other numeric arguments,
247except that the number is converted into sectors by dividing by the
248sector size (as specified by
249.Fl S Ar secsize )
250after suffix interpretation.
251.Pp
252If no
253.Fl s Ar size
254is specified then the filesystem size defaults to that of the partition, or,
255if
256.Fl F
257is specified, the existing file.
258.Pp
259If
260.Ar size
261is negative the specified size is subtracted from the default size
262(reserving space at the end of the partition).
263.It Fl T Ar disk-type
264Uses information for the specified disk from
265.Pa /etc/disktab
266instead of trying to get the information from the disk label.
267.It Fl v Ar volname
268This specifies that an Apple UFS filesystem should be created
269with the given volume name.
270.It Fl V Ar verbose
271This controls the amount of information written to stdout:
272.Bl -tag -width 3n -offset indent -compact
273.It 0
274No output
275.It 1
276Overall size and cylinder group details.
277.It 2
278A progress bar (dots ending at right hand margin).
279.It 3
280The first few super-block backup sector numbers are displayed before the
281progress bar.
282.It 4
283All the super-block backup sector numbers are displayed (no progress bar).
284.El
285The default is 3.
286If
287.Fl N
288is specifed
289.Nm
290stops before outputting the progress bar.
291.It Fl Z
292Pre-zeros the file system image created with
293.Fl F .
294This is necessary if the image is to be used by
295.Xr vnd 4
296(which doesn't support file systems with
297.Sq holes ) .
298.El
299.Pp
300The following option overrides the standard sizes for the disk geometry.
301The default value is taken from the disk label.
302Changing this default is useful only when using
303.Nm
304to build a file system whose raw image will eventually be used on a
305different type of disk than the one on which it is initially created
306(for example on a write-once disk).
307Note that changing this value from its default will make
308it impossible for
309.Xr fsck_ffs 8
310to find the alternative superblocks if the standard superblock is lost.
311.Bl -tag -width Fl
312.It Fl S Ar sector-size
313The size of a sector in bytes (almost never anything but 512).
314Defaults to 512.
315.El
316.Sh NOTES
317The file system is created with
318.Sq random
319inode generation numbers to improve NFS security.
320.Pp
321The owner and group ids of the root node of the new file system
322are set to the effective uid and gid of the user initializing
323the file system.
324.Pp
325For the
326.Nm
327command to succeed,
328the disk label should first be updated such that the fstype field for the
329partition is set to
330.Ql 4.2BSD
331or
332.Ql Apple UFS ,
333unless
334.Fl F
335or
336.Fl I
337is used.
338.Pp
339To create and populate a filesystem image within a file use the
340.Xr makefs 8
341utility.
342.Pp
343The partition size is found using
344.Xr fstat 2
345not by inspecting the disklabel.
346The block size and fragment size will be written back to the disklabel
347only if the last character of
348.Ar special
349references the same partition as the minor device number.
350.Pp
351Unless
352.Fl F
353is specified,
354.Ar special
355must be a raw device.
356This means that for example
357.Pa wd0a
358or
359.Pa /dev/rwd0a
360must be specified instead of
361.Pa /dev/wd0a .
362.Sh SEE ALSO
363.Xr fstat 2 ,
364.Xr disktab 5 ,
365.Xr fs 5 ,
366.Xr disklabel 8 ,
367.Xr diskpart 8 ,
368.Xr dumpfs 8 ,
369.\" .Xr format 8 ,
370.Xr fsck_ffs 8 ,
371.\" .Xr fsirand 8 ,
372.Xr makefs 8 ,
373.Xr mount 8 ,
374.Xr mount_mfs 8 ,
375.Xr newfs_ext2fs 8 ,
376.Xr newfs_lfs 8 ,
377.Xr newfs_msdos 8 ,
378.Xr tunefs 8
379.Rs
380.%A M. McKusick
381.%A W. Joy
382.%A S. Leffler
383.%A R. Fabry
384.%T A Fast File System for UNIX ,
385.%J ACM Transactions on Computer Systems 2
386.%V 3
387.%P pp 181-197
388.%D August 1984
389.%O (reprinted in the BSD System Manager's Manual)
390.Re
391.Rs
392.%A M. McKusick
393.%T Enhancements to the fast filesystem to support multi-terabyte storage systems
394.%J Proceedings of the BSD Conference 2003
395.%P pp 79-90
396.%D September 2003
397.Re
398.Sh HISTORY
399The
400.Nm
401command appeared in
402.Bx 4.2 .
403