Tuning File Systems in Solaris 8
A situation might arise in which you want to change some of the parameters that were set when you originally created the file system. Perhaps you want to change the minfree value to free some additional disk space on a large disk drive. Using the tunefs command, you can modify the following file system parameters:
- maxcontig
- rotdelay
- maxbpg
- minfree
- optimization
See Table 1 for a description of these options.
CAUTION
tunefs can destroy a file system in seconds. Always back up the entire file system before using tunefs.
The syntax for tunefs is as follows:
tunefs [ -a <maxcontig> ] [ -d <rotdelay> ] [ -e <maxbpg> ] [ -m <minfree> ] [ -o [ <value> ] special/filesystem
The tunefs command is described in Table 1.
Table 1 The tunefs Command
Option |
Description |
-a <maxcontig> |
Specifies the maximum number of contiguous blocks that are laid out before forcing a rotational delay (see the -d option). The default value is 1 because most device drivers require an interrupt per disk transfer. For device drivers that can chain several buffers into a single transfer, set this to the maximum chain length. |
-d <rotdelay> |
Specifies the expected time (in milliseconds) to service a transfer completion interrupt and to initiate a new transfer on the same disk. It is used to decide how much rotational spacing to place between successive blocks in a file. |
-e <maxbpg> |
Sets the maximum number of blocks that any single file can allocate from a cylinder group before it is forced to begin allocating blocks from another cylinder group. Typically, this value is set to approximately one quarter of the total blocks in a cylinder group. The intent is to prevent any single file from using up all the blocks in a single cylinder group. The effect of this limit is to cause big files to do long seeks more frequently than if they were allowed to allocate all the blocks in a cylinder group before seeking elsewhere. For file systems with exclusively large files, this parameter should be set higher. |
-m <minfree> |
Specifies the percentage of space held back from normal users (the minimum free space threshold). The default value is 10 percent, however, on large file systems, the minfree value is determined automatically. |
-o <value> |
Changes the optimization strategy for the file system. The value is either space or time. Use space to conserve space; use time to organize file layout and minimize access time. Generally, optimize a file system for time unless it is more than 90 percent full. |
<special>/<filesystem> |
Enters either the special device name (such as /dev/rdsk/c0t0d0s6) or the file system name (such as /home). |
The file system must be unmounted before you use tunefs.
To change the minimum free space (minfree) on a file system from 10 percent to 5 percent, type the following:
tunefs -m5 /dev/rdsk/c0t0d0s6 minimum percentage of free space changes from 10% to 5%
The manual page of tunefs recommends that minfree be set at 10 percent, and that if you set the value under that, you lose performance. This means that 10 percent of the disk is unusable. This might not have been too bad in the days when disks were a couple hundred megabytes in size, but on a 9GB disk, you're losing 900MB of disk space. The mention of loss of performance in the manual page is misleading. With such large disk drives, you can afford to have minfree as low as 1 percent. This has been found to be a practical and affordable limit. In addition, performance does not become an issue because locating free blocks even within a 90MB area is efficient. A rule of thumb is to use the default 10 percent minfree value for file systems up to 1GB, and then adjust the minfree value so that your minfree area is no larger than 100MB. As for the performance, applications do not complain about the lower minfree value. The one exception would be the root (/) file system, in which the system administrator can use his judgment to allow more free space just to be conservative, in case root (/) ever becomes 100 percent full.
NOTE
On large file systems, the minfree is automatically determined so that disk space is not wasted. Use the mkfs m command described next if you want to see the actual minfree value that newfs used.
Later, if you want to see what parameters were used when creating a file system, issue the mkfs command:
mkfs -m /dev/rdsk/c0t0d0s6
The system responds with this:
mkfs -F ufs -o nsect=117,ntrack=9,bsize=8192, \fragsize=1024,cgsize=16,free=5,rps=90,nbpi=2062,opt=t, \apc=0,gap=0,nrpos=8,maxcontig=15 /dev/rdsk/c0t0d0s6 205334The fstyp Command
Another good command to use to view file system parameters is the fstyp command. Use the -v option to obtain a full listing of a file system's parameters:
fstyp -v /dev/rdsk/c0t0d0s6
The system responds with this:
ufs magic 11954 format dynamic time Sat Oct 2 10:11:06 1999 sblkno 16 cblkno 24 iblkno 32 dblkno 528 sbsize 3072 cgsize 2048 cgoffset 64 cgmask 0xfffffff0 ncg 13 size 102667 blocks95994 bsize 8192 shift 13 mask 0xffffe000 fsize 1024 shift 10 mask 0xfffffc00 frag 8 shift 3 fsbtodb 1 minfree 5% maxbpg 2048 optim time maxcontig 15 rotdelay 0ms rps 90 csaddr 528 cssize 1024 shift 9 mask 0xfffffe00 ntrak 9 nsect 117 spc 1053 ncyl 195 cpg 16 bpg 1053 fpg 8424 ipg 3968 nindir 2048 inopb 64 nspf 2 nbfree 11995 ndir 2 nifree 51577 nffree 1 cgrotor 0 fmod 0 ronly 0 fs_reclaim is not set file system state is valid, fsclean is 1 blocks available in each rotational position cylinder number 0: position 0: 0 8 15 22 30 37 44 52 59 position 1: 1 9 16 23 31 38 45 53 60 position 2: 2 10 17 24 39 46 61 position 3: 3 18 25 32 40 47 54 62 position 4: 4 11 19 26 33 41 48 55 63 position 5: 5 12 20 27 34 42 49 56 position 6: 6 13 21 28 35 50 57 64 position 7: 7 14 29 36 43 51 58 65 cylinder number 1: position 0: 66 74 81 88 103 110 117 125 position 1: 67 82 89 96 104 111 118 126 position 2: 68 75 83 90 97 105 112 119 127 position 3: 69 76 84 91 98 106 113 120 position 4: 70 77 85 92 99 114 121 128 position 5: 71 78 93 100 107 115 122 129 position 6: 72 79 86 94 101 108 116 123 130 position 7: 73 80 87 95 102 109 124 131 ... ...
NOTE
It's always a good idea to print the mkfs options used on a file system along with information provided by the prtvtoc command. Put the printout in your system log so that if you ever need to rebuild a file system because of a hard drive failure, you can re-create it exactly as it was before.
About this Article
This article is excerpted from Solaris 8 Training Guide (310-011 and 310-012): System Administrator Certification, by Bill Calkins ( New Riders Publishing, ISBN: 1578702593). Refer to chapter 7, "Solaris File Systems: Advanced Topics" of the book to learn more about the advanced topics of file systems and how to meet the objectives of the Solaris 8 exam.