System Administration Guide, Volume 1

Maintaining the Cache

After you set up the cache, you can perform the following maintenance tasks on it:


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 Chapter 36, Mounting and Unmounting File Systems (Tasks). When you modify a file system in the cache, you need to delete the cache and then recreate it. You might also need to reboot your machine in single user mode, depending on how your file systems are shared and accessed.

The following example shows some of the steps involved in this procedure.

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 might have other commands you prefer to use to accomplish some of the tasks shown in this example.


# shutdown -g30 -y
.
.
.
Type Cntrl-d to proceed with normal startup,
(or give root password for system maintenance):
# enter password:
.
.
.
Here is where you might 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
# init 6
.
.
.
console login:
password:
# mount -F cachefs -o backfstype=nfs,cachedir=/local/cache1, demandconst merlin:/docs /docs 
#

If you did not successfully remount the file system in the cache, the system displays an error message similar to the following:


cachefsstat: /doc: not a cachefs mount point

How to Display Information About Cached File Systems

  1. Become superuser.

  2. Display information about all file systems cached under a specified cache.


    # cfsadmin -l cache-directory
    

    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 name of 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

  1. Become superuser.

  2. Mount the file system in the cache specifying the demandconst option of the mount command, as follows:


    # mount -F cachefs -o backfstype=nfs,cachedir=/directory,demandconst 
    server:/file-system /mount-point
    

  3. To initiate consistency checking on a specific cached file system, use the cfsadmin -s command as follows:


    # cfsadmin -s /mount-point
    

    For more information about consistency checking, see "Consistency Checking of Cached File Systems With the Back File System".

How to Delete a Cached File System

  1. Become superuser.

  2. Unmount the cached file system.


    # umount mount-point
    

    mount-point specifies the cached file system that you want to delete.

  3. 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
    cache-ID
    #
  4. Delete a cached file system from a specified cache.


    # cfsadmin -d cache-id cache-directory
    

    cache-id

    Indicates the name of the cached file system, which is the last line of the cfsadmin -l output. 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

    Specifies the directory where the cache resides. 

  5. Verify that the file system has been deleted.

    The cache ID of the file system you just deleted should be missing from the output of the following command. Refer to cfsadmin(1M) for more information about the fields specified in the command output.


    # cfsadmin -l cache-directory
    cfsadmin: list cache FS information
       maxblocks     90%
       minblocks      0%
       threshblocks  85%
       maxfiles      90%
       minfiles       0%
       threshfiles   85%
       maxfilesize    3MB
    # 

Examples--Deleting a Cached File System

The following example unmounts a cached file system and deletes the cached file system from the cache.


# umount /docs
# 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

How to Check the Integrity of Cached File Systems

Use the fsck command to check the integrity of cached file systems. The CacheFS version of fsck automatically corrects problems without requiring user interaction. You should not need to run fsck manually for cached file systems; fsck 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 fsck_cachefs(1M) for more information.

  1. Become superuser.

  2. Check the cached file systems under a specified cache.


    # fsck -F cachefs [-m -o noclean] cache-directory
    

    -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

    Indicates 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
#