xref: /openbsd/sbin/newfs/newfs.8 (revision 771fbea0)
1.\"	$OpenBSD: newfs.8,v 1.78 2021/06/03 06:42:03 otto 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: June 3 2021 $
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 options
69.Op Fl P Ar file
70.Op Fl s Ar size
71.Ar special node
72.Ek
73.Sh DESCRIPTION
74Before running
75.Nm ,
76the disk must be labeled using
77.Xr disklabel 8 .
78.Nm
79builds a file system on the specified
80.Ar special
81device,
82basing its defaults on the information in the disk label.
83Typically the defaults are reasonable, although
84.Nm
85has numerous options to allow the defaults to be selectively overridden.
86.Pp
87The
88.Ar special
89file should be a raw device,
90for example
91.Pa /dev/rsd0a ;
92if a relative path like
93.Pa sd0a
94is specified,
95the corresponding raw device is used.
96.Pp
97.Nm mount_mfs
98is used to build a file system in virtual memory and then mount it
99on a specified node.
100.Nm mount_mfs
101exits and the contents of the file system are lost
102when the file system is unmounted.
103If
104.Nm mount_mfs
105is sent a signal while running,
106for example during system shutdown,
107it will attempt to unmount its
108corresponding file system.
109The parameters to
110.Nm mount_mfs
111are the same as those to
112.Nm newfs .
113The special file is only used to read the disk label which provides
114a set of configuration parameters for the memory based file system.
115The special file is typically that of the primary swap area,
116since that is where the file system will be backed up when
117free memory gets low and the memory supporting
118the file system has to be paged.
119If the keyword
120.Dq swap
121is used instead of a special file name, default configuration parameters
122will be used.
123(This option is useful when trying to use
124.Nm mount_mfs
125on a machine without any disks.)
126.Pp
127Both
128.Nm
129and
130.Nm mount_mfs
131now have the functionality of
132.Xr fsirand 8
133built in, so it is not necessary to run
134.Xr fsirand 8
135manually unless you wish to re-randomize the
136file system (or list the inode generation numbers).
137.Pp
138The options to
139.Nm
140are as follows:
141.Bl -tag -width Ds
142.It Fl b Ar block-size
143The block size of the file system, in bytes.
144If a disklabel is available, the default is read from it.
145Otherwise the default is 16 KB or eight times the fragment size,
146whichever is smaller.
147.It Fl c Ar fragments-per-cylinder-group
148The number of fragments per cylinder group in a file system.
149The default is to compute the maximum allowed by the other parameters.
150This value is dependent on a number of other parameters,
151in particular the block size and the number of bytes per inode.
152.It Fl e Ar maxbpg
153This indicates the maximum number of blocks any single file can
154allocate out of a cylinder group before it is forced to begin
155allocating blocks from another cylinder group.
156The default is about one quarter of the total blocks in a cylinder group.
157See
158.Xr tunefs 8
159for more details on how to set this option.
160.It Fl f Ar frag-size
161The fragment size of the file system in bytes.
162If a disklabel is available, the default is read from it.
163Otherwise the default is 2048.
164.It Fl g Ar avgfilesize
165The expected average file size for the file system in bytes.
166.It Fl h Ar avgfpdir
167The expected average number of files per directory on the file system.
168.It Fl i Ar bytes
169This specifies the density of inodes in the file system.
170The default is to create an inode for every 4 fragments,
171for 4k disks one inode for every 2 fragments.
172If fewer inodes are desired, a larger number should be used;
173to create more inodes a smaller number should be given.
174.It Fl m Ar free-space
175The percentage of space reserved from normal users; the minimum free
176space threshold.
177The default value used is 5%.
178See
179.Xr tunefs 8
180for more details on how to set this option.
181.It Fl N
182Causes the file system parameters to be printed out
183without really creating the file system.
184.It Fl O Ar filesystem-format
185Select the filesystem format:
186.Pp
187.Bl -tag -width 3n -offset indent -compact
188.It 0
189.Bx 4.3
190format file system.
191This option is primarily used to build root file systems that can
192be understood by older boot ROMs.
193.It 1
194Fast File System (FFS).
195.It 2
196Enhanced Fast File System (FFS2), the default.
197.El
198.It Fl o Ar optimization
199.Ar space
200or
201.Ar time .
202The file system can either be instructed to try to minimize the
203time spent allocating blocks, or to try to minimize the space
204fragmentation on the disk.
205Unless an optimization has been specified,
206if the value of minfree (see above) is less than 5%, the default
207is to optimize for space; if the value of minfree is greater than
208or equal to 5%, the default is to optimize for time.
209See
210.Xr tunefs 8
211for more details on how to set this option.
212.It Fl q
213Operate in quiet mode.
214With this option,
215.Nm
216will not print extraneous information like superblock backups.
217.It Fl S Ar sector-size
218The size of a sector in bytes (almost always 512).
219Alternatively
220.Ar sector-size
221may instead use a multiplier, as documented in
222.Xr scan_scaled 3 .
223.Ar sector-size
224should be 512 or a multiple of it because the kernel operates
225512\-byte blocks internally.
226A sector is the smallest addressable unit on the physical device.
227Changing this is useful only when using
228.Nm
229to build a file system whose raw image will eventually be used on
230a different type of disk than the one on which it is initially
231created (for example on a write-once disk).
232Note that changing this
233from its default will make it impossible for
234.Xr fsck 8
235to find the alternate superblocks automatically if the standard
236superblock is lost.
237.It Fl s Ar size
238The size of the file system in sectors (see
239.Fl S ) .
240Alternatively
241.Ar size
242may instead use a multiplier, as documented in
243.Xr scan_scaled 3 ,
244to specify size in bytes; in this case
245.Ar size
246is rounded up to the next sector boundary.
247The maximum size of an FFS file system is 2,147,483,647 (2^31 \- 1) of
248512\-byte blocks, slightly less than 1 TB.
249FFS2 file systems can be as large as 64 PB.
250Note however that for
251.Nm mount_mfs
252the practical limit is based on
253.Va datasize
254in
255.Xr login.conf 5 ,
256and ultimately depends on the per-arch
257.Dv MAXDSIZ
258limit.
259.It Fl T Ar disktype
260Uses information for the specified disk from
261.Xr disktab 5
262instead of trying to get the information from the
263.Xr disklabel 5 .
264.It Fl t Ar fstype
265Set the file system type of which file system you wish to create.
266.Nm
267will be smart enough to run the alternate newfs_XXX program instead.
268.El
269.Pp
270The options to
271.Nm mount_mfs
272are as described for
273.Nm ,
274except for the
275.Fl o
276and
277.Fl P
278options.
279.Pp
280Those options are as follows:
281.Bl -tag -width indent
282.It Fl o Ar options
283Options are specified with a
284.Fl o
285flag followed by a comma separated string of options.
286See the
287.Xr mount 8
288man page for possible options and their meanings.
289.It Fl P Ar file
290If
291.Ar file
292is a directory, populate the created mfs file system with the
293contents of the directory.
294If
295.Ar file
296is a block device, populate the created mfs file system with the
297contents of the FFS file system contained on the device.
298.El
299.Pp
300If the
301.Fl P Ar file
302option is not used, the owner and mode of the created mfs file
303system will be the same as the owner and mode of the mount point.
304.Sh ENVIRONMENT
305.Bl -tag -width COLUMNS
306.It Ev COLUMNS
307If set to a positive integer,
308output is formatted to the given width in columns.
309Otherwise,
310.Nm
311defaults to the terminal width, or 80 columns if the output is not a terminal.
312.El
313.Sh SEE ALSO
314.Xr disktab 5 ,
315.Xr fs 5 ,
316.Xr disklabel 8 ,
317.Xr dumpfs 8 ,
318.Xr fsck 8 ,
319.Xr fsirand 8 ,
320.Xr growfs 8 ,
321.Xr mount 8 ,
322.Xr tunefs 8
323.Rs
324.%A M. McKusick
325.%A W. Joy
326.%A S. Leffler
327.%A R. Fabry
328.%T A Fast File System for UNIX
329.%J ACM Transactions on Computer Systems 2
330.%V 3
331.%P pp. 181\(en197
332.%D August 1984
333.%O (reprinted in the BSD System Manager's Manual)
334.Re
335.Rs
336.%A M. McKusick
337.%A M. Karels
338.%A K. Bostic
339.%T "A Pageable Memory Based Filesystem"
340.%J "USENIX Summer Conference Proceedings"
341.%D 1990
342.Re
343.Sh HISTORY
344The
345.Nm
346command appeared in
347.Bx 4.2 .
348