Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

System Administration Guide: Devices and File Systems
Previous Next

Creating and Mounting a CacheFS File System (Task Map)

Use the procedures in this task map to create and mount a CacheFS file system.

Task

Description

For Instructions

1. Share the file system to be cached.

Verify that the file system you want to cache is shared.

share(1M)

2. Create the cache.

Use the cfsadmin command to create the cache.

How to Create the Cache

3. Mount a file system in the cache.

Mount a file system in a cache by using one of the following methods:

Mount a CacheFS file system by using the mount command.

How to Mount a CacheFS File System (mount)

Mount a CacheFS file system by editing the /etc/vfstab file.

How to Mount a CacheFS File System (/etc/vfstab)

Mount a cached file system by using AutoFS.

How to Mount a CacheFS File System (AutoFS)

How to Create the Cache

  1. Become superuser on the client system.
  2. Create the cache.
    # cfsadmin -c /cache-directory

    where cache-directory indicates the name of the directory where the cache resides.

    For more information, see cfsadmin(1M).


    Note - After you have created the cache, do not perform any operations within the cache directory itself. Doing so could cause conflicts within the CacheFS software.


Example 20-1 Creating the Cache

The following example shows how to create a cache in the /local/mycache directory by using the default cache parameter values.

# mkdir /local
# cfsadmin -c /local/mycache

Mounting a File System in the Cache

You specify a file system to be mounted in the cache so that users can locally access files in that file system. The files do not actually get placed in the cache until the user accesses the files.

The following table describes three ways to mount a CacheFS file system.

Mount Type for CacheFS File System

Frequency of CacheFS Mount Type

Using the mount 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.

You can mount only file systems that are shared. For information on sharing file systems, see share(1M).


Note - The caching of the root (/) and /usr file systems is not supported in a CacheFS file system.


How to Mount a CacheFS File System (mount)

  1. Become superuser on the client system.
  2. Create the mount point, if necessary.
    # mkdir /mount-point

    You can create the mount point from anywhere, but it must be a UFS file system. The CacheFS options used with the mount command, as shown in the next step, determine that the mount point you create is cached in the cache directory you specify.

  3. Mount a file system in the cache.
    # 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, which can be either NFS or HSFS.

    /cache-directory

    Indicates the name of the UFS directory where the cache resides. This name is the same name you specified when you created the cache in How to Create the Cache.

    options

    Specifies other mount options that you can include when you mount a file system in a cache. For a list of CacheFS mount options, see mount_cachefs(1M).

    /back-filesystem

    Specifies 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: /data/abc.

    /mount-point

    Indicates the directory where the file system is mounted.

  4. Verify that the cache you created was actually mounted.
    # cachefsstat /mount-point

    The /mount-point is the CacheFS file system that you created.

    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

    If the file system was not mounted in the cache, an error message similar to the following is displayed:

    # cachefsstat /mount-point
    cachefsstat: mount-point: not a cachefs mountpoint

    For more information about the cachefsstat command, see Collecting CacheFS Statistics.

Example 20-2 Mounting a CacheFS File System (mount)

The following example shows how to mount the NFS file system merlin:/docs as a CacheFS 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 shows how to make a Solaris 9 SPARCTM CD (HSFS file system) available as a CacheFS file system named /cfssrc. Because you cannot write to the CD, the ro argument is specified to make the CacheFS file system read-only. This example assumes that the removable media services are not running.

# mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /sol9
# mount -F cachefs -o backfstype=hsfs,cachedir=/cfs/cache,ro,noconst,
backpath=/sol9 /dev/dsk/c0t6d0s0 /cfssrc
# ls /cfssrc
Copyright  Solaris_9

The following example shows how to mount a Solaris 9 SPARC CD as a CacheFS file system with vold running.

# mount -F cachefs -o backfstype=hsfs,cachedir=/cfs/cache,ro,noconst,
backpath=/cdrom/sol_9_sparc/s0 /vol/dev/dsk/c0t2d0/sol_9_sparc/s0 /cfssrc

The following example shows how to mount a CD as a CacheFS file system with vold running.

# mount -F cachefs -o backfstype=hsfs,cachedir=/cfs/cache,ro,noconst,
backpath=/cdrom/epson /vol/dev/dsk/c0t2d0/epson /drvrs

The following example uses the demandconst option to specify consistency checking on demand for the NFS CacheFS file system /docs, whose back file system is merlin:/docs. For more information, see Consistency Checking of a CacheFS File System.

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

How to Mount a CacheFS File System (/etc/vfstab)

  1. Become superuser on the client system.
  2. Using an editor, specify the file systems to be mounted in the /etc/vfstab file.

    See the example that follows.

    For more information on the /etc/vfstab file, see Field Descriptions for the /etc/vfstab File.

  3. Mount the CacheFS file system.
    # mount /mount-point

    Or, reboot the system.

Example 20-3 Mounting a CacheFS File System (/etc/vfstab)

The following example shows the /etc/vfstab entry for the /data/abc directory from the remote system starbug that is mounted in the cached directory, /opt/cache.

 
#device           device             mount      FS     fsck  mount   mount
#to mount         to fsck            point      type   pass  at boot options
#
starbug:/data/abc /local/abc         /opt/cache cachefs 7    yes     local-access,bg,
nosuid,demandconst,backfstype=nfs,cachedir=/opt/cache

How to Mount a CacheFS File System (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 the CacheFS mount options, for example, backfstype and cachedir, are also specified in the automount map.

For details on automount maps, see Task Overview for Autofs Administration in System Administration Guide: Network Services or automount(1M).

  1. Become superuser on the client system.
  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.
    # cd /filesystem
    # ls
Example 20-4 Mounting a CacheFS File System (AutoFS)

The following auto_direct entry automatically mounts the CacheFS file system in the /docs directory.

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

 
 
  Published under the terms fo the Public Documentation License Version 1.01. Design by Interspire