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