xref: /freebsd/sbin/tunefs/tunefs.8 (revision b197d4b893974c9eb4d7b38704c6d5c486235d6f)
1.\" Copyright (c) 1983, 1991, 1993
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.\"     @(#)tunefs.8	8.2 (Berkeley) 12/11/93
29.\" $FreeBSD$
30.\"
31.Dd August 16, 2022
32.Dt TUNEFS 8
33.Os
34.Sh NAME
35.Nm tunefs
36.Nd tune up an existing UFS file system
37.Sh SYNOPSIS
38.Nm
39.Op Fl A
40.Op Fl a Cm enable | disable
41.Op Fl e Ar maxbpg
42.Op Fl f Ar avgfilesize
43.Op Fl j Cm enable | disable
44.Op Fl J Cm enable | disable
45.Op Fl k Ar held-for-metadata-blocks
46.Op Fl L Ar volname
47.Op Fl l Cm enable | disable
48.Op Fl m Ar minfree
49.Op Fl N Cm enable | disable
50.Op Fl n Cm enable | disable
51.Op Fl o Cm space | time
52.Op Fl p
53.Op Fl s Ar avgfpdir
54.Op Fl S Ar size
55.Op Fl t Cm enable | disable
56.Ar special | filesystem
57.Sh DESCRIPTION
58The
59.Nm
60utility is designed to change the dynamic parameters of a UFS file system
61which affect the layout policies.
62The
63.Nm
64utility cannot be run on an active file system.
65To change an active file system,
66it must be downgraded to read-only or unmounted.
67.Pp
68The parameters which are to be changed are indicated by the flags
69given below:
70.Bl -tag -width indent
71.It Fl A
72The file system has several backups of the super-block.
73Specifying
74this option will cause all backups to be modified as well as the
75primary super-block.
76This is potentially dangerous - use with caution.
77.It Fl a Cm enable | disable
78Turn on/off the administrative POSIX.1e ACL enable flag.
79.It Fl e Ar maxbpg
80Indicate the maximum number of blocks any single file can
81allocate out of a cylinder group before it is forced to begin
82allocating blocks from another cylinder group.
83Typically this value is set to about one quarter of the total blocks
84in a cylinder group.
85The intent is to prevent any single file from using up all the
86blocks in a single cylinder group,
87thus degrading access times for all files subsequently allocated
88in that cylinder group.
89The effect of this limit is to cause big files to do long seeks
90more frequently than if they were allowed to allocate all the blocks
91in a cylinder group before seeking elsewhere.
92For file systems with exclusively large files,
93this parameter should be set higher.
94.It Fl f Ar avgfilesize
95Specify the expected average file size.
96.It Fl j Cm enable | disable
97Turn on/off soft updates journaling.
98.Pp
99Enabling journaling reduces the time spent by
100.Xr fsck_ffs 8
101cleaning up a filesystem after a crash to a few seconds from minutes to hours.
102Without journaling, the time to recover after a crash is a function
103of the number of files in the filesystem and the size of the filesystem.
104With journaling, the time to recover after a crash is a function of the
105amount of activity in the filesystem in the minute before the crash.
106Journaled recovery time is usually only a few seconds and never
107exceeds a minute.
108.Pp
109The drawback to using journaling is that the writes to its log adds
110an extra write load to the media containing the filesystem.
111Thus a write-intensive workload will have reduced throughput on a
112filesystem running with journaling.
113.Pp
114Like all journaling filesystems, the journal recovery will only fix
115issues known to the journal.
116Specifically if a media error occurs,
117the journal will not know about it and hence will not fix it.
118Thus when using journaling, it is still necessary to run a full fsck
119every few months or after a filesystem panic to check for and fix
120any errors brought on by media failure.
121A full fsck can be done by running a background fsck on a live
122filesystem or by running with the
123.Fl f
124flag on an unmounted filesystem.
125When running
126.Xr fsck_ffs 8
127in background on a live filesystem the filesystem performance
128will be about half of normal during the time that the background
129.Xr fsck_ffs 8
130is running.
131Running a full fsck on a UFS filesystem is the equivalent of
132running a scrub on a ZFS filesystem.
133.Pp
134Presently it is not possible to take a snapshot on a UFS filesystem
135running with journaled soft updates.
136Thus it is not possible to reliably dump mounted filesystems or
137to run background fsck on filesystems enabled for journaling.
138.It Fl J Cm enable | disable
139Turn on/off gjournal flag.
140.It Fl k Ar held-for-metadata-blocks
141Set the amount of space to be held for metadata blocks.
142When set, the file system preference routines will try to save
143the specified amount of space immediately following the inode blocks
144in each cylinder group for use by metadata blocks.
145Clustering the metadata blocks speeds up random file access
146and decreases the running time of
147.Xr fsck 8 .
148While this option can be set at any time,
149it is most effective if set before any data is loaded into the file system.
150By default
151.Xr newfs 8
152sets it to half of the space reserved to minfree.
153.It Fl L Ar volname
154Add/modify an optional file system volume label.
155Legal characters are alphanumerics, dashes, and underscores.
156.It Fl l Cm enable | disable
157Turn on/off MAC multilabel flag.
158.It Fl m Ar minfree
159Specify the percentage of space held back
160from normal users; the minimum free space threshold.
161The default value used is 8%.
162Note that lowering the threshold can adversely affect performance:
163.Bl -bullet
164.It
165Settings of 5% and less force space optimization to
166always be used which will greatly increase the overhead for file
167writes.
168.It
169The file system's ability to avoid fragmentation will be reduced
170when the total free space, including the reserve, drops below 15%.
171As free space approaches zero, throughput can degrade by up to a
172factor of three over the performance obtained at a 10% threshold.
173.El
174.Pp
175If the value is raised above the current usage level,
176users will be unable to allocate files until enough files have
177been deleted to get under the higher threshold.
178.It Fl N Cm enable | disable
179Turn on/off the administrative NFSv4 ACL enable flag.
180.It Fl n Cm enable | disable
181Turn on/off soft updates.
182.It Fl o Cm space | time
183The file system can either try to minimize the time spent
184allocating blocks, or it can attempt to minimize the space
185fragmentation on the disk.
186Optimization for space has much
187higher overhead for file writes.
188The kernel normally changes the preference automatically as
189the percent fragmentation changes on the file system.
190.It Fl p
191Show a summary of what the current tunable settings
192are on the selected file system.
193More detailed information can be
194obtained from the
195.Xr dumpfs 8
196utility.
197.It Fl s Ar avgfpdir
198Specify the expected number of files per directory.
199.It Fl S Ar size
200Specify the softdep journal size in bytes.
201The minimum is 4M.
202.It Fl t Cm enable | disable
203Turn on/off the TRIM enable flag.
204If enabled, and if the underlying device supports the BIO_DELETE
205command, the file system will send a delete request to the underlying
206device for each freed block.
207The trim enable flag is typically set when the underlying device
208uses flash-memory as the device can use the delete command to
209pre-zero or at least avoid copying blocks that have been deleted.
210.Pp
211Note that this does not trim blocks that are already free.
212See the
213.Xr fsck_ffs 8
214.Fl E
215flag.
216.El
217.Pp
218At least one of these flags is required.
219.Sh FILES
220.Bl -tag -width ".Pa /etc/fstab"
221.It Pa /etc/fstab
222read this to determine the device file for a
223specified mount point.
224.El
225.Sh SEE ALSO
226.Xr fs 5 ,
227.Xr dumpfs 8 ,
228.Xr gjournal 8 ,
229.Xr growfs 8 ,
230.Xr newfs 8
231.Rs
232.%A M. McKusick
233.%A W. Joy
234.%A S. Leffler
235.%A R. Fabry
236.%T "A Fast File System for UNIX"
237.%J "ACM Transactions on Computer Systems 2"
238.%N 3
239.%P pp 181-197
240.%D August 1984
241.%O "(reprinted in the BSD System Manager's Manual, SMM:5)"
242.Re
243.Sh HISTORY
244The
245.Nm
246utility appeared in
247.Bx 4.2 .
248.Sh BUGS
249This utility does not work on active file systems.
250To change the root file system, the system must be rebooted
251after the file system is tuned.
252.\" Take this out and a Unix Daemon will dog your steps from now until
253.\" the time_t's wrap around.
254.Pp
255You can tune a file system, but you cannot tune a fish.
256