Initial import from FreeBSD RELENG_4:
[games.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 .\" 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: src/sbin/newfs/newfs.8,v 1.26.2.15 2003/05/13 12:16:08 joerg Exp $
34 .\"
35 .Dd May 13, 2003
36 .Dt NEWFS 8
37 .Os
38 .Sh NAME
39 .Nm newfs ,
40 .Nm mount_mfs
41 .Nd construct a new file system
42 .Sh SYNOPSIS
43 .Nm
44 .Op Fl NOU
45 .Op Fl S Ar sector-size
46 .Op Fl T Ar disktype
47 .Op Fl a Ar maxcontig
48 .Op Fl b Ar block-size
49 .Op Fl c Ar cylinders
50 .Op Fl d Ar rotdelay
51 .Op Fl e Ar maxbpg
52 .Op Fl f Ar frag-size
53 .Op Fl g Ar avgfilesize
54 .Op Fl h Ar avfpdir
55 .Op Fl i Ar bytes
56 .Op Fl k Ar skew
57 .Op Fl l Ar interleave
58 .Op Fl m Ar free space
59 .Op Fl n Ar rotational positions
60 .Op Fl o Ar optimization
61 .Op Fl p Ar sectors
62 .Op Fl r Ar revolutions
63 .Op Fl s Ar size
64 .Op Fl t Ar tracks
65 .Op Fl u Ar sectors
66 .Op Fl v
67 .Op Fl x Ar sectors
68 .Ar special
69 .Nm mount_mfs
70 .Op Fl NU
71 .Op Fl F Ar file
72 .Op Fl T Ar disktype
73 .Op Fl a Ar maxcontig
74 .Op Fl b Ar block-size
75 .Op Fl c Ar cylinders
76 .Op Fl d Ar rotdelay
77 .Op Fl e Ar maxbpg
78 .Op Fl f Ar frag-size
79 .Op Fl i Ar bytes
80 .Op Fl m Ar free space
81 .Op Fl n Ar rotational positions
82 .Op Fl o Ar options
83 .Op Fl s Ar size
84 .Op Fl v
85 .Ar special node
86 .Sh DESCRIPTION
87 .Nm Newfs
88 is used to initialize and clear filesystems before first use.
89 Before running
90 .Nm
91 or
92 .Nm mount_mfs ,
93 the disk must be labeled using
94 .Xr disklabel 8 .
95 .Nm Newfs
96 builds a file system on the specified special file.
97 (We often refer to the
98 .Dq special file
99 as the
100 .Dq disk ,
101 although the special file need not be a physical disk.
102 In fact, it need not even be special.)
103 Typically the defaults are reasonable, however
104 .Nm
105 has numerous options to allow the defaults to be selectively overridden.
106 .Pp
107 .Nm Mount_mfs
108 is used to build a file system in virtual memory and then mount it
109 on a specified node.
110 .Nm Mount_mfs
111 exits and the contents of the file system are lost
112 when the file system is unmounted.
113 If
114 .Nm mount_mfs
115 is sent a signal while running,
116 for example during system shutdown,
117 it will attempt to unmount its
118 corresponding file system.
119 The parameters to
120 .Nm mount_mfs
121 are the same as those to
122 .Nm .
123 If the
124 .Fl T
125 flag is specified (see below), the special file is unused.
126 Otherwise, it is only used to read the disk label which provides
127 a set of configuration parameters for the memory based file system.
128 The special file is typically that of the primary swap area,
129 since that is where the file system will be backed up when
130 free memory gets low and the memory supporting
131 the file system has to be paged.
132 .Pp
133 The following options define the general layout policies:
134 .Bl -tag -width indent
135 .It Fl T Ar disktype
136 For backward compatibility and for
137 .Nm mount_mfs .
138 .It Fl F Ar file
139 .Nm Mount_mfs
140 will use this file for the image of the filesystem.  When
141 .Nm mount_mfs
142 exits, this file will be left behind.
143 .It Fl N
144 Cause the file system parameters to be printed out
145 without really creating the file system.
146 .It Fl O
147 Create a
148 .Bx 4.3
149 format filesystem.
150 This options is primarily used to build root filesystems
151 that can be understood by older boot ROMs.
152 .It Fl T
153 Use information for the specified disk from
154 .Pa /etc/disktab
155 instead of trying to get the information from a disklabel.
156 .It Fl U
157 Enables soft updates on the new filesystem.
158 .It Fl a Ar maxcontig
159 Specify the maximum number of contiguous blocks that will be
160 laid out before forcing a rotational delay (see the
161 .Fl d
162 option).
163 The default value is 1.
164 See
165 .Xr tunefs 8
166 for more details on how to set this option.
167 .It Fl b Ar block-size
168 The block size of the file system, in bytes.  It must be a power of 2.  The
169 default size is 16384 bytes, and the smallest allowable size is 4096 bytes.
170 The optimal block:fragment ratio is 8:1.
171 Other ratios are possible, but are not recommended,
172 and may produce unpredictable results.
173 .It Fl c Ar #cylinders/group
174 The number of cylinders per cylinder group in a file system.  The default
175 is to compute the maximum allowed by the other parameters.  This value is
176 dependent on a number of other parameters, in particular the block size
177 and the number of bytes per inode.
178 .It Fl d Ar rotdelay
179 This parameter once specified the minimum time in milliseconds required to
180 initiate another disk transfer on the same cylinder.  It was used in determining
181 the rotationally optimal layout for disk blocks within a file.  Modern disks
182 with read/write-behind achieve higher performance with this feature disabled, so
183 this value should be left at the default value of 0 milliseconds.  See
184 .Xr tunefs 8
185 for more details on how to set this option.
186 .It Fl e Ar maxbpg
187 Indicate the maximum number of blocks any single file can
188 allocate out of a cylinder group before it is forced to begin
189 allocating blocks from another cylinder group.
190 The default is about one quarter of the total blocks in a cylinder group.
191 See
192 .Xr tunefs 8
193 for more details on how to set this option.
194 .It Fl f Ar frag-size
195 The fragment size of the file system in bytes.  It must be a power of two
196 ranging in value between
197 .Ar blocksize Ns /8
198 and
199 .Ar blocksize .
200 The default is 2048 bytes.
201 .It Fl g Ar avgfilesize
202 The expected average file size for the file system.
203 .It Fl h Ar avgfpdir
204 The expected average number of files per directory on the file system.
205 .It Fl i Ar number of bytes per inode
206 Specify the density of inodes in the file system.
207 The default is to create an inode for every
208 .Pq 4 * Ar frag-size
209 bytes of data space.
210 If fewer inodes are desired, a larger number should be used;
211 to create more inodes a smaller number should be given.
212 One inode is required for each distinct file, so this value effectively
213 specifies the average file size on the file system.
214 .It Fl m Ar free space \&%
215 The percentage of space reserved from normal users; the minimum free
216 space threshold.
217 The default value used is
218 defined by
219 .Dv MINFREE
220 from
221 .Aq Pa ufs/ffs/fs.h ,
222 currently 8%.
223 See
224 .Xr tunefs 8
225 for more details on how to set this option.
226 .It Fl n Ar number of distinguished rotational positions
227 UFS has the ability to keep track of the availability of blocks at different
228 rotational positions, so that it could lay out the data to be picked up with
229 minimum rotational latency.  This parameter specifies the default number of
230 rotational positions to distinguish.
231 .Pp
232 Nowadays this value should be set to 1 (which essentially disables the
233 rotational position table) because modern drives with read-ahead and
234 write-behind do better without the rotational position table.
235 .It Fl o Ar optimization\ preference
236 .Pq Ar space No or Ar time .
237 The file system can either be instructed to try to minimize the time spent
238 allocating blocks, or to try to minimize the space fragmentation on the disk.
239 If the value of minfree (see above) is less than 8%,
240 the default is to optimize for
241 .Ar space ;
242 if the value of minfree is greater than or equal to 8%,
243 the default is to optimize for
244 .Ar time .
245 See
246 .Xr tunefs 8
247 for more details on how to set this option.
248 .It Fl s Ar size
249 The size of the file system in sectors.  This value defaults to the size of the
250 raw partition specified in
251 .Ar special
252 (in other words,
253 .Nm
254 will use the entire partition for the file system).
255 .It Fl v
256 Specify that the disk does not contain any partitions, and that
257 .Nm
258 should build a file system on the whole disk.
259 This option is useful for synthetic disks such as
260 .Nm vinum .
261 .El
262 .Pp
263 The following options override the standard sizes for the disk geometry.
264 Their default values are taken from the disk label.
265 Changing these defaults is useful only when using
266 .Nm
267 to build a file system whose raw image will eventually be used on a
268 different type of disk than the one on which it is initially created
269 (for example on a write-once disk).
270 Note that changing any of these values from their defaults will make
271 it impossible for
272 .Xr fsck 8
273 to find the alternate superblocks if the standard superblock is lost.
274 .Bl -tag -width indent
275 .It Fl S Ar sector-size
276 The size of a sector in bytes (almost never anything but 512).
277 .It Fl k Ar sector \&0 skew , per track
278 Used to describe perturbations in the media format to compensate for
279 a slow controller.
280 Track skew is the offset of sector 0 on track N relative to sector 0
281 on track N-1 on the same cylinder.
282 This option is of historical importance only; modern controllers are always fast
283 enough to handle operations back-to-back.
284 .It Fl l Ar hardware sector interleave
285 Used to describe perturbations in the media format to compensate for
286 a slow controller.
287 Interleave is physical sector interleave on each track,
288 specified as the denominator of the ratio:
289 .Dl sectors read/sectors passed over
290 Thus an interleave of 1/1 implies contiguous layout, while 1/2 implies
291 logical sector 0 is separated by one sector from logical sector 1.
292 This option is of historical importance only; the physical sector layout of
293 modern disks is not visible from outside.
294 .It Fl p Ar spare sectors per track
295 Spare sectors (bad sector replacements) are physical sectors that occupy
296 space at the end of each track.
297 They are not counted as part of the sectors/track
298 .Pq Fl u
299 since they are not available to the file system for data allocation.
300 This option is of historical importance only.  Modern disks perform their own
301 bad sector allocation.
302 .It Fl r Ar revolutions/minute
303 The speed of the disk in revolutions per minute.  This value is no longer of
304 interest, since all the parameters which depend on it are usually disabled.
305 .It Fl t Ar #tracks/cylinder
306 The number of tracks/cylinder available for data allocation by the file
307 system.
308 The default is 1.
309 If zero is specified, the value from the disklabel will be used.
310 .It Fl u Ar sectors/track
311 The number of sectors per track available for data allocation by the file
312 system.
313 The default is 4096.
314 If zero is specified, the value from the disklabel will be used.
315 This does not include sectors reserved at the end of each track for bad
316 block replacement (see the
317 .Fl p
318 option).
319 .It Fl x Ar spare sectors per cylinder
320 Spare sectors (bad sector replacements) are physical sectors that occupy
321 space at the end of the last track in the cylinder.
322 They are deducted from the sectors/track
323 .Pq Fl u
324 of the last track of each cylinder since they are not available to the file
325 system for data allocation.
326 This option is of historical importance only.  Modern disks perform their own
327 bad sector allocation.
328 .El
329 .Pp
330 The options to the
331 .Nm mount_mfs
332 command are as described for the
333 .Nm
334 command, except for the
335 .Fl o
336 option.
337 .Pp
338 That option is as follows:
339 .Bl -tag -width indent
340 .It Fl o
341 Options are specified with a
342 .Fl o
343 flag followed by a comma separated string of options.
344 See the
345 .Xr mount 8
346 man page for possible options and their meanings.
347 .El
348 .Sh EXAMPLES
349 .Dl newfs /dev/ad3s1a
350 .Pp
351 Creates a new ufs file system on
352 .Pa ad3s1a .
353 .Nm
354 will use a block size of 16384 bytes, a fragment size of 2048 bytes
355 and the largest possible number of cylinders per group.
356 These values tend to produce better performance for most applications
357 than the historical defaults
358 (8192 byte block size and 1024 byte fragment size).
359 This large fragment size
360 may lead to large amounts of wasted space
361 on filesystems that contain a large number of small files.
362 .Pp
363 .Dl mount_mfs -s 131072 -o nosuid,nodev,nosymfollow /dev/da0s1b /tmp
364 .Pp
365 Mount a 64 MB large memory file system on
366 .Pa /tmp ,
367 with
368 .Xr mount 8
369 options
370 .Ar nosuid ,
371 .Ar nodev ,
372 and
373 .Ar nosymfollow .
374 .Sh SEE ALSO
375 .Xr fdformat 1 ,
376 .Xr disktab 5 ,
377 .Xr fs 5 ,
378 .Xr camcontrol 8 ,
379 .Xr disklabel 8 ,
380 .Xr diskpart 8 ,
381 .Xr dumpfs 8 ,
382 .Xr fsck 8 ,
383 .Xr mount 8 ,
384 .Xr tunefs 8 ,
385 .Xr vinum 8
386 .Rs
387 .%A M. McKusick
388 .%A W. Joy
389 .%A S. Leffler
390 .%A R. Fabry
391 .%T A Fast File System for UNIX
392 .%J ACM Transactions on Computer Systems 2
393 .%V 3
394 .%P pp 181-197
395 .%D August 1984
396 .%O (reprinted in the BSD System Manager's Manual)
397 .Re
398 .Sh HISTORY
399 The
400 .Nm
401 command appeared in
402 .Bx 4.2 .