System Administration Guide

Creating a Temporary File System (TMPFS)

The most common use for a TMPFS is the /tmp directory. By default, the /tmp directory for the Solaris system software is a TMPFS, and an entry is provided for it in the default /etc/vfstab file. Also, files in TMPFS directories do not survive across reboots or unmounts.

If you create multiple temporary file systems, be aware that they all use the same system resources. Files created under one TMPFS directory use up the space available for any other TMPFS, unless you limit TMPFS sizes using the -o option of the mount command.

How to Create a Temporary File System

  1. Become superuser.

  2. If necessary, create the directory where you want to mount the TMPFS and set permissions and ownership as necessary.

  3. Create a temporary file system.


    # mount -F tmpfs swap mount-point
    

    -F tmpfs swap

    A TMPFS file system. 

    mount-point

    The directory where the TMPFS file system is mounted. 

  4. To verify that a temporary file system called /visitors has been created and mounted in the /usr/tmp directory, use the mount command.

    $ mount
                            .
                            .
                            .
    /visitors on /usr/tmp on Wed May 28 15:27:16 1997
    $ ls /usr/tmp
    NTa0006h    ps_data      visitors

Example--Creating a Temporary File System

This example creates a new directory, /export/reports, and mounts a temporary file system at that point.

# mkdir /export/reports
# chmod 777 /export/reports
# mount -F tmpfs swap /export/reports

See the tmpfs(7FS) man page for more information.

How to Preserve a Temporary File System

You can preserve a TMPFS across reboots or unmounts by adding an entry to the /etc/vfstab file. Edit the file to add an entry like this, separating each field with a tab:


swap - mount-point  tmpfs   -  yes  -

mount-point

The default mount point directory. 


Caution - Caution -

Files in the TMPFS are not preserved; only the file system itself.


For more information about editing the /etc/vfstab file, see Chapter 28, Mounting and Unmounting File Systems (Tasks).