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