System Administration Guide, Volume 1

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.

The table below describes three ways to mount cached file systems:

To Mount A Cached File System By ... 

You Need To Do This ... 

Using the mount(1M) command

Every time the system reboots in order to access the same file system. 

Editing the /etc/vfstab file

Only once. The /etc/vfstab file remains unchanged after the system reboots.

Using AutoFS 

Only once. AutoFS maps remain unchanged after the system reboots.  

Choose the method of mounting file systems that best suits your environment.


Note -

Caching of the root (/) and /usr file systems is not supported in CacheFS. To cache the root (/) and /usr file systems, you must purchase the Solstice AutoClient product. For more information about the AutoClient product, see the Solstice AutoClient 2.1 Administration Guide.


How to Specify a File System to Be Mounted in a Cache With mount

  1. Become superuser.

  2. 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 command, as shown in the next step, will determine that the mount point you created will be cached in the cache directory you specified.

  3. Mount a file system in a cache with the mount command.


    # mount -F cachefs -o backfstype=fstype,cachedir=cache-directory[, options]
    back-filesystem mount-point
    

    fstype

    Indicates the file system type of the back file system (can be either NFS or HSFS).

    cache-directory

    Indicates 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".

    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

    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

    Indicates the directory where the file system is mounted. 

  4. Verify that the cache you created was actually mounted by using 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 "CacheFS Statistics".

    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

Examples--Specifying a File System to be Mounted in a Cache With mount

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 option 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 command.


# 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" for more information.


# mount -F cachefs -o backfstype=nfs,cachedir=/local/mycache,demandconst merlin:/docs /docs

How to Mount a File System in a Cache by Editing the /etc/vfstab File

  1. Become superuser.

  2. Using an editor, specify the file systems to be mounted in the /etc/vfstab file:


    #device     device             mount  FS    fsck  mount   mount
    #to mount   to fsck            point  type  pass  at boot options
    #
    /dev/dsk/devicename /dev/rdsk/devicename /mount-point cachefs  2    yes  -

    This line represents the new entry.

  3. Mount the cached file system using the mount command, as follows:


    # mount /mount-point
    

    or reboot.

Example--Mounting a File System in a Cache by Editing the /etc/vfstab File

The following example shows the /etc/vfstab entry for the cache file system.


 
#device           device             mount      FS    fsck  mount   mount
#to mount         to fsck            point      type  pass  at boot options
#
/dev/dsk/c0t1d0s0 /dev/rdsk/c0t1d0s0 /usr/local cachefs  2   yes     -

The /usr/local directory is mounted in the cache directory.


# mount /usr/local

How to Mount a File System in a Cache With AutoFS

You can mount a file system in a cache with AutoFS 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) for details on automount maps. Also see System Administration Guide, Volume 3.

  1. Become superuser.

  2. Using an editor, add the following line to the auto_direct map:


    /mount-point -fstype=cachefs,cachedir=/directory,backfstype=nfs 
    server:/file-system
    
  3. Using an editor, add the following line to the auto_master map:


    /-

    The /- entry is a pointer to check the auto_direct map.

  4. Reboot the system.

  5. Verify that the entry was made correctly by changing to the file system you mounted in the cache, and then list the contents, as follows:


    # cd filesystem
    # ls filesystem
    

For more information about AutoFS and how to edit the maps, refer to the AutoFS chapter of the System Administration Guide, Volume 3.

Example--Mounting a File System in a Cache With AutoFS

The following auto_master entry automatically mounts the cache file system in the /docs directory.


/docs	 -fstype=cachefs,cachedir=/local/mycache,backfstype=nfs 
merlin:/docs