xref: /freebsd/sbin/newfs/newfs.8 (revision 6ae1554a5d9b318f8ad53ccc39fa5a961403da73)
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.\" 4. 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 July 15, 2015
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.
82.Pp
83This option is only relevant for flash based storage devices that use
84wear-leveling algorithms.
85.Pp
86Erasing may take a long time as it writes to every sector on the disk.
87.It Fl J
88Enable journaling on the new file system via gjournal.
89See
90.Xr gjournal 8
91for details.
92.It Fl L Ar volname
93Add a volume label to the new file system.
94.It Fl N
95Cause the file system parameters to be printed out
96without really creating the file system.
97.It Fl O Ar filesystem-type
98Use 1 to specify that a UFS1 format file system be built;
99use 2 to specify that a UFS2 format file system be built.
100The default format is UFS2.
101.It Fl T Ar disktype
102For backward compatibility.
103.It Fl U
104Enable soft updates on the new file system.
105.It Fl a Ar maxcontig
106Specify the maximum number of contiguous blocks that will be
107laid out before forcing a rotational delay.
108The default value is 16.
109See
110.Xr tunefs 8
111for more details on how to set this option.
112.It Fl b Ar block-size
113The block size of the file system, in bytes.
114It must be a power of 2.
115The
116default size is 32768 bytes, and the smallest allowable size is 4096 bytes.
117The optimal block:fragment ratio is 8:1.
118Other ratios are possible, but are not recommended,
119and may produce poor results.
120.It Fl c Ar blocks-per-cylinder-group
121The number of blocks per cylinder group in a file system.
122The default is to compute the maximum allowed by the other parameters.
123This value is
124dependent on a number of other parameters, in particular the block size
125and the number of bytes per inode.
126.It Fl d Ar max-extent-size
127The file system may choose to store large files using extents.
128This parameter specifies the largest extent size that may be used.
129The default value is the file system blocksize.
130It is presently limited to a maximum value of 16 times the
131file system blocksize and a minimum value of the file system blocksize.
132.It Fl e Ar maxbpg
133Indicate the maximum number of blocks any single file can
134allocate out of a cylinder group before it is forced to begin
135allocating blocks from another cylinder group.
136The default is about one quarter of the total blocks in a cylinder group.
137See
138.Xr tunefs 8
139for more details on how to set this option.
140.It Fl f Ar frag-size
141The fragment size of the file system in bytes.
142It must be a power of two
143ranging in value between
144.Ar blocksize Ns /8
145and
146.Ar blocksize .
147The default is 4096 bytes.
148.It Fl g Ar avgfilesize
149The expected average file size for the file system.
150.It Fl h Ar avgfpdir
151The expected average number of files per directory on the file system.
152.It Fl i Ar bytes
153Specify the density of inodes in the file system.
154The default is to create an inode for every
155.Pq 2 * Ar frag-size
156bytes of data space.
157If fewer inodes are desired, a larger number should be used;
158to create more inodes a smaller number should be given.
159One inode is required for each distinct file, so this value effectively
160specifies the average file size on the file system.
161.It Fl j
162Enable soft updates journaling on the new file system.
163This flag is implemented by running the
164.Xr tunefs 8
165utility found in the user's
166.Dv $PATH .
167.It Fl k Ar held-for-metadata-blocks
168Set the amount of space to be held for metadata blocks in each cylinder group.
169When set, the file system preference routines will try to save
170the specified amount of space immediately following the inode blocks
171in each cylinder group for use by metadata blocks.
172Clustering the metadata blocks speeds up random file access
173and decreases the running time of
174.Xr fsck 8 .
175By default
176.Nm
177sets it to half of the space reserved to minfree.
178.It Fl l
179Enable multilabel MAC on the new file system.
180.It Fl m Ar free-space
181The percentage of space reserved from normal users; the minimum free
182space threshold.
183The default value used is
184defined by
185.Dv MINFREE
186from
187.In ufs/ffs/fs.h ,
188currently 8%.
189See
190.Xr tunefs 8
191for more details on how to set this option.
192.It Fl n
193Do not create a
194.Pa .snap
195directory on the new file system.
196The resulting file system will not support snapshot generation, so
197.Xr dump 8
198in live mode and background
199.Xr fsck 8
200will not function properly.
201The traditional
202.Xr fsck 8
203and offline
204.Xr dump 8
205will work on the file system.
206This option is intended primarily for memory or vnode-backed file systems that
207do not require
208.Xr dump 8
209or
210.Xr fsck 8
211support.
212.It Fl o Ar optimization
213.Cm ( space
214or
215.Cm time ) .
216The file system can either be instructed to try to minimize the time spent
217allocating blocks, or to try to minimize the space fragmentation on the disk.
218If the value of minfree (see above) is less than 8%,
219the default is to optimize for
220.Cm space ;
221if the value of minfree is greater than or equal to 8%,
222the default is to optimize for
223.Cm time .
224See
225.Xr tunefs 8
226for more details on how to set this option.
227.It Fl p Ar partition
228The partition name (a..h) you want to use in case the underlying image
229is a file, so you do not have access to individual partitions through the
230filesystem.
231Can also be used with a device, e.g.,
232.Nm
233.Fl p Ar f
234.Ar /dev/da1s3
235is equivalent to
236.Nm
237.Ar /dev/da1s3f .
238.It Fl r Ar reserved
239The size, in sectors, of reserved space
240at the end of the partition specified in
241.Ar special .
242This space will not be occupied by the file system;
243it can be used by other consumers such as
244.Xr geom 4 .
245Defaults to 0.
246.It Fl s Ar size
247The size of the file system in sectors.
248This value defaults to the size of the
249raw partition specified in
250.Ar special
251less the
252.Ar reserved
253space at its end (see
254.Fl r ) .
255A
256.Ar size
257of 0 can also be used to choose the default value.
258A valid
259.Ar size
260value cannot be larger than the default one,
261which means that the file system cannot extend into the reserved space.
262.It Fl t
263Turn on the TRIM enable flag.
264If enabled, and if the underlying device supports the BIO_DELETE
265command, the file system will send a delete request to the underlying
266device for each freed block.
267The trim enable flag is typically set when the underlying device
268uses flash-memory as the device can use the delete command to
269pre-zero or at least avoid copying blocks that have been deleted.
270.El
271.Pp
272The following options override the standard sizes for the disk geometry.
273Their default values are taken from the disk label.
274Changing these defaults is useful only when using
275.Nm
276to build a file system whose raw image will eventually be used on a
277different type of disk than the one on which it is initially created
278(for example on a write-once disk).
279Note that changing any of these values from their defaults will make
280it impossible for
281.Xr fsck 8
282to find the alternate superblocks if the standard superblock is lost.
283.Bl -tag -width indent
284.It Fl S Ar sector-size
285The size of a sector in bytes (almost never anything but 512).
286.El
287.Sh EXAMPLES
288.Dl newfs /dev/ada3s1a
289.Pp
290Creates a new ufs file system on
291.Pa ada3s1a .
292The
293.Nm
294utility will use a block size of 32768 bytes, a fragment size of 4096 bytes
295and the largest possible number of blocks per cylinders group.
296These values tend to produce better performance for most applications
297than the historical defaults
298(8192 byte block size and 1024 byte fragment size).
299This large fragment size may lead to much wasted space
300on file systems that contain many small files.
301.Sh SEE ALSO
302.Xr fdformat 1 ,
303.Xr geom 4 ,
304.Xr disktab 5 ,
305.Xr fs 5 ,
306.Xr camcontrol 8 ,
307.Xr dump 8 ,
308.Xr dumpfs 8 ,
309.Xr fsck 8 ,
310.Xr gpart 8 ,
311.Xr gjournal 8 ,
312.Xr growfs 8 ,
313.Xr gvinum 8 ,
314.Xr makefs 8 ,
315.Xr mount 8 ,
316.Xr tunefs 8
317.Rs
318.%A M. McKusick
319.%A W. Joy
320.%A S. Leffler
321.%A R. Fabry
322.%T A Fast File System for UNIX
323.%J ACM Transactions on Computer Systems 2
324.%V 3
325.%P pp 181-197
326.%D August 1984
327.%O (reprinted in the BSD System Manager's Manual)
328.Re
329.Sh HISTORY
330The
331.Nm
332utility appeared in
333.Bx 4.2 .
334