xref: /openbsd/sbin/newfs/newfs.8 (revision 09467b48)
1.\"	$OpenBSD: newfs.8,v 1.77 2020/05/18 06:20:44 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: May 18 2020 $
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.
171If fewer inodes are desired, a larger number should be used;
172to create more inodes a smaller number should be given.
173.It Fl m Ar free-space
174The percentage of space reserved from normal users; the minimum free
175space threshold.
176The default value used is 5%.
177See
178.Xr tunefs 8
179for more details on how to set this option.
180.It Fl N
181Causes the file system parameters to be printed out
182without really creating the file system.
183.It Fl O Ar filesystem-format
184Select the filesystem format:
185.Pp
186.Bl -tag -width 3n -offset indent -compact
187.It 0
188.Bx 4.3
189format file system.
190This option is primarily used to build root file systems that can
191be understood by older boot ROMs.
192.It 1
193Fast File System (FFS).
194.It 2
195Enhanced Fast File System (FFS2), the default.
196.El
197.It Fl o Ar optimization
198.Ar space
199or
200.Ar time .
201The file system can either be instructed to try to minimize the
202time spent allocating blocks, or to try to minimize the space
203fragmentation on the disk.
204Unless an optimization has been specified,
205if the value of minfree (see above) is less than 5%, the default
206is to optimize for space; if the value of minfree is greater than
207or equal to 5%, the default is to optimize for time.
208See
209.Xr tunefs 8
210for more details on how to set this option.
211.It Fl q
212Operate in quiet mode.
213With this option,
214.Nm
215will not print extraneous information like superblock backups.
216.It Fl S Ar sector-size
217The size of a sector in bytes (almost always 512).
218Alternatively
219.Ar sector-size
220may instead use a multiplier, as documented in
221.Xr scan_scaled 3 .
222.Ar sector-size
223should be 512 or a multiple of it because the kernel operates
224512\-byte blocks internally.
225A sector is the smallest addressable unit on the physical device.
226Changing this is useful only when using
227.Nm
228to build a file system whose raw image will eventually be used on
229a different type of disk than the one on which it is initially
230created (for example on a write-once disk).
231Note that changing this
232from its default will make it impossible for
233.Xr fsck 8
234to find the alternate superblocks automatically if the standard
235superblock is lost.
236.It Fl s Ar size
237The size of the file system in sectors (see
238.Fl S ) .
239Alternatively
240.Ar size
241may instead use a multiplier, as documented in
242.Xr scan_scaled 3 ,
243to specify size in bytes; in this case
244.Ar size
245is rounded up to the next sector boundary.
246The maximum size of an FFS file system is 2,147,483,647 (2^31 \- 1) of
247512\-byte blocks, slightly less than 1 TB.
248FFS2 file systems can be as large as 64 PB.
249Note however that for
250.Nm mount_mfs
251the practical limit is based on
252.Va datasize
253in
254.Xr login.conf 5 ,
255and ultimately depends on the per-arch
256.Dv MAXDSIZ
257limit.
258.It Fl T Ar disktype
259Uses information for the specified disk from
260.Xr disktab 5
261instead of trying to get the information from the
262.Xr disklabel 5 .
263.It Fl t Ar fstype
264Set the file system type of which file system you wish to create.
265.Nm
266will be smart enough to run the alternate newfs_XXX program instead.
267.El
268.Pp
269The options to
270.Nm mount_mfs
271are as described for
272.Nm ,
273except for the
274.Fl o
275and
276.Fl P
277options.
278.Pp
279Those options are as follows:
280.Bl -tag -width indent
281.It Fl o Ar options
282Options are specified with a
283.Fl o
284flag followed by a comma separated string of options.
285See the
286.Xr mount 8
287man page for possible options and their meanings.
288.It Fl P Ar file
289If
290.Ar file
291is a directory, populate the created mfs file system with the
292contents of the directory.
293If
294.Ar file
295is a block device, populate the created mfs file system with the
296contents of the FFS file system contained on the device.
297.El
298.Pp
299If the
300.Fl P Ar file
301option is not used, the owner and mode of the created mfs file
302system will be the same as the owner and mode of the mount point.
303.Sh ENVIRONMENT
304.Bl -tag -width COLUMNS
305.It Ev COLUMNS
306If set to a positive integer,
307output is formatted to the given width in columns.
308Otherwise,
309.Nm
310defaults to the terminal width, or 80 columns if the output is not a terminal.
311.El
312.Sh SEE ALSO
313.Xr disktab 5 ,
314.Xr fs 5 ,
315.Xr disklabel 8 ,
316.Xr dumpfs 8 ,
317.Xr fsck 8 ,
318.Xr fsirand 8 ,
319.Xr growfs 8 ,
320.Xr mount 8 ,
321.Xr tunefs 8
322.Rs
323.%A M. McKusick
324.%A W. Joy
325.%A S. Leffler
326.%A R. Fabry
327.%T A Fast File System for UNIX
328.%J ACM Transactions on Computer Systems 2
329.%V 3
330.%P pp. 181\(en197
331.%D August 1984
332.%O (reprinted in the BSD System Manager's Manual)
333.Re
334.Rs
335.%A M. McKusick
336.%A M. Karels
337.%A K. Bostic
338.%T "A Pageable Memory Based Filesystem"
339.%J "USENIX Summer Conference Proceedings"
340.%D 1990
341.Re
342.Sh HISTORY
343The
344.Nm
345command appeared in
346.Bx 4.2 .
347