xref: /openbsd/sbin/newfs/newfs.8 (revision d415bd75)
1.\"	$OpenBSD: newfs.8,v 1.79 2022/11/19 08:02:11 sthen Exp $
2.\"	$NetBSD: newfs.8,v 1.12 1995/03/18 14:58:41 cgd Exp $
3.\"
4.\" Copyright (c) 1983, 1987, 1991, 1993, 1994
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)newfs.8	8.3 (Berkeley) 3/27/94
32.\"
33.Dd $Mdocdate: November 19 2022 $
34.Dt NEWFS 8
35.Os
36.Sh NAME
37.Nm newfs , mount_mfs
38.Nd construct a new file system
39.Sh SYNOPSIS
40.Nm newfs
41.Bk -words
42.Op Fl Nq
43.Op Fl b Ar block-size
44.Op Fl c Ar fragments-per-cylinder-group
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
50.Op Fl m Ar free-space
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 disktype
56.Op Fl t Ar fstype
57.Ar special
58.Ek
59.Pp
60.Nm mount_mfs
61.Bk -words
62.Op Fl b Ar block-size
63.Op Fl c Ar fragments-per-cylinder-group
64.Op Fl e Ar maxbpg
65.Op Fl f Ar frag-size
66.Op Fl i Ar bytes
67.Op Fl m Ar free-space
68.Op Fl O Ar filesystem-format
69.Op Fl o Ar options
70.Op Fl P Ar file
71.Op Fl s Ar size
72.Ar special node
73.Ek
74.Sh DESCRIPTION
75Before running
76.Nm ,
77the disk must be labeled using
78.Xr disklabel 8 .
79.Nm
80builds a file system on the specified
81.Ar special
82device,
83basing its defaults on the information in the disk label.
84Typically the defaults are reasonable, although
85.Nm
86has numerous options to allow the defaults to be selectively overridden.
87.Pp
88The
89.Ar special
90file should be a raw device,
91for example
92.Pa /dev/rsd0a ;
93if a relative path like
94.Pa sd0a
95is specified,
96the corresponding raw device is used.
97.Pp
98.Nm mount_mfs
99is used to build a file system in virtual memory and then mount it
100on a specified node.
101.Nm mount_mfs
102exits and the contents of the file system are lost
103when the file system is unmounted.
104If
105.Nm mount_mfs
106is sent a signal while running,
107for example during system shutdown,
108it will attempt to unmount its
109corresponding file system.
110The parameters to
111.Nm mount_mfs
112are the same as those to
113.Nm newfs .
114The special file is only used to read the disk label which provides
115a set of configuration parameters for the memory based file system.
116The special file is typically that of the primary swap area,
117since that is where the file system will be backed up when
118free memory gets low and the memory supporting
119the file system has to be paged.
120If the keyword
121.Dq swap
122is used instead of a special file name, default configuration parameters
123will be used.
124(This option is useful when trying to use
125.Nm mount_mfs
126on a machine without any disks.)
127.Pp
128Both
129.Nm
130and
131.Nm mount_mfs
132now have the functionality of
133.Xr fsirand 8
134built in, so it is not necessary to run
135.Xr fsirand 8
136manually unless you wish to re-randomize the
137file system (or list the inode generation numbers).
138.Pp
139The options to
140.Nm
141are as follows:
142.Bl -tag -width Ds
143.It Fl b Ar block-size
144The block size of the file system, in bytes.
145If a disklabel is available, the default is read from it.
146Otherwise the default is 16 KB or eight times the fragment size,
147whichever is smaller.
148.It Fl c Ar fragments-per-cylinder-group
149The number of fragments per cylinder group in a file system.
150The default is to compute the maximum allowed by the other parameters.
151This value is dependent on a number of other parameters,
152in particular the block size and the number of bytes per inode.
153.It Fl e Ar maxbpg
154This indicates the maximum number of blocks any single file can
155allocate out of a cylinder group before it is forced to begin
156allocating blocks from another cylinder group.
157The default is about one quarter of the total blocks in a cylinder group.
158See
159.Xr tunefs 8
160for more details on how to set this option.
161.It Fl f Ar frag-size
162The fragment size of the file system in bytes.
163If a disklabel is available, the default is read from it.
164Otherwise the default is 2048.
165.It Fl g Ar avgfilesize
166The expected average file size for the file system in bytes.
167.It Fl h Ar avgfpdir
168The expected average number of files per directory on the file system.
169.It Fl i Ar bytes
170This specifies the density of inodes in the file system.
171The default is to create an inode for every 4 fragments,
172for 4k disks one inode for every 2 fragments.
173If fewer inodes are desired, a larger number should be used;
174to create more inodes a smaller number should be given.
175.It Fl m Ar free-space
176The percentage of space reserved from normal users; the minimum free
177space threshold.
178The default value used is 5%.
179See
180.Xr tunefs 8
181for more details on how to set this option.
182.It Fl N
183Causes the file system parameters to be printed out
184without really creating the file system.
185.It Fl O Ar filesystem-format
186Select the filesystem format:
187.Pp
188.Bl -tag -width 3n -offset indent -compact
189.It 0
190.Bx 4.3
191format file system.
192This option is primarily used to build root file systems that can
193be understood by older boot ROMs.
194.It 1
195Fast File System (FFS), the default for
196.Nm mount_mfs .
197.It 2
198Enhanced Fast File System (FFS2), the default for
199.Nm .
200.El
201.It Fl o Ar optimization
202.Ar space
203or
204.Ar time .
205The file system can either be instructed to try to minimize the
206time spent allocating blocks, or to try to minimize the space
207fragmentation on the disk.
208Unless an optimization has been specified,
209if the value of minfree (see above) is less than 5%, the default
210is to optimize for space; if the value of minfree is greater than
211or equal to 5%, the default is to optimize for time.
212See
213.Xr tunefs 8
214for more details on how to set this option.
215.It Fl q
216Operate in quiet mode.
217With this option,
218.Nm
219will not print extraneous information like superblock backups.
220.It Fl S Ar sector-size
221The size of a sector in bytes (almost always 512).
222Alternatively
223.Ar sector-size
224may instead use a multiplier, as documented in
225.Xr scan_scaled 3 .
226.Ar sector-size
227should be 512 or a multiple of it because the kernel operates
228512\-byte blocks internally.
229A sector is the smallest addressable unit on the physical device.
230Changing this is useful only when using
231.Nm
232to build a file system whose raw image will eventually be used on
233a different type of disk than the one on which it is initially
234created (for example on a write-once disk).
235Note that changing this
236from its default will make it impossible for
237.Xr fsck 8
238to find the alternate superblocks automatically if the standard
239superblock is lost.
240.It Fl s Ar size
241The size of the file system in sectors (see
242.Fl S ) .
243Alternatively
244.Ar size
245may instead use a multiplier, as documented in
246.Xr scan_scaled 3 ,
247to specify size in bytes; in this case
248.Ar size
249is rounded up to the next sector boundary.
250The maximum size of an FFS file system is 2,147,483,647 (2^31 \- 1) of
251512\-byte blocks, slightly less than 1 TB.
252FFS2 file systems can be as large as 64 PB.
253Note however that for
254.Nm mount_mfs
255the practical limit is based on
256.Va datasize
257in
258.Xr login.conf 5 ,
259and ultimately depends on the per-arch
260.Dv MAXDSIZ
261limit.
262.It Fl T Ar disktype
263Uses information for the specified disk from
264.Xr disktab 5
265instead of trying to get the information from the
266.Xr disklabel 5 .
267.It Fl t Ar fstype
268Set the file system type of which file system you wish to create.
269.Nm
270will be smart enough to run the alternate newfs_XXX program instead.
271.El
272.Pp
273The options to
274.Nm mount_mfs
275are as described for
276.Nm ,
277except for the
278.Fl o
279and
280.Fl P
281options.
282.Pp
283Those options are as follows:
284.Bl -tag -width indent
285.It Fl o Ar options
286Options are specified with a
287.Fl o
288flag followed by a comma separated string of options.
289See the
290.Xr mount 8
291man page for possible options and their meanings.
292.It Fl P Ar file
293If
294.Ar file
295is a directory, populate the created mfs file system with the
296contents of the directory.
297If
298.Ar file
299is a block device, populate the created mfs file system with the
300contents of the FFS file system contained on the device.
301.El
302.Pp
303If the
304.Fl P Ar file
305option is not used, the owner and mode of the created mfs file
306system will be the same as the owner and mode of the mount point.
307.Sh ENVIRONMENT
308.Bl -tag -width COLUMNS
309.It Ev COLUMNS
310If set to a positive integer,
311output is formatted to the given width in columns.
312Otherwise,
313.Nm
314defaults to the terminal width, or 80 columns if the output is not a terminal.
315.El
316.Sh SEE ALSO
317.Xr disktab 5 ,
318.Xr fs 5 ,
319.Xr disklabel 8 ,
320.Xr dumpfs 8 ,
321.Xr fsck 8 ,
322.Xr fsirand 8 ,
323.Xr growfs 8 ,
324.Xr mount 8 ,
325.Xr tunefs 8
326.Rs
327.%A M. McKusick
328.%A W. Joy
329.%A S. Leffler
330.%A R. Fabry
331.%T A Fast File System for UNIX
332.%J ACM Transactions on Computer Systems 2
333.%V 3
334.%P pp. 181\(en197
335.%D August 1984
336.%O (reprinted in the BSD System Manager's Manual)
337.Re
338.Rs
339.%A M. McKusick
340.%A M. Karels
341.%A K. Bostic
342.%T "A Pageable Memory Based Filesystem"
343.%J "USENIX Summer Conference Proceedings"
344.%D 1990
345.Re
346.Sh HISTORY
347The
348.Nm
349command appeared in
350.Bx 4.2 .
351