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