xref: /freebsd/sbin/newfs/newfs.8 (revision 13ea0450a9c8742119d36f3bf8f47accdce46e54)
1.\" Copyright (c) 1983, 1987, 1991, 1993, 1994
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     @(#)newfs.8	8.6 (Berkeley) 5/3/95
29.\" $FreeBSD$
30.\"
31.Dd January 29, 2019
32.Dt NEWFS 8
33.Os
34.Sh NAME
35.Nm newfs
36.Nd construct a new UFS1/UFS2 file system
37.Sh SYNOPSIS
38.Nm
39.Op Fl EJNUjlnt
40.Op Fl L Ar volname
41.Op Fl O Ar filesystem-type
42.Op Fl S Ar sector-size
43.Op Fl T Ar disktype
44.Op Fl a Ar maxcontig
45.Op Fl b Ar block-size
46.Op Fl c Ar blocks-per-cylinder-group
47.Op Fl d Ar max-extent-size
48.Op Fl e Ar maxbpg
49.Op Fl f Ar frag-size
50.Op Fl g Ar avgfilesize
51.Op Fl h Ar avgfpdir
52.Op Fl i Ar bytes
53.Op Fl k Ar held-for-metadata-blocks
54.Op Fl m Ar free-space
55.Op Fl o Ar optimization
56.Op Fl p Ar partition
57.Op Fl r Ar reserved
58.Op Fl s Ar size
59.Ar special
60.Sh DESCRIPTION
61The
62.Nm
63utility is used to initialize and clear file systems before first use.
64The
65.Nm
66utility builds a file system on the specified special file.
67(We often refer to the
68.Dq special file
69as the
70.Dq disk ,
71although the special file need not be a physical disk.
72In fact, it need not even be special.)
73Typically the defaults are reasonable, however
74.Nm
75has numerous options to allow the defaults to be selectively overridden.
76.Pp
77The following options define the general layout policies:
78.Bl -tag -width indent
79.It Fl E
80Erase the content of the disk before making the filesystem.
81The reserved area in front of the superblock (for bootcode) will not be erased.
82Erasing is only relevant to flash-memory or thinly provisioned devices.
83Erasing may take a long time.
84If the device does not support BIO_DELETE, the command will fail.
85.It Fl J
86Enable journaling on the new file system via gjournal.
87See
88.Xr gjournal 8
89for details.
90.It Fl L Ar volname
91Add a volume label to the new file system.
92Legal characters are alphanumerics, dashes, and underscores.
93.It Fl N
94Cause the file system parameters to be printed out
95without really creating the file system.
96.It Fl O Ar filesystem-type
97Use 1 to specify that a UFS1 format file system be built;
98use 2 to specify that a UFS2 format file system be built.
99The default format is UFS2.
100.It Fl T Ar disktype
101For backward compatibility.
102.It Fl U
103Enable soft updates on the new file system.
104.It Fl a Ar maxcontig
105Specify the maximum number of contiguous blocks that will be
106laid out before forcing a rotational delay.
107The default value is 16.
108See
109.Xr tunefs 8
110for more details on how to set this option.
111.It Fl b Ar block-size
112The block size of the file system, in bytes.
113It must be a power of 2.
114The
115default size is 32768 bytes, and the smallest allowable size is 4096 bytes.
116The optimal block:fragment ratio is 8:1.
117Other ratios are possible, but are not recommended,
118and may produce poor results.
119.It Fl c Ar blocks-per-cylinder-group
120The number of blocks per cylinder group in a file system.
121The default is to compute the maximum allowed by the other parameters.
122This value is
123dependent on a number of other parameters, in particular the block size
124and the number of bytes per inode.
125.It Fl d Ar max-extent-size
126The file system may choose to store large files using extents.
127This parameter specifies the largest extent size that may be used.
128The default value is the file system blocksize.
129It is presently limited to a maximum value of 16 times the
130file system blocksize and a minimum value of the file system blocksize.
131.It Fl e Ar maxbpg
132Indicate the maximum number of blocks any single file can
133allocate out of a cylinder group before it is forced to begin
134allocating blocks from another cylinder group.
135The default is about one quarter of the total blocks in a cylinder group.
136See
137.Xr tunefs 8
138for more details on how to set this option.
139.It Fl f Ar frag-size
140The fragment size of the file system in bytes.
141It must be a power of two
142ranging in value between
143.Ar blocksize Ns /8
144and
145.Ar blocksize .
146The default is 4096 bytes.
147.It Fl g Ar avgfilesize
148The expected average file size for the file system.
149.It Fl h Ar avgfpdir
150The expected average number of files per directory on the file system.
151.It Fl i Ar bytes
152Specify the density of inodes in the file system.
153The default is to create an inode for every
154.Pq 2 * Ar frag-size
155bytes of data space.
156If fewer inodes are desired, a larger number should be used;
157to create more inodes a smaller number should be given.
158One inode is required for each distinct file, so this value effectively
159specifies the average file size on the file system.
160.It Fl j
161Enable soft updates journaling on the new file system.
162This flag is implemented by running the
163.Xr tunefs 8
164utility found in the user's
165.Dv $PATH .
166.It Fl k Ar held-for-metadata-blocks
167Set the amount of space to be held for metadata blocks in each cylinder group.
168When set, the file system preference routines will try to save
169the specified amount of space immediately following the inode blocks
170in each cylinder group for use by metadata blocks.
171Clustering the metadata blocks speeds up random file access
172and decreases the running time of
173.Xr fsck 8 .
174By default
175.Nm
176sets it to half of the space reserved to minfree.
177.It Fl l
178Enable multilabel MAC on the new file system.
179.It Fl m Ar free-space
180The percentage of space reserved from normal users; the minimum free
181space threshold.
182The default value used is
183defined by
184.Dv MINFREE
185from
186.In ufs/ffs/fs.h ,
187currently 8%.
188See
189.Xr tunefs 8
190for more details on how to set this option.
191.It Fl n
192Do not create a
193.Pa .snap
194directory on the new file system.
195The resulting file system will not support snapshot generation, so
196.Xr dump 8
197in live mode and background
198.Xr fsck 8
199will not function properly.
200The traditional
201.Xr fsck 8
202and offline
203.Xr dump 8
204will work on the file system.
205This option is intended primarily for memory or vnode-backed file systems that
206do not require
207.Xr dump 8
208or
209.Xr fsck 8
210support.
211.It Fl o Ar optimization
212.Cm ( space
213or
214.Cm time ) .
215The file system can either be instructed to try to minimize the time spent
216allocating blocks, or to try to minimize the space fragmentation on the disk.
217If the value of minfree (see above) is less than 8%,
218the default is to optimize for
219.Cm space ;
220if the value of minfree is greater than or equal to 8%,
221the default is to optimize for
222.Cm time .
223See
224.Xr tunefs 8
225for more details on how to set this option.
226.It Fl p Ar partition
227The partition name (a..h) you want to use in case the underlying image
228is a file, so you do not have access to individual partitions through the
229filesystem.
230Can also be used with a device, e.g.,
231.Nm
232.Fl p Ar f
233.Ar /dev/da1s3
234is equivalent to
235.Nm
236.Ar /dev/da1s3f .
237.It Fl r Ar reserved
238The size, in sectors, of reserved space
239at the end of the partition specified in
240.Ar special .
241This space will not be occupied by the file system;
242it can be used by other consumers such as
243.Xr geom 4 .
244Defaults to 0.
245.It Fl s Ar size
246The size of the file system in sectors.
247This value defaults to the size of the
248raw partition specified in
249.Ar special
250less the
251.Ar reserved
252space at its end (see
253.Fl r ) .
254A
255.Ar size
256of 0 can also be used to choose the default value.
257A valid
258.Ar size
259value cannot be larger than the default one,
260which means that the file system cannot extend into the reserved space.
261.It Fl t
262Turn on the TRIM enable flag.
263If enabled, and if the underlying device supports the BIO_DELETE
264command, the file system will send a delete request to the underlying
265device for each freed block.
266The trim enable flag is typically set for flash-memory devices to
267reduce write amplification which reduces wear on write-limited
268flash-memory and often improves long-term performance.
269Thinly provisioned storage also benefits by returning unused blocks to
270the global pool.
271.El
272.Pp
273The following options override the standard sizes for the disk geometry.
274Their default values are taken from the disk label.
275Changing these defaults is useful only when using
276.Nm
277to build a file system whose raw image will eventually be used on a
278different type of disk than the one on which it is initially created
279(for example on a write-once disk).
280Note that changing any of these values from their defaults will make
281it impossible for
282.Xr fsck 8
283to find the alternate superblocks if the standard superblock is lost.
284.Bl -tag -width indent
285.It Fl S Ar sector-size
286The size of a sector in bytes (almost never anything but 512).
287.El
288.Sh EXAMPLES
289.Dl newfs /dev/ada3s1a
290.Pp
291Creates a new ufs file system on
292.Pa ada3s1a .
293The
294.Nm
295utility will use a block size of 32768 bytes, a fragment size of 4096 bytes
296and the largest possible number of blocks per cylinders group.
297These values tend to produce better performance for most applications
298than the historical defaults
299(8192 byte block size and 1024 byte fragment size).
300This large fragment size may lead to much wasted space
301on file systems that contain many small files.
302.Sh SEE ALSO
303.Xr fdformat 1 ,
304.Xr geom 4 ,
305.Xr disktab 5 ,
306.Xr fs 5 ,
307.Xr camcontrol 8 ,
308.Xr dump 8 ,
309.Xr dumpfs 8 ,
310.Xr fsck 8 ,
311.Xr gpart 8 ,
312.Xr gjournal 8 ,
313.Xr growfs 8 ,
314.Xr gvinum 8 ,
315.Xr makefs 8 ,
316.Xr mount 8 ,
317.Xr tunefs 8
318.Rs
319.%A M. McKusick
320.%A W. Joy
321.%A S. Leffler
322.%A R. Fabry
323.%T A Fast File System for UNIX
324.%J ACM Transactions on Computer Systems 2
325.%V 3
326.%P pp 181-197
327.%D August 1984
328.%O (reprinted in the BSD System Manager's Manual)
329.Re
330.Sh HISTORY
331The
332.Nm
333utility appeared in
334.Bx 4.2 .
335