xref: /freebsd/sbin/newfs/newfs.8 (revision f9218d3d4fd34f082473b3a021c6d4d109fb47cf)
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. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)newfs.8	8.6 (Berkeley) 5/3/95
33.\" $FreeBSD$
34.\"
35.Dd May 18, 2002
36.Dt NEWFS 8
37.Os
38.Sh NAME
39.Nm newfs ,
40.Nd construct a new UFS1/UFS2 file system
41.Sh SYNOPSIS
42.Nm
43.Op Fl NU
44.Op Fl L Ar volname
45.Op Fl O Ar filesystem-type
46.Op Fl S Ar sector-size
47.Op Fl T Ar disktype
48.Op Fl a Ar maxcontig
49.Op Fl b Ar block-size
50.Op Fl c Ar blocks-per-cylinder-group
51.Op Fl d Ar max-extent-size
52.Op Fl e Ar maxbpg
53.Op Fl f Ar frag-size
54.Op Fl g Ar avgfilesize
55.Op Fl h Ar avgfpdir
56.Op Fl i Ar bytes
57.Op Fl m Ar free-space
58.Op Fl o Ar optimization
59.Op Fl s Ar size
60.Ar special
61.Sh DESCRIPTION
62The
63.Nm
64utility is used to initialize and clear file systems before first use.
65Before running
66.Nm
67the disk must be labeled using
68.Xr disklabel 8 .
69The
70.Nm
71utility builds a file system on the specified special file.
72(We often refer to the
73.Dq special file
74as the
75.Dq disk ,
76although the special file need not be a physical disk.
77In fact, it need not even be special.)
78Typically the defaults are reasonable, however
79.Nm
80has numerous options to allow the defaults to be selectively overridden.
81.Pp
82The following options define the general layout policies:
83.Bl -tag -width indent
84.It Fl L Ar volname
85Add a volume label to the new file system.
86.It Fl N
87Cause the file system parameters to be printed out
88without really creating the file system.
89.It Fl O Ar filesystem-type
90Use 1 to specify that a UFS1 format file system be built;
91use 2 to specify that a UFS2 format file system be built.
92The default is UFS1 format, but will eventually be changed to UFS2.
93.It Fl T Ar disktype
94For backward compatibility.
95.It Fl U
96Enables soft updates on the new file system.
97.It Fl a Ar maxcontig
98Specify the maximum number of contiguous blocks that will be
99laid out before forcing a rotational delay.
100The default value is 16.
101See
102.Xr tunefs 8
103for more details on how to set this option.
104.It Fl b Ar block-size
105The block size of the file system, in bytes.
106It must be a power of 2.
107The
108default size is 16384 bytes, and the smallest allowable size is 4096 bytes.
109The optimal block:fragment ratio is 8:1.
110Other ratios are possible, but are not recommended,
111and may produce poor results.
112.It Fl c Ar blocks-per-cylinder-group
113The number of blocks per cylinder group in a file system.
114The default is to compute the maximum allowed by the other parameters.
115This value is
116dependent on a number of other parameters, in particular the block size
117and the number of bytes per inode.
118.It Fl d Ar max-extent-size
119The file system may choose to store large files using extents.
120This parameter specifies the largest extent size that may be used.
121It is presently limited to its default value which is 16 times
122the file system blocksize.
123.It Fl e Ar maxbpg
124Indicate the maximum number of blocks any single file can
125allocate out of a cylinder group before it is forced to begin
126allocating blocks from another cylinder group.
127The default is about one quarter of the total blocks in a cylinder group.
128See
129.Xr tunefs 8
130for more details on how to set this option.
131.It Fl f Ar frag-size
132The fragment size of the file system in bytes.
133It must be a power of two
134ranging in value between
135.Ar blocksize Ns /8
136and
137.Ar blocksize .
138The default is 2048 bytes.
139.It Fl g Ar avgfilesize
140The expected average file size for the file system.
141.It Fl h Ar avgfpdir
142The expected average number of files per directory on the file system.
143.It Fl i Ar bytes
144Specify the density of inodes in the file system.
145The default is to create an inode for every
146.Pq 4 * Ar frag-size
147bytes of data space.
148If fewer inodes are desired, a larger number should be used;
149to create more inodes a smaller number should be given.
150One inode is required for each distinct file, so this value effectively
151specifies the average file size on the file system.
152.It Fl m Ar free-space
153The percentage of space reserved from normal users; the minimum free
154space threshold.
155The default value used is
156defined by
157.Dv MINFREE
158from
159.Aq Pa ufs/ffs/fs.h ,
160currently 8%.
161See
162.Xr tunefs 8
163for more details on how to set this option.
164.It Fl o Ar optimization
165.Cm ( space
166or
167.Cm time ) .
168The file system can either be instructed to try to minimize the time spent
169allocating blocks, or to try to minimize the space fragmentation on the disk.
170If the value of minfree (see above) is less than 8%,
171the default is to optimize for
172.Cm space ;
173if the value of minfree is greater than or equal to 8%,
174the default is to optimize for
175.Cm time .
176See
177.Xr tunefs 8
178for more details on how to set this option.
179.It Fl s Ar size
180The size of the file system in sectors.
181This value defaults to the size of the
182raw partition specified in
183.Ar special
184(in other words,
185.Nm
186will use the entire partition for the file system).
187.El
188.Pp
189The following options override the standard sizes for the disk geometry.
190Their default values are taken from the disk label.
191Changing these defaults is useful only when using
192.Nm
193to build a file system whose raw image will eventually be used on a
194different type of disk than the one on which it is initially created
195(for example on a write-once disk).
196Note that changing any of these values from their defaults will make
197it impossible for
198.Xr fsck 8
199to find the alternate superblocks if the standard superblock is lost.
200.Bl -tag -width indent
201.It Fl S Ar sector-size
202The size of a sector in bytes (almost never anything but 512).
203.El
204.Sh EXAMPLES
205.Dl newfs /dev/ad3s1a
206.Pp
207Creates a new ufs file system on
208.Pa ad3s1a .
209The
210.Nm
211utility will use a block size of 16384 bytes, a fragment size of 2048 bytes
212and the largest possible number of blocks per cylinders group.
213These values tend to produce better performance for most applications
214than the historical defaults
215(8192 byte block size and 1024 byte fragment size).
216This large fragment size may lead to much wasted space
217on file systems that contain many small files.
218.Sh SEE ALSO
219.Xr fdformat 1 ,
220.Xr disktab 5 ,
221.Xr fs 5 ,
222.Xr camcontrol 8 ,
223.Xr disklabel 8 ,
224.Xr diskpart 8 ,
225.Xr dumpfs 8 ,
226.Xr fsck 8 ,
227.Xr mount 8 ,
228.Xr tunefs 8 ,
229.Xr vinum 8
230.Rs
231.%A M. McKusick
232.%A W. Joy
233.%A S. Leffler
234.%A R. Fabry
235.%T A Fast File System for UNIX
236.%J ACM Transactions on Computer Systems 2
237.%V 3
238.%P pp 181-197
239.%D August 1984
240.%O (reprinted in the BSD System Manager's Manual)
241.Re
242.Sh HISTORY
243The
244.Nm
245utility appeared in
246.Bx 4.2 .
247