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