Contained Within
Find More Documentation
Featured Support Resources
| Scarica il manuale in formato PDF
Setting Up and Maintaining the Cache File System
35
- The Cache File System (CacheFS) is a general purpose file system caching mechanism that improves NFS server performance and scalability by reducing server and network load. Designed as a layered file system, CacheFS provides the ability to cache one file system on another. In an NFS environment, CacheFS increases the client per server ratio, reduces server and network loads and improves performance for clients on slow links, such as Point-to-Point Protocol (PPP).
- This is a list of the step-by-step instructions in this chapter.
-
How CacheFS Works
- You create a cache, using the cfsadmin(1M) command, on the client so that file systems you specify to be mounted in the cache can be accessed by the user locally instead of across the network. Figure 35-1 on page 579 shows the relationship of the components involved in using CacheFS. The back file system is the file system that you specify to be mounted in the cache. Typically, this is an NFS or HSFS (High Sierra File System) file system. When the user attempts to access files that are part of the back file system, those files are placed in the cache. So the cache does not get filled until the user requests access to a file or files. To the user, the initial request to access a file may seem slow, but subsequent uses of the same file will be faster.
-
Note - You can mount only file systems that are shared. See the share(1M)command. Also, there is no performance gain in caching a local UFS disk file system.

Figure 35-1
Setting Up a Cached File System
-
Table 35-1 shows the steps involved to set up a cached file system.
-
Table 35-1 Task Map for Setting Up a Cached File System
- Activity........Description
- For Instructions, Go To
-
Create a Cache
- Use the cfsadmin command to create a cache · How to Create a Cache
-
page 581
-
Mount File
- Mount a file system in a cache by using the
-
· How to Specify a File System page 583
-
Systems in the
-
mount command
-
to be Mounted in a Cache
-
Cache
-
With mount(1M)
- or
-
· How to Mount a File System
page 586
- Cache a file system by editing the
-
in a Cache Editing the
-
/etc/vfstab file
-
/etc/vfstab File
- or
- Cache a file system by using AutoFS
-
· How to Mount a File System
-
page 587
-
in a Cache With AutoFS
· How to Create a Cache
-
-
Become root.
-
Create a cache using the -c option of the cfsadmin(1M) command.
-
# cfsadmin -c cache-directory
|
- In this command,
-
cache-directory....Is the name of the directory where the cache resides. For more information about the cfsadmin command, see the man page.
-
Note - After you have created the cache, do not perform any operations within the cache directory itself. This causes conflicts within the CacheFS software.
Example--Creating a Cache
- The following example creates a cache in the /local/mycache directory by using the default cache parameter values.
-
# cfsadmin -c /local/mycache
#
|
Verification--Creating a Cache
- If you performed the steps in this procedure successfully, you will receive a system prompt after each step, with no system response, as shown in the above example.
Specifying a File System to Be Mounted in the Cache
- You specify file systems to be mounted in the cache so that users can locally access files in the file system you've specified. The files do not actually get placed in the cache until the user accesses the files.
- There are three ways to specify file systems to be cached:
-
- Using the mount(1M) command - you need to use the mount(1M)command every time the system reboots in order to access the same file system.
- Editing the /etc/vfstab file - you only need to do this once. The /etc/vfstab file will remain unaltered after the system reboots.
- Using AutoFS - you only need to do this once. AutoFS maps remain unaltered after the system reboots.
- Choose the method of mounting file systems you are currently familiar with.
-
Note - Caching of the / (root) and /usr file systems is not supported in CacheFS. To cache the / and /usr file systems, you must purchase the Solstice AutoClient product. For more information about the AutoClient product, see the Solstice AutoClient Administration Guide.
· How to Specify a File System to be Mounted in a Cache With mount(1M)
-
-
Become root.
-
Create a mount point.
The mount point allows user access to the file system specified under that mount point. You can create the mount point from anywhere. The CacheFS options used with the mount(1M)command, as shown in the next step, will determine that the mount point you created will be cached in the cache directory you specified.
-
Mount a file system in a cache with the mount(1M) command.
-
# mount -F cachefs -o backfstype=fstype,cachedir=cache-directory[,options] back-filesystem mount-point
|
- In this command,
-
| fstype | Is the file system type of the back file system, for example nfs. |
| cache-directory | Is the name of the directory where the cache resides. This is the same name you specified when you created the cache in "How to Create a Cache" on page 581. |
| options | Specifies other mount options that you can include when mounting a file system in a cache. See mount_cachefs(1M) for a list of CacheFS mount options. |
| back-filesystem | Is the mount point of the back file system to cache. If the back file system is an NFS file system, you must specify the host name of the server from which you are mounting the file system and the name of the file system to cache (separated by a colon), for example, merlin: /usr/openwin |
| mount-point | Is the directory where the file system is mounted. |
Examples--Specifying a File System to be Mounted in a CacheWith mount(1M)
- The following example creates the mount point /docs, and mounts the NFS file system merlin:/docs as a cached file system named /docs in the cache named /local/mycache.
-
# mkdir /docs
# mount -F cachefs -o backfstype=nfs,cachedir=/local/mycache merlin:/docs /docs
|
- The following example makes a CD-ROM (HSFS file system) available as a cached file system named /docs. Because you cannot write to the CD-ROM, the ro argument is specified to make the cached file system read-only. You must specify the backpath argument because Volume Management automatically mounts the CD-ROM when it is inserted. The mount point is in the /cdrom directory and is determined by the name of the CD-ROM. The special device to mount is the same as the value for the backpath argument.
-
# mount -F cachefs -o backfstype=hsfs,cachedir=/local/mycache,ro,backpath=/cdrom/cdrom_name \
/cdrom/cdrom_name /docs
|
- The following example uses the demandconst option to specify consistency checking on demand for the NFS cached file system /docs, whose back file system is merlin:/docs. See "Consistency Checking of Cached File Systems With the Back File System" on page 611 for more information.
-
# mount -F cachefs -o backfstype=nfs,cachedir=/local/mycache,demandconst merlin:/docs /docs
|
Verification--Specifying a File System to be Mounted in a Cache with mount(1M)
- When you mount the file system in the cache using the mount command, you will receive a prompt with no system response if the file system was mounted correctly. Or, to verify that the cache you created was actually mounted, use the cachefsstat(1M)command, as follows:
-
# cachefsstat mount-point
|
- For example:
-
# cachefsstat /docs
/docs
cache hit rate: 100% (0 hits, 0 misses)
consistency checks: 1 (1 pass, 0 fail)
modifies: 0
garbage collection: 0
|
- The mount point is the cached file system you created. For more information about the cachefsstat command, see "How to View Cache Statistics" on page 609.
- If the file system was not mounted in the cache, you will receive an error message similar to the following:
-
# cachefsstat mount-point
cachefsstat: mount-point: not a cachefs mountpoint
|
· How to Mount a File System in a Cache Editing the /etc/vfstab File
-
-
Become root.
-
Using an editor, specify the file systems to be mounted in the
/etc/vfstab file:

- The last line represents the new entry.
-
-
Mount the cached file system using the mount command, as follows:
-
-
or reboot.
- The above example shows the file system /usr/local mounted in the cache directory.
· How to Mount a File System in a Cache With AutoFS
- Enable caching of automounts by specifying the fstype=cachefs mount option in your automount map. Note that CacheFS mount options (for example, backfstype and cachedir) are also specified in the automount map. See automount(1M) the for details on automount maps. Also see the NFS Administration Guide.
-
-
Become root.
-
Using an editor, add the following line to the auto_direct map:
-
/docs -fstype=cachefs,cachedir=/local/mycache,backfstype=nfs merlin:/docs
|
-
-
Using an editor, add the following line to the auto_master map:
-
- The /- entry is a pointer to check the auto_direct map.
-
-
Reboot the system.
Verification--Mounting a File System in a Cache With AutoFS
- To verify that the entry was made correctly, change to the file system you modified, and then list the contents, as follows:
-
# cd filesystem
# ls filesystem
|
- For example:
-
# cd /usr/openwin
# ls
bin demo etc include
lib man server share
|
- For more information about AutoFS and how to edit the maps, refer to the AutoFS chapter of the NFS Administration Guide.
Maintaining the Cache
- After you set up the cache, you can perform the following maintenance tasks on it:
-
- Modify file systems in the cache (by unmounting, deleting, recreating, and remounting the cache)
- Display cache information
- Check cache consistency
- Delete a file system from the cache
- Check cached file system integrity
-
Note - If you are using the /etc/vfstab file to mount file systems, you modify the cache by editing the file systems options in the etc/vfstab file. If you are using AutoFS, you modify the cache by editing the file systems options in the AutoFS maps.
· How to Modify File Systems in a Cache
- For information on how to modify specific options of a file system, refer to the Chapter 34, "Mounting and Unmounting File Systems". When you modify a file system in the cache, you need to delete the cache and then recreate it. You may also need to reboot your machine in single user mode, depending on how your file systems are shared and accessed.
- Following is an example of what this procedure may entail:
Example--Modifying File Systems in a Cache
- In the following example, the cache is deleted, then re-created, and then mounted again with the demandconst option specified for the file system /docs. This example shows the steps including rebooting to single user mode. You may have other commands you prefer to use to accomplish some of the tasks shown in this example.
-
$ su
password:
# halt
.
.
.
ok boot -s
.
.
.
Type Cntrl-d to proceed with normal startup,
(or give root password for system maintenance):
# enter password:
.
.
.
Here is where you may be prompted from system to run fsck on the file system where the cache is located.
# fsck /local
# mount /local
# cfsadmin -d all /local/mycache
# cfsadmin -c /local/mycache
# reboot
.
.
.
login:
password:
# mount -F cachefs -o backfstype=nfs,cachedir=/local/cache1,demandconst merlin:/docs /docs
|
Verification--Modifying File Systems in a Cache
- If you performed the steps in this procedure successfully, you will receive a prompt after each step, with no system output.
- If you did not successfully mount the file system in the cache again, you would get an error message similar to the following:
-
cachefsstat: /doc: not a cachefs mount point
|
· How to Display Information About Cached File Systems
-
-
Become root.
-
Display information about all file systems cached under a specified cache.
-
# cfsadmin -l cache-directory
|
- In this command, cache-directory is the name of the directory where the cache resides.
Example--Displaying Information About Cached File Systems
- The following example shows information about the cache directory named /local/mycache. In this example, the file system /docs is cached in /local/mycache. The last line displays the cached file system.
-
# cfsadmin -l /local/mycache
cfsadmin: list cache FS information
maxblocks 90%
minblocks 0%
threshblocks 85%
maxfiles 90%
minfiles 0%
threshfiles 85%
maxfilesize 3MB
merlin:_docs:_docs
#
|
· How to Specify Consistency Checking on Demand
-
-
Become root.
-
Mount the file system in the cache specifying the demandconst option of the mount(1M) command, as follows:
-
# mount -F cachefs -o backfstype=nfs,cachedir=/local/mycache,demandconst merlin:/docs /docs
|
-
-
To enable consistency checking on a specific cached file system, use the
cfsadmin(1M)</> command with the -s option as follows:
-
- For more information about consistency checking, see "Consistency Checking of Cached File Systems With the Back File System" on page 611.
Verification--Specifying Consistency Checking on Demand
- If you performed the steps in this procedure successfully, you will receive a prompt after each step, with no system output. If the check was not successful, you will receive an error message.
· How to Delete a Cached File System
-
-
Become root.
-
Unmount all the file systems in the cache.
-
- In this command, mount-point specifies the directory where a file system or file systems are mounted.
-
-
Determine the cache ID from the cfsadmin -l output, as follows:
-
# cfsadmin -l cache-directory
cfsadmin: list cache FS information
maxblocks 90%
minblocks 0%
threshblocks 85%
maxfiles 90%
minfiles 0%
threshfiles 85%
maxfilesize 3MB
merlin:_docs:_docs
#
|
-
-
Delete a cached file system from a specified cache.
-
# cfsadmin -d cache-id cache-directory
|
- In this command,
-
cache-id.........Is the name of the cached file system, which is the last line of the output from the cfsadmin -l command. See "How to Display Information About Cached File Systems" for more information. You can delete all the cached file systems in a particular cache by specifying all for cache-id.
- cache-directory......Is the directory where the cache resides.
Examples--Deleting a Cached File System
- The following example unmounts a cached file system and deletes the cached file system from the cache.
-
# umount /usr/openwin
# cfsadmin -d merlin:docs /docs /local/mycache
|
- The following example deletes all the cached file systems in the /local/mycache cache. This also deletes the cache.
-
# cfsadmin -d all /local/mycache
|
Verification--Deleting a Cached File System
- The cache ID of the file system you just deleted should be missing from the output of the following command. Refer to the cfsadmin(1M) manpage for more information about the fields specified in the command output.
-
# cfsadmin -l /local/mycache
cfsadmin: list cache FS information
maxblocks 90%
minblocks 0%
threshblocks 85%
maxfiles 90%
minfiles 0%
threshfiles 85%
maxfilesize 3MB
#
|
· How to Check the Integrity of Cached File Systems
- Use the fsck(1M) command to check the integrity of cached file systems. The CacheFS version of fsck(1M) automatically corrects problems without requiring user interaction. You should not need to run fsck(1M) manually for cached file systems; fsck(1M) is run automatically at boot time or when the file system is mounted. If you want to manually check the integrity, you can use the following procedure.
- See the fsck_cachefs(1M) man page for more information.
-
-
Become root.
-
Check the cached file systems under a specified cache.
-
# fsck -F cachefs [-m] [-o noclean] cache-directory
|
- In this command,
-
| -m | Causes fsck to check the cached file systems without making any repairs. |
| -o noclean | Forces a check on the cached file systems only. Does not make any repairs. |
| cache-directory | The name of the directory where the cache resides. |
Example--Checking the Integrity of Cached File Systems
- The following example checks the cached file systems that are part of the /local/mycache cache.
-
# fsck -F cachefs /local/mycache
|
Verification--Checking the Integrity of Cached File Systems
- If you performed this procedure successfully, you will receive a prompt back with no system output. If the check was not successful, you will receive an error message.
|
|