]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/newfs/newfs.8
OpenSSL: Merge OpenSSL 1.1.1s
[FreeBSD/FreeBSD.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. 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 October 21, 2022
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 EJNUjlnt
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 k Ar held-for-metadata-blocks
54 .Op Fl m Ar free-space
55 .Op Fl o Ar optimization
56 .Op Fl p Ar partition
57 .Op Fl r Ar reserved
58 .Op Fl s Ar size
59 .Ar special
60 .Sh DESCRIPTION
61 The
62 .Nm
63 utility is used to initialize and clear file systems before first use.
64 The
65 .Nm
66 utility builds a file system on the specified special file.
67 (We often refer to the
68 .Dq special file
69 as the
70 .Dq disk ,
71 although the special file need not be a physical disk.
72 In fact, it need not even be special.)
73 Typically the defaults are reasonable, however
74 .Nm
75 has numerous options to allow the defaults to be selectively overridden.
76 .Pp
77 The following options define the general layout policies:
78 .Bl -tag -width indent
79 .It Fl E
80 Erase the content of the disk before making the filesystem.
81 The reserved area in front of the superblock (for bootcode) will not be erased.
82 Erasing is only relevant to flash-memory or thinly provisioned devices.
83 Erasing may take a long time.
84 If the device does not support BIO_DELETE, the command will fail.
85 .It Fl J
86 Enable journaling on the new file system via gjournal.
87 See
88 .Xr gjournal 8
89 for details.
90 .It Fl L Ar volname
91 Add a volume label to the new file system.
92 Legal characters are alphanumerics, dashes, and underscores.
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 .\" If changing the default block size and it causes the default
115 .\" fragment size to change, be sure to update the location of
116 .\" the first backup superblock on the fsck_ffs.8 manual page.
117 The
118 default size is 32768 bytes, and the smallest allowable size is 4096 bytes.
119 The optimal block:fragment ratio is 8:1.
120 Other ratios are possible, but are not recommended,
121 and may produce poor results.
122 .It Fl c Ar blocks-per-cylinder-group
123 The number of blocks per cylinder group in a file system.
124 The default is to compute the maximum allowed by the other parameters.
125 This value is
126 dependent on a number of other parameters, in particular the block size
127 and the number of bytes per inode.
128 .It Fl d Ar max-extent-size
129 The file system may choose to store large files using extents.
130 This parameter specifies the largest extent size that may be used.
131 The default value is the file system blocksize.
132 It is presently limited to a maximum value of 16 times the
133 file system blocksize and a minimum value of the file system blocksize.
134 .It Fl e Ar maxbpg
135 Indicate the maximum number of blocks any single file can
136 allocate out of a cylinder group before it is forced to begin
137 allocating blocks from another cylinder group.
138 The default is about one quarter of the total blocks in a cylinder group.
139 See
140 .Xr tunefs 8
141 for more details on how to set this option.
142 .It Fl f Ar frag-size
143 The fragment size of the file system in bytes.
144 It must be a power of two
145 ranging in value between
146 .Ar blocksize Ns /8
147 and
148 .Ar blocksize .
149 .\" If changing the default fragment size or it changes because of a
150 .\" change to the default block size, be sure to update the location
151 .\" of the first backup superblock on the fsck_ffs.8 manual page.
152 The default is 4096 bytes.
153 .It Fl g Ar avgfilesize
154 The expected average file size for the file system.
155 .It Fl h Ar avgfpdir
156 The expected average number of files per directory on the file system.
157 .It Fl i Ar bytes
158 Specify the density of inodes in the file system.
159 The default is to create an inode for every
160 .Pq 2 * Ar frag-size
161 bytes of data space.
162 If fewer inodes are desired, a larger number should be used;
163 to create more inodes a smaller number should be given.
164 One inode is required for each distinct file, so this value effectively
165 specifies the average file size on the file system.
166 .It Fl j
167 Enable soft updates journaling on the new file system.
168 This flag is implemented by running the
169 .Xr tunefs 8
170 utility found in the user's
171 .Dv $PATH .
172 .Pp
173 Enabling journaling reduces the time spent by
174 .Xr fsck_ffs 8
175 cleaning up a filesystem after a crash to a few seconds from minutes to hours.
176 Without journaling, the time to recover after a crash is a function
177 of the number of files in the filesystem and the size of the filesystem.
178 With journaling, the time to recover after a crash is a function of the
179 amount of activity in the filesystem in the minute before the crash.
180 Journaled recovery time is usually only a few seconds and never
181 exceeds a minute.
182 .Pp
183 The drawback to using journaling is that the writes to its log adds
184 an extra write load to the media containing the filesystem.
185 Thus a write-intensive workload will have reduced throughput on a
186 filesystem running with journaling.
187 .Pp
188 Like all journaling filesystems, the journal recovery will only fix
189 issues known to the journal.
190 Specifically if a media error occurs,
191 the journal will not know about it and hence will not fix it.
192 Thus when using journaling, it is still necessary to run a full fsck
193 every few months or after a filesystem panic to check for and fix
194 any errors brought on by media failure.
195 A full fsck can be done by running a background fsck on a live
196 filesystem or by running with the
197 .Fl f
198 flag on an unmounted filesystem.
199 When running
200 .Xr fsck_ffs 8
201 in background on a live filesystem the filesystem performance
202 will be about half of normal during the time that the background
203 .Xr fsck_ffs 8
204 is running.
205 Running a full fsck on a UFS filesystem is the equivalent of
206 running a scrub on a ZFS filesystem.
207 .Pp
208 Presently it is not possible to take a snapshot on a UFS filesystem
209 running with journaled soft updates.
210 Thus it is not possible to reliably dump mounted filesystems or
211 to run background fsck on filesystems enabled for journaling.
212 .It Fl k Ar held-for-metadata-blocks
213 Set the amount of space to be held for metadata blocks in each cylinder group.
214 When set, the file system preference routines will try to save
215 the specified amount of space immediately following the inode blocks
216 in each cylinder group for use by metadata blocks.
217 Clustering the metadata blocks speeds up random file access
218 and decreases the running time of
219 .Xr fsck 8 .
220 By default
221 .Nm
222 sets it to half of the space reserved to minfree.
223 .It Fl l
224 Enable multilabel MAC on the new file system.
225 .It Fl m Ar free-space
226 The percentage of space reserved from normal users; the minimum free
227 space threshold.
228 The default value used is
229 defined by
230 .Dv MINFREE
231 from
232 .In ufs/ffs/fs.h ,
233 currently 8%.
234 See
235 .Xr tunefs 8
236 for more details on how to set this option.
237 .It Fl n
238 Do not create a
239 .Pa .snap
240 directory on the new file system.
241 The resulting file system will not support snapshot generation, so
242 .Xr dump 8
243 in live mode and background
244 .Xr fsck 8
245 will not function properly.
246 The traditional
247 .Xr fsck 8
248 and offline
249 .Xr dump 8
250 will work on the file system.
251 This option is intended primarily for memory or vnode-backed file systems that
252 do not require
253 .Xr dump 8
254 or
255 .Xr fsck 8
256 support.
257 .It Fl o Ar optimization
258 .Cm ( space
259 or
260 .Cm time ) .
261 The file system can either be instructed to try to minimize the time spent
262 allocating blocks, or to try to minimize the space fragmentation on the disk.
263 If the value of minfree (see above) is less than 8%,
264 the default is to optimize for
265 .Cm space ;
266 if the value of minfree is greater than or equal to 8%,
267 the default is to optimize for
268 .Cm time .
269 See
270 .Xr tunefs 8
271 for more details on how to set this option.
272 .It Fl p Ar partition
273 The partition name (a..h) you want to use in case the underlying image
274 is a file, so you do not have access to individual partitions through the
275 filesystem.
276 Can also be used with a device, e.g.,
277 .Nm
278 .Fl p Ar f
279 .Ar /dev/da1s3
280 is equivalent to
281 .Nm
282 .Ar /dev/da1s3f .
283 .It Fl r Ar reserved
284 The size, in sectors, of reserved space
285 at the end of the partition specified in
286 .Ar special .
287 This space will not be occupied by the file system;
288 it can be used by other consumers such as
289 .Xr geom 4 .
290 Defaults to 0.
291 .It Fl s Ar size
292 The size of the file system in sectors.
293 This value defaults to the size of the
294 raw partition specified in
295 .Ar special
296 less the
297 .Ar reserved
298 space at its end (see
299 .Fl r ) .
300 A
301 .Ar size
302 of 0 can also be used to choose the default value.
303 A valid
304 .Ar size
305 value cannot be larger than the default one,
306 which means that the file system cannot extend into the reserved space.
307 .It Fl t
308 Turn on the TRIM enable flag.
309 If enabled, and if the underlying device supports the BIO_DELETE
310 command, the file system will send a delete request to the underlying
311 device for each freed block.
312 The trim enable flag is typically set for flash-memory devices to
313 reduce write amplification which reduces wear on write-limited
314 flash-memory and often improves long-term performance.
315 Thinly provisioned storage also benefits by returning unused blocks to
316 the global pool.
317 .El
318 .Pp
319 The following options override the standard sizes for the disk geometry.
320 Their default values are taken from the disk label.
321 Changing these defaults is useful only when using
322 .Nm
323 to build a file system whose raw image will eventually be used on a
324 different type of disk than the one on which it is initially created
325 (for example on a write-once disk).
326 Note that changing any of these values from their defaults will make
327 it impossible for
328 .Xr fsck 8
329 to find the alternate superblocks if the standard superblock is lost.
330 .Bl -tag -width indent
331 .It Fl S Ar sector-size
332 The size of a sector in bytes (almost never anything but 512).
333 .El
334 .Sh NOTES ON THE NAMING
335 .Dq newfs
336 is a common name prefix for utilities creating filesystems, with the suffix
337 indicating the type of the filesystem, for instance
338 .Xr newfs_msdos 8 .
339 The
340 .Nm
341 utility is a special case which predates that convention.
342 .Sh EXAMPLES
343 .Dl newfs /dev/ada3s1a
344 .Pp
345 Creates a new ufs file system on
346 .Pa ada3s1a .
347 The
348 .Nm
349 utility will use a block size of 32768 bytes, a fragment size of 4096 bytes
350 and the largest possible number of blocks per cylinders group.
351 These values tend to produce better performance for most applications
352 than the historical defaults
353 (8192 byte block size and 1024 byte fragment size).
354 This large fragment size may lead to much wasted space
355 on file systems that contain many small files.
356 .Sh SEE ALSO
357 .Xr fdformat 8 ,
358 .Xr geom 4 ,
359 .Xr disktab 5 ,
360 .Xr fs 5 ,
361 .Xr camcontrol 8 ,
362 .Xr dump 8 ,
363 .Xr dumpfs 8 ,
364 .Xr fsck 8 ,
365 .Xr gjournal 8 ,
366 .Xr gpart 8 ,
367 .Xr growfs 8 ,
368 .Xr gvinum 8 ,
369 .Xr makefs 8 ,
370 .Xr mount 8 ,
371 .Xr newfs_msdos 8 ,
372 .Xr tunefs 8
373 .Rs
374 .%A M. McKusick
375 .%A W. Joy
376 .%A S. Leffler
377 .%A R. Fabry
378 .%T A Fast File System for UNIX
379 .%J ACM Transactions on Computer Systems 2
380 .%V 3
381 .%P pp 181-197
382 .%D August 1984
383 .%O (reprinted in the BSD System Manager's Manual)
384 .Re
385 .Sh HISTORY
386 The
387 .Nm
388 utility appeared in
389 .Bx 4.2 .