xref: /freebsd/sbin/newfs/newfs.8 (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
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 January 21, 2005
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 EJNUln
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 m Ar free-space
54.Op Fl o Ar optimization
55.Op Fl r Ar reserved
56.Op Fl s Ar size
57.Ar special
58.Sh DESCRIPTION
59The
60.Nm
61utility is used to initialize and clear file systems before first use.
62The
63.Nm
64utility builds a file system on the specified special file.
65(We often refer to the
66.Dq special file
67as the
68.Dq disk ,
69although the special file need not be a physical disk.
70In fact, it need not even be special.)
71Typically the defaults are reasonable, however
72.Nm
73has numerous options to allow the defaults to be selectively overridden.
74.Pp
75The following options define the general layout policies:
76.Bl -tag -width indent
77.It Fl E
78Erase the content of the disk before making the filesystem.
79The reserved area in front of the superblock (for bootcode) will not be erased.
80
81This is a relevant option for flash based storage devices that use
82wear levelling algorithms.
83
84NB: Erasing may take as long time as writing every sector on the disk.
85.It Fl J
86Enable journaling on the new file system via gjournal.
87.It Fl L Ar volname
88Add a volume label to the new file system.
89.It Fl N
90Cause the file system parameters to be printed out
91without really creating the file system.
92.It Fl O Ar filesystem-type
93Use 1 to specify that a UFS1 format file system be built;
94use 2 to specify that a UFS2 format file system be built.
95The default format is UFS2.
96.It Fl T Ar disktype
97For backward compatibility.
98.It Fl U
99Enable soft updates on the new file system.
100.It Fl a Ar maxcontig
101Specify the maximum number of contiguous blocks that will be
102laid out before forcing a rotational delay.
103The default value is 16.
104See
105.Xr tunefs 8
106for more details on how to set this option.
107.It Fl b Ar block-size
108The block size of the file system, in bytes.
109It must be a power of 2.
110The
111default size is 16384 bytes, and the smallest allowable size is 4096 bytes.
112The optimal block:fragment ratio is 8:1.
113Other ratios are possible, but are not recommended,
114and may produce poor results.
115.It Fl c Ar blocks-per-cylinder-group
116The number of blocks per cylinder group in a file system.
117The default is to compute the maximum allowed by the other parameters.
118This value is
119dependent on a number of other parameters, in particular the block size
120and the number of bytes per inode.
121.It Fl d Ar max-extent-size
122The file system may choose to store large files using extents.
123This parameter specifies the largest extent size that may be used.
124It is presently limited to its default value which is 16 times
125the file system blocksize.
126.It Fl e Ar maxbpg
127Indicate the maximum number of blocks any single file can
128allocate out of a cylinder group before it is forced to begin
129allocating blocks from another cylinder group.
130The default is about one quarter of the total blocks in a cylinder group.
131See
132.Xr tunefs 8
133for more details on how to set this option.
134.It Fl f Ar frag-size
135The fragment size of the file system in bytes.
136It must be a power of two
137ranging in value between
138.Ar blocksize Ns /8
139and
140.Ar blocksize .
141The default is 2048 bytes.
142.It Fl g Ar avgfilesize
143The expected average file size for the file system.
144.It Fl h Ar avgfpdir
145The expected average number of files per directory on the file system.
146.It Fl i Ar bytes
147Specify the density of inodes in the file system.
148The default is to create an inode for every
149.Pq 4 * Ar frag-size
150bytes of data space.
151If fewer inodes are desired, a larger number should be used;
152to create more inodes a smaller number should be given.
153One inode is required for each distinct file, so this value effectively
154specifies the average file size on the file system.
155.It Fl l
156Enable multilabel MAC on the new file system.
157.It Fl m Ar free-space
158The percentage of space reserved from normal users; the minimum free
159space threshold.
160The default value used is
161defined by
162.Dv MINFREE
163from
164.In ufs/ffs/fs.h ,
165currently 8%.
166See
167.Xr tunefs 8
168for more details on how to set this option.
169.It Fl n
170Do not create a
171.Pa .snap
172directory on the new file system.
173The resulting file system will not support snapshot generation, so
174.Xr dump 8
175in live mode and background
176.Xr fsck 8
177will not function properly.
178The traditional
179.Xr fsck 8
180and offline
181.Xr dump 8
182will work on the file system.
183This option is intended primarily for memory or vnode-backed file systems that
184do not require
185.Xr dump 8
186or
187.Xr fsck 8
188support.
189.It Fl o Ar optimization
190.Cm ( space
191or
192.Cm time ) .
193The file system can either be instructed to try to minimize the time spent
194allocating blocks, or to try to minimize the space fragmentation on the disk.
195If the value of minfree (see above) is less than 8%,
196the default is to optimize for
197.Cm space ;
198if the value of minfree is greater than or equal to 8%,
199the default is to optimize for
200.Cm time .
201See
202.Xr tunefs 8
203for more details on how to set this option.
204.It Fl r Ar reserved
205The size, in sectors, of reserved space
206at the end of the partition specified in
207.Ar special .
208This space will not be occupied by the file system;
209it can be used by other consumers such as
210.Xr geom 4 .
211Defaults to 0.
212.It Fl s Ar size
213The size of the file system in sectors.
214This value defaults to the size of the
215raw partition specified in
216.Ar special
217less the
218.Ar reserved
219space at its end (see
220.Fl r ) .
221A
222.Ar size
223of 0 can also be used to choose the default value.
224A valid
225.Ar size
226value cannot be larger than the default one,
227which means that the file system cannot extend into the reserved space.
228.El
229.Pp
230The following options override the standard sizes for the disk geometry.
231Their default values are taken from the disk label.
232Changing these defaults is useful only when using
233.Nm
234to build a file system whose raw image will eventually be used on a
235different type of disk than the one on which it is initially created
236(for example on a write-once disk).
237Note that changing any of these values from their defaults will make
238it impossible for
239.Xr fsck 8
240to find the alternate superblocks if the standard superblock is lost.
241.Bl -tag -width indent
242.It Fl S Ar sector-size
243The size of a sector in bytes (almost never anything but 512).
244.El
245.Sh EXAMPLES
246.Dl newfs /dev/ad3s1a
247.Pp
248Creates a new ufs file system on
249.Pa ad3s1a .
250The
251.Nm
252utility will use a block size of 16384 bytes, a fragment size of 2048 bytes
253and the largest possible number of blocks per cylinders group.
254These values tend to produce better performance for most applications
255than the historical defaults
256(8192 byte block size and 1024 byte fragment size).
257This large fragment size may lead to much wasted space
258on file systems that contain many small files.
259.Sh SEE ALSO
260.Xr fdformat 1 ,
261.Xr geom 4 ,
262.Xr disktab 5 ,
263.Xr fs 5 ,
264.Xr bsdlabel 8 ,
265.Xr camcontrol 8 ,
266.Xr dump 8 ,
267.Xr dumpfs 8 ,
268.Xr fsck 8 ,
269.Xr mount 8 ,
270.Xr tunefs 8 ,
271.Xr vinum 8
272.Rs
273.%A M. McKusick
274.%A W. Joy
275.%A S. Leffler
276.%A R. Fabry
277.%T A Fast File System for UNIX
278.%J ACM Transactions on Computer Systems 2
279.%V 3
280.%P pp 181-197
281.%D August 1984
282.%O (reprinted in the BSD System Manager's Manual)
283.Re
284.Sh HISTORY
285The
286.Nm
287utility appeared in
288.Bx 4.2 .
289