System Administration Guide, Volume 1

Creating a Temporary File System (TMPFS)

The Temporary File System (TMPFS) uses local memory for file system reads and writes, which is typically much faster than a UFS file system. Using TMPFS file systems can improve system performance by saving the cost of reading and writing temporary files to a local disk or across the network. Files in TMPFS file systems do not survive across reboots or unmounts.

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

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

How to Create a TMPFS File System

  1. Become superuser.

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

  3. Create a TMPFS file system.

    To set up the system to automatically create a TMPFS file system when it boots, see "Example--Creating a TMPFS File System at Boot Time".


    # mount -F tmpfs [-o size=number ] number swap mount-point
    

    -o size=number

    Specifies the size of the TMPFS file system in Mbytes.  

    mount-point

    The directory on which the TMPFS file system is mounted. 

  4. Look at the output from the mount command to verify that the TMPFS file system has been created.


    # mount -v
    

Example--Creating a TMPFS File System

The following example creates a new directory, /export/reports, and mounts a TMPFS file system at that point, limiting it to 50 Mbytes.


# mkdir /export/reports
# chmod 777 /export/reports
# mount -F tmpfs -o size=50 swap /export/reports

Example--Creating a TMPFS File System at Boot Time

You can set up the system to automatically create a TMPFS file system when it boots by adding an entry to the /etc/vfstab file. The following example shows an entry in the /etc/vfstab file that will create a TMPFS file system on /export/test when the system boots. Since the size=number option is not specified, the size of the TMPFS file system on /export/test is limited only by the available system resources.


swap - /export/test  tmpfs   -  yes  -

For more information the /etc/vfstab file, see "The /etc/vfstab Field Descriptions".