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