xref: /openbsd/sbin/newfs/newfs.8 (revision da5362d5)
1*da5362d5Sguenther.\"	$OpenBSD: newfs.8,v 1.80 2024/01/09 03:16:00 guenther Exp $
2df930be7Sderaadt.\"	$NetBSD: newfs.8,v 1.12 1995/03/18 14:58:41 cgd Exp $
3df930be7Sderaadt.\"
4df930be7Sderaadt.\" Copyright (c) 1983, 1987, 1991, 1993, 1994
5df930be7Sderaadt.\"	The Regents of the University of California.  All rights reserved.
6df930be7Sderaadt.\"
7df930be7Sderaadt.\" Redistribution and use in source and binary forms, with or without
8df930be7Sderaadt.\" modification, are permitted provided that the following conditions
9df930be7Sderaadt.\" are met:
10df930be7Sderaadt.\" 1. Redistributions of source code must retain the above copyright
11df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer.
12df930be7Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright
13df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer in the
14df930be7Sderaadt.\"    documentation and/or other materials provided with the distribution.
151ef0d710Smillert.\" 3. Neither the name of the University nor the names of its contributors
16df930be7Sderaadt.\"    may be used to endorse or promote products derived from this software
17df930be7Sderaadt.\"    without specific prior written permission.
18df930be7Sderaadt.\"
19df930be7Sderaadt.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20df930be7Sderaadt.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21df930be7Sderaadt.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22df930be7Sderaadt.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23df930be7Sderaadt.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24df930be7Sderaadt.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25df930be7Sderaadt.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26df930be7Sderaadt.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27df930be7Sderaadt.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28df930be7Sderaadt.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29df930be7Sderaadt.\" SUCH DAMAGE.
30df930be7Sderaadt.\"
31df930be7Sderaadt.\"     @(#)newfs.8	8.3 (Berkeley) 3/27/94
32df930be7Sderaadt.\"
33*da5362d5Sguenther.Dd $Mdocdate: January 9 2024 $
34df930be7Sderaadt.Dt NEWFS 8
35fc8533a3Saaron.Os
36df930be7Sderaadt.Sh NAME
3758aefd4bSaaron.Nm newfs , mount_mfs
38df930be7Sderaadt.Nd construct a new file system
39df930be7Sderaadt.Sh SYNOPSIS
407349792aSaaron.Nm newfs
41044785f1Sjmc.Bk -words
42992d7f77Smillert.Op Fl Nq
43df930be7Sderaadt.Op Fl b Ar block-size
445d5f5f99Sotto.Op Fl c Ar fragments-per-cylinder-group
45df930be7Sderaadt.Op Fl e Ar maxbpg
46df930be7Sderaadt.Op Fl f Ar frag-size
47b1bed20eStedu.Op Fl g Ar avgfilesize
486707edc7Stedu.Op Fl h Ar avgfpdir
49df930be7Sderaadt.Op Fl i Ar bytes
5019e9c204Sjmc.Op Fl m Ar free-space
51992d7f77Smillert.Op Fl O Ar filesystem-format
52df930be7Sderaadt.Op Fl o Ar optimization
5319e9c204Sjmc.Op Fl S Ar sector-size
54df930be7Sderaadt.Op Fl s Ar size
5562202a9dSjmc.Op Fl T Ar disktype
56212ed4daSderaadt.Op Fl t Ar fstype
57df930be7Sderaadt.Ar special
58044785f1Sjmc.Ek
5958aefd4bSaaron.Pp
60df930be7Sderaadt.Nm mount_mfs
61044785f1Sjmc.Bk -words
62df930be7Sderaadt.Op Fl b Ar block-size
635d5f5f99Sotto.Op Fl c Ar fragments-per-cylinder-group
64df930be7Sderaadt.Op Fl e Ar maxbpg
65df930be7Sderaadt.Op Fl f Ar frag-size
66df930be7Sderaadt.Op Fl i Ar bytes
67c24776e6Ssobrado.Op Fl m Ar free-space
689320ea12Ssthen.Op Fl O Ar filesystem-format
69df930be7Sderaadt.Op Fl o Ar options
7019e9c204Sjmc.Op Fl P Ar file
71df930be7Sderaadt.Op Fl s Ar size
72df930be7Sderaadt.Ar special node
73044785f1Sjmc.Ek
74df930be7Sderaadt.Sh DESCRIPTION
75df930be7SderaadtBefore running
7609c515c2Sjmc.Nm ,
77df930be7Sderaadtthe disk must be labeled using
78df930be7Sderaadt.Xr disklabel 8 .
7958aefd4bSaaron.Nm
805eaf1a72Saaronbuilds a file system on the specified
815eaf1a72Saaron.Ar special
825eaf1a72Saarondevice,
83df930be7Sderaadtbasing its defaults on the information in the disk label.
84fff41271SpjanzenTypically the defaults are reasonable, although
8558aefd4bSaaron.Nm
86df930be7Sderaadthas numerous options to allow the defaults to be selectively overridden.
87df930be7Sderaadt.Pp
887238ea4fSottoThe
897238ea4fSotto.Ar special
907238ea4fSottofile should be a raw device,
917238ea4fSottofor example
927238ea4fSotto.Pa /dev/rsd0a ;
937238ea4fSottoif a relative path like
947238ea4fSotto.Pa sd0a
957238ea4fSottois specified,
967238ea4fSottothe corresponding raw device is used.
977238ea4fSotto.Pp
985eaf1a72Saaron.Nm mount_mfs
99df930be7Sderaadtis used to build a file system in virtual memory and then mount it
100df930be7Sderaadton a specified node.
1015eaf1a72Saaron.Nm mount_mfs
102df930be7Sderaadtexits and the contents of the file system are lost
103df930be7Sderaadtwhen the file system is unmounted.
104df930be7SderaadtIf
105df930be7Sderaadt.Nm mount_mfs
106df930be7Sderaadtis sent a signal while running,
107df930be7Sderaadtfor example during system shutdown,
108df930be7Sderaadtit will attempt to unmount its
109df930be7Sderaadtcorresponding file system.
110df930be7SderaadtThe parameters to
111df930be7Sderaadt.Nm mount_mfs
112df930be7Sderaadtare the same as those to
113df930be7Sderaadt.Nm newfs .
114df930be7SderaadtThe special file is only used to read the disk label which provides
115df930be7Sderaadta set of configuration parameters for the memory based file system.
116df930be7SderaadtThe special file is typically that of the primary swap area,
117df930be7Sderaadtsince that is where the file system will be backed up when
118df930be7Sderaadtfree memory gets low and the memory supporting
1199615e1d4Saaronthe file system has to be paged.
1209615e1d4SaaronIf the keyword
12195675cd5Saaron.Dq swap
122df930be7Sderaadtis used instead of a special file name, default configuration parameters
1239615e1d4Saaronwill be used.
1249615e1d4Saaron(This option is useful when trying to use
125df930be7Sderaadt.Nm mount_mfs
126df930be7Sderaadton a machine without any disks.)
127df930be7Sderaadt.Pp
128b3593665SmillertBoth
129b3593665Smillert.Nm
130b3593665Smillertand
131b3593665Smillert.Nm mount_mfs
132b3593665Smillertnow have the functionality of
133b3593665Smillert.Xr fsirand 8
13497c4e750Sjmcbuilt in, so it is not necessary to run
135b3593665Smillert.Xr fsirand 8
136b3593665Smillertmanually unless you wish to re-randomize the
137b3593665Smillertfile system (or list the inode generation numbers).
138b3593665Smillert.Pp
13962202a9dSjmcThe options to
14062202a9dSjmc.Nm
14162202a9dSjmcare as follows:
1422a110ee1Sschwarze.Bl -tag -width Ds
143df930be7Sderaadt.It Fl b Ar block-size
144df930be7SderaadtThe block size of the file system, in bytes.
145a15f91ccSottoIf a disklabel is available, the default is read from it.
146a15f91ccSottoOtherwise the default is 16 KB or eight times the fragment size,
147a15f91ccSottowhichever is smaller.
1485d5f5f99Sotto.It Fl c Ar fragments-per-cylinder-group
1495d5f5f99SottoThe number of fragments per cylinder group in a file system.
150992d7f77SmillertThe default is to compute the maximum allowed by the other parameters.
151992d7f77SmillertThis value is dependent on a number of other parameters,
152992d7f77Smillertin particular the block size and the number of bytes per inode.
153df930be7Sderaadt.It Fl e Ar maxbpg
154df930be7SderaadtThis indicates the maximum number of blocks any single file can
155df930be7Sderaadtallocate out of a cylinder group before it is forced to begin
156df930be7Sderaadtallocating blocks from another cylinder group.
157df930be7SderaadtThe default is about one quarter of the total blocks in a cylinder group.
158df930be7SderaadtSee
159df930be7Sderaadt.Xr tunefs 8
160df930be7Sderaadtfor more details on how to set this option.
161df930be7Sderaadt.It Fl f Ar frag-size
162df930be7SderaadtThe fragment size of the file system in bytes.
163a15f91ccSottoIf a disklabel is available, the default is read from it.
164a15f91ccSottoOtherwise the default is 2048.
165b1bed20eStedu.It Fl g Ar avgfilesize
1662c11113eSteduThe expected average file size for the file system in bytes.
167b1bed20eStedu.It Fl h Ar avgfpdir
168b1bed20eSteduThe expected average number of files per directory on the file system.
16919e9c204Sjmc.It Fl i Ar bytes
170df930be7SderaadtThis specifies the density of inodes in the file system.
17183d1f402SottoThe default is to create an inode for every 4 fragments,
17283d1f402Sottofor 4k disks one inode for every 2 fragments.
173df930be7SderaadtIf fewer inodes are desired, a larger number should be used;
174df930be7Sderaadtto create more inodes a smaller number should be given.
17519e9c204Sjmc.It Fl m Ar free-space
176df930be7SderaadtThe percentage of space reserved from normal users; the minimum free
177df930be7Sderaadtspace threshold.
178e4cb669cSderaadtThe default value used is 5%.
179df930be7SderaadtSee
180df930be7Sderaadt.Xr tunefs 8
181df930be7Sderaadtfor more details on how to set this option.
18219e9c204Sjmc.It Fl N
18319e9c204SjmcCauses the file system parameters to be printed out
18419e9c204Sjmcwithout really creating the file system.
18530b3308dSjmc.It Fl O Ar filesystem-format
18630b3308dSjmcSelect the filesystem format:
18730b3308dSjmc.Pp
188992d7f77Smillert.Bl -tag -width 3n -offset indent -compact
189992d7f77Smillert.It 1
1909320ea12SsthenFast File System (FFS), the default for
1919320ea12Ssthen.Nm mount_mfs .
192992d7f77Smillert.It 2
1939320ea12SsthenEnhanced Fast File System (FFS2), the default for
1949320ea12Ssthen.Nm .
195992d7f77Smillert.El
19619e9c204Sjmc.It Fl o Ar optimization
19795675cd5Saaron.Ar space
19895675cd5Saaronor
19995675cd5Saaron.Ar time .
200992d7f77SmillertThe file system can either be instructed to try to minimize the
201992d7f77Smillerttime spent allocating blocks, or to try to minimize the space
20230b3308dSjmcfragmentation on the disk.
20330b3308dSjmcUnless an optimization has been specified,
204992d7f77Smillertif the value of minfree (see above) is less than 5%, the default
205992d7f77Smillertis to optimize for space; if the value of minfree is greater than
20630b3308dSjmcor equal to 5%, the default is to optimize for time.
20730b3308dSjmcSee
208df930be7Sderaadt.Xr tunefs 8
209df930be7Sderaadtfor more details on how to set this option.
21019e9c204Sjmc.It Fl q
21130b3308dSjmcOperate in quiet mode.
21230b3308dSjmcWith this option,
21319e9c204Sjmc.Nm
21419e9c204Sjmcwill not print extraneous information like superblock backups.
21562202a9dSjmc.It Fl S Ar sector-size
21646d12c8bSkrwThe size of a sector in bytes (almost always 512).
217f3095649SdcoppaAlternatively
218f3095649Sdcoppa.Ar sector-size
219f3095649Sdcoppamay instead use a multiplier, as documented in
220f3095649Sdcoppa.Xr scan_scaled 3 .
221f3095649Sdcoppa.Ar sector-size
222f3095649Sdcoppashould be 512 or a multiple of it because the kernel operates
223f3095649Sdcoppa512\-byte blocks internally.
22446d12c8bSkrwA sector is the smallest addressable unit on the physical device.
22562202a9dSjmcChanging this is useful only when using
22662202a9dSjmc.Nm
22762202a9dSjmcto build a file system whose raw image will eventually be used on
22862202a9dSjmca different type of disk than the one on which it is initially
22962202a9dSjmccreated (for example on a write-once disk).
23062202a9dSjmcNote that changing this
23162202a9dSjmcfrom its default will make it impossible for
23262202a9dSjmc.Xr fsck 8
233f3095649Sdcoppato find the alternate superblocks automatically if the standard
234f3095649Sdcoppasuperblock is lost.
235df930be7Sderaadt.It Fl s Ar size
236f3095649SdcoppaThe size of the file system in sectors (see
237f3095649Sdcoppa.Fl S ) .
238f3095649SdcoppaAlternatively
239f3095649Sdcoppa.Ar size
240f3095649Sdcoppamay instead use a multiplier, as documented in
241f3095649Sdcoppa.Xr scan_scaled 3 ,
242f3095649Sdcoppato specify size in bytes; in this case
243f3095649Sdcoppa.Ar size
244f3095649Sdcoppais rounded up to the next sector boundary.
245f3095649SdcoppaThe maximum size of an FFS file system is 2,147,483,647 (2^31 \- 1) of
24646d12c8bSkrw512\-byte blocks, slightly less than 1 TB.
24746d12c8bSkrwFFS2 file systems can be as large as 64 PB.
24830b3308dSjmcNote however that for
2491dcd5a5cSotto.Nm mount_mfs
2501dcd5a5cSottothe practical limit is based on
25131ac3e4eSjmc.Va datasize
25231ac3e4eSjmcin
25331ac3e4eSjmc.Xr login.conf 5 ,
25431ac3e4eSjmcand ultimately depends on the per-arch
25531ac3e4eSjmc.Dv MAXDSIZ
25631ac3e4eSjmclimit.
25762202a9dSjmc.It Fl T Ar disktype
25862202a9dSjmcUses information for the specified disk from
25962202a9dSjmc.Xr disktab 5
26062202a9dSjmcinstead of trying to get the information from the
26162202a9dSjmc.Xr disklabel 5 .
262212ed4daSderaadt.It Fl t Ar fstype
263212ed4daSderaadtSet the file system type of which file system you wish to create.
26458aefd4bSaaron.Nm
265212ed4daSderaadtwill be smart enough to run the alternate newfs_XXX program instead.
266df930be7Sderaadt.El
267df930be7Sderaadt.Pp
26862202a9dSjmcThe options to
269df930be7Sderaadt.Nm mount_mfs
27062202a9dSjmcare as described for
27162202a9dSjmc.Nm ,
27262202a9dSjmcexcept for the
273df930be7Sderaadt.Fl o
27419e9c204Sjmcand
27519e9c204Sjmc.Fl P
27619e9c204Sjmcoptions.
277df930be7Sderaadt.Pp
27862202a9dSjmcThose options are as follows:
279df930be7Sderaadt.Bl -tag -width indent
28019e9c204Sjmc.It Fl o Ar options
28119e9c204SjmcOptions are specified with a
28219e9c204Sjmc.Fl o
28330b3308dSjmcflag followed by a comma separated string of options.
28430b3308dSjmcSee the
28519e9c204Sjmc.Xr mount 8
28619e9c204Sjmcman page for possible options and their meanings.
28709758f56Sotto.It Fl P Ar file
28809758f56SottoIf
28909758f56Sotto.Ar file
290992d7f77Smillertis a directory, populate the created mfs file system with the
29130b3308dSjmccontents of the directory.
29230b3308dSjmcIf
29309758f56Sotto.Ar file
294992d7f77Smillertis a block device, populate the created mfs file system with the
295992d7f77Smillertcontents of the FFS file system contained on the device.
296df930be7Sderaadt.El
29709758f56Sotto.Pp
29809758f56SottoIf the
29909758f56Sotto.Fl P Ar file
300992d7f77Smillertoption is not used, the owner and mode of the created mfs file
301992d7f77Smillertsystem will be the same as the owner and mode of the mount point.
3027220d8ecSbentley.Sh ENVIRONMENT
3037220d8ecSbentley.Bl -tag -width COLUMNS
3047220d8ecSbentley.It Ev COLUMNS
3057220d8ecSbentleyIf set to a positive integer,
3067220d8ecSbentleyoutput is formatted to the given width in columns.
3077220d8ecSbentleyOtherwise,
3087220d8ecSbentley.Nm
3097220d8ecSbentleydefaults to the terminal width, or 80 columns if the output is not a terminal.
3107220d8ecSbentley.El
311df930be7Sderaadt.Sh SEE ALSO
312df930be7Sderaadt.Xr disktab 5 ,
313df930be7Sderaadt.Xr fs 5 ,
314df930be7Sderaadt.Xr disklabel 8 ,
3157acc01d2Saaron.Xr dumpfs 8 ,
3167acc01d2Saaron.Xr fsck 8 ,
3177acc01d2Saaron.Xr fsirand 8 ,
318cfd956ddSjmc.Xr growfs 8 ,
319df930be7Sderaadt.Xr mount 8 ,
3207acc01d2Saaron.Xr tunefs 8
321df930be7Sderaadt.Rs
322df930be7Sderaadt.%A M. McKusick
323df930be7Sderaadt.%A W. Joy
324df930be7Sderaadt.%A S. Leffler
325df930be7Sderaadt.%A R. Fabry
32679b21c69Sderaadt.%T A Fast File System for UNIX
327df930be7Sderaadt.%J ACM Transactions on Computer Systems 2
328df930be7Sderaadt.%V 3
329301058f1Sschwarze.%P pp. 181\(en197
330df930be7Sderaadt.%D August 1984
331df930be7Sderaadt.%O (reprinted in the BSD System Manager's Manual)
332df930be7Sderaadt.Re
3339780d940Sjsg.Rs
3349780d940Sjsg.%A M. McKusick
3359780d940Sjsg.%A M. Karels
3369780d940Sjsg.%A K. Bostic
3379780d940Sjsg.%T "A Pageable Memory Based Filesystem"
3389780d940Sjsg.%J "USENIX Summer Conference Proceedings"
3399780d940Sjsg.%D 1990
3409780d940Sjsg.Re
341df930be7Sderaadt.Sh HISTORY
342df930be7SderaadtThe
343df930be7Sderaadt.Nm
344df930be7Sderaadtcommand appeared in
345df930be7Sderaadt.Bx 4.2 .
346