System Administration Guide, Volume I

Chapter 26 File Systems (Overview)

This is a list of the overview information in this chapter.

What's New in File Systems?

The Solaris 7 release provides two new file system features: UFS logging and a new mount option to ignore access time updates on files.

UFS logging is the process of storing transactions (changes that make up a complete UFS operation) into a log before the transactions are applied to the UFS file system. Once a transaction is stored, the transaction can be applied to the file system later.

UFS logging provides two advantages. It prevents file systems from becoming inconsistent, therefore eliminating the need to run the fsck command. And, because fsck can be bypassed, UFS logging reduces the time required to reboot a system if it crashes, or after an unclean halt.

UFS logging is not enabled by default. To enable UFS logging, you must specify the -o logging option with the mount command when mounting the file system. Also, the fsdb command has been updated with new debugging commands to support UFS logging.

To ignore access time updates on files, you can specify the -o noatime option when mounting a UFS file system. This option reduces disk activity on file systems where access times are unimportant (for example, a Usenet news spool). See the mount_ufs(1M) man page for more details.

Introduction

A file system is a structure of directories used to organize and store files. The term "file system" is used to describe:

Usually, you can tell from context which meaning is intended.

The Solaris operating environment uses the virtual file system (VFS) architecture, which provides a standard interface for different file system types. The VFS architecture enables the kernel to handle basic operations, such as reading, writing, and listing files, without requiring the user or program to know about the underlying file system type.

Administering file systems is one of your most important system administration tasks. Read this chapter for file system background and planning information. Refer to other chapters in the System Administration Guide for instructions about the following tasks:

Types of File Systems

The Solaris operating environment supports three types of file systems:

To identify the type for a particular file system, see "Determining a File System's Type".

Disk-based File Systems

Disk-based file systems are stored on physical media such as hard disks, CD-ROMs, and diskettes. Disk-based file systems can be written in different formats. The available formats are:

Each type of disk-based file system is customarily associated with a particular media device:

These associations are not, however, restrictive. For example, CD-ROMs and diskettes can have UFS file systems created on them.

Network-based File Systems

Network-based file systems can be accessed over the network. Typically, network-based file systems reside on one system, typically a server, and are accessed by other systems across the network. The Network File System (NFS) is the only available network-based file system.

NFS is the distributed file system service for Solaris. With NFS, you can administer distributed resources (files or directories) by exporting them from a server and mounting them on individual clients. See "The Network File System (NFS)" for more information.

Virtual File Systems

Virtual file systems are memory-based file systems that provide access to special kernel information and facilities. Most virtual file systems do not use file system disk space. However, the Cache File System (CacheFS) uses a file system on the disk to contain the cache, and some virtual file systems, such as the Temporary File System (TMPFS), use the swap space on a disk.

The Cache File System

The Cache File System (CacheFSTM) can be used to improve performance of remote file systems or slow devices such as CD-ROM drives. When a file system is cached, the data read from the remote file system or CD-ROM is stored in a cache on the local system. See Chapter 29, The Cache File System (Tasks) for detailed information on setting up and administering CacheFS File Systems.

The Temporary File System

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. For example, temporary files are created when you compile a program, and the operating system generates a lot of disk or network activity while manipulating these files. Using TMPFS to hold these temporary files may significantly speed up their creation, manipulation, and deletion.

Files in TMPFS file systems are not permanent. They are deleted when the file system is unmounted and when the system is shut down or rebooted.

TMPFS is the default file system type for the /tmp directory in the Solaris operating environment. You can copy or move files into or out of the /tmp directory, just as you would in a UFS file system.

The TMPFS file system uses swap space as a temporary backing store. If a system with a TMPFS file system does not have adequate swap space, two problems can occur:

See Chapter 27, Creating File Systems (Tasks) for information about creating TMPFS file systems. See Chapter 30, Configuring Additional Swap Space (Tasks) for information about increasing swap space.

The Loopback File System

The Loopback File System (LOFS) lets you create a new virtual file system, so you can access files by using an alternative path name. For example, you can create a loopback mount of root / on /tmp/newroot, which will make the entire file system hierarchy look like it is duplicated under /tmp/newroot, including any file systems mounted from NFS servers. All files will be accessible either with a path name starting from (/), or with a path name starting from /tmp/newroot.

See Chapter 27, Creating File Systems (Tasks) for information on how to create LOFS file systems.

The Process File System

The Process File System (PROCFS) resides in memory. It contains a list of active processes, by process number, in the /proc directory. Information in the /proc directory is used by commands like ps. Debuggers and other development tools can also access the address space of the processes by using file system calls.


Caution - Caution -

Do not delete the files in the /proc directory. Deleting processes from the /proc directory is not the best way to kill them. Remember, /proc files do not use disk space, so there is little reason to delete files from this directory.


The /proc directory does not require system administration.

Additional Virtual File Systems

These additional types of virtual file systems are listed for your information. They do not require administration.

File System Administration Commands

Most file system administration commands have both a generic and a file system-specific component. You should use the generic commands whenever possible, which call the file system-specific component. Table 26-1 lists the generic file system administrative commands, which are located in the /usr/sbin directory.

Table 26-1 Generic File System Administrative Commands

Command 

Description 

clri(1M)

Clears inodes 

df(1M)

Reports the number of free disk blocks and files 

ff(1M)

Lists file names and statistics for a file system 

fsck(1M)

Checks the integrity of a file system and repairs any damage found 

fsdb(1M)

Debugs the file system 

fstyp(1M)

Determines the file system type 

labelit(1M)

Lists or provides labels for file systems when copied to tape (for use by the volcopy command only)

mkfs(1M)

Makes a new file system 

mount(1M)

Mounts local and remote file systems 

mountall(1M)

Mounts all file systems specified in the virtual file system table (/etc/vfstab)

ncheck(1M)

Generates a list of path names with their i-numbers 

umount(1M)

Unmounts local and remote file systems 

umountall(1M)

Unmounts all file systems specified in a virtual file system table (/etc/vfstab)

volcopy(1M)

Makes an image copy of a file system 

How the File System Commands Determine the File System Type

The generic file system commands determine the file system type by following this sequence:

  1. From the -F option, if supplied.

  2. By matching a special device with an entry in /etc/vfstab file (if special is supplied). For example, fsck first looks for a match against the fsck device field; if no match is found, it then checks the special device field.

  3. By using the default specified in /etc/default/fs for local file systems and in /etc/dfs/fstypes for remote file systems.

Manual Pages for Generic and Specific Commands

Both the generic and specific commands have manual pages in the man Pages(1M): System Administration Commands. The specific manual page is a continuation of the generic manual page. To look at a specific manual page, append an underscore and the file system type abbreviation to the generic command name. For example, to see the specific manual page for mounting a UFS file system, type man mount_ufs(1M).

The Default Solaris File Systems

The Solaris file system is hierarchical, starting with the root directory (/) and continuing downwards through a number of directories. The Solaris installation process enables you to install a default set of directories and uses a set of conventions to group similar types of files together. Table 26-2 provides a summary of the default Solaris file systems, and shows the type of each file system.

The root (/) and /usr file systems are both needed to run a system. Some of the most basic commands from the /usr file system (like mount) are included in the root (/) file system so that they are available when the system boots or is in single-user mode and /usr is not mounted. See Chapter 32, File System Reference for more detailed information on the default directories for the root (/) and /usr file systems.

Table 26-2 The Default Solaris File Systems

File System or Directory 

File System Type 

Description 

root (/)

UFS 

The top of the hierarchical file tree. The root directory contains the directories and files critical for system operation, such as the kernel, the device drivers, and the programs used to boot the system. It also contains the mount point directories where local and remote file systems can be attached to the file tree. 

/usr

UFS 

System files and directories that can be shared with other users. Files that run only on certain types of systems are in the /usr directory (for example, SPARC executables). Files (such as man pages) that can be used on all types of systems are in /usr/share.

/export/home or /home

NFS, UFS 

The mount point for users home directories, which store users work files. By default /home is an automounted file system. On standalone systems, /home may be a UFS file system on a local disk slice.

/var

UFS 

System files and directories that are likely to change or grow over the life of the local system. These include system logs, vi and ex backup files, and uucp files.

/opt

NFS, UFS 

Mount point for optional, third-party software. On some systems, /opt may be a UFS file system on a local disk slice.

/tmp

TMPFS 

Temporary files, cleared each time the system is booted or the /tmp file system is unmounted.

/proc

PROCFS 

A list of active processes, by number. 

Swap Space

The Solaris operating environment uses some disk slices for temporary storage rather than for file systems. These slices are called swap slices, or swap space. Swap space is used as virtual memory storage areas when the system does not have enough physical memory to handle current processes.

Since many applications rely on swap space, it is important to know how to plan for, monitor, and add more swap space when needed. For an overview about swap space and instructions for adding swap space, see Chapter 30, Configuring Additional Swap Space (Tasks).

The UFS File System

UFS is the default disk-based file system in Solaris operating environment. Most of the time, when you administer a disk-based file system, you will be administering UFS file systems. UFS provides the following features:

See Chapter 32, File System Reference for detailed information about the UFS file system.

Parts of a UFS File System

When you create a UFS file system, the disk slice is divided into cylinder groups, which are made up of one or more consecutive disk cylinders. The cylinder groups are then further divided into addressable blocks to control and organize the structure of the files within the cylinder group. Each type of block has a specific function in the file system.

A UFS file system has these four types of blocks:

See "The Structure of UFS File System Cylinder Groups" for more detailed information about each type of block.

If you want to customize a file system using arguments with the newfs command or the mkfs command, see Chapter 32, File System Reference for information about altering these parameters.

UFS Logging

UFS logging is the process of storing transactions (changes that make up a complete UFS operation) in a log before the transactions are applied to the UFS file system. Once a transaction is stored, the transaction can be applied to the file system later.

At reboot, the system discards incomplete transactions, but applies the transactions for completed operations. The file system remains consistent because only completed transactions are ever applied. This is true even when a system crashes, which normally interrupts system calls and introduces inconsistencies into a UFS file system.

UFS logging provides two advantages. It prevents file systems from becoming inconsistent, therefore eliminating the need to run fsck. And, because fsck can be bypassed, UFS logging reduces the time required to reboot a system if it crashes, or after an unclean halt (see "What fsck Checks and Tries to Repair" for details on unclean halts). UFS logging can especially reduce the boot time on systems that have large file systems, which usually take a long time to read and verify with fsck.

The log created by UFS logging is continually flushed as it fills up. The log is totally flushed when the file system is unmounted or as a result of the lockfs -f command.

UFS logging is not enabled by default. To enable UFS logging, you must specify the -o logging option with the mount command when mounting the file system. The log is allocated from free blocks on the file system, and it is sized approximately 1 Mbyte per 1 Gbyte of file system, up to a maximum of 64 Mbytes. Logging can be enabled on any UFS, including the root (/) file system. Also, the fsdb command has been updated with new debugging commands to support UFS logging.

Planning UFS File Systems

When laying out file systems, you need to consider possible conflicting demands. Here are some suggestions:

See Chapter 27, Creating File Systems (Tasks) for information on default file system parameters as well as procedures for creating new UFS file systems.

Mounting and Unmounting File Systems

Before you can access the files on a file system, you need to mount the file system. Mounting a file system attaches that file system to a directory (mount point) and makes it available to the system. The root (/) file system is always mounted. Any other file system can be connected or disconnected from the root (/) file system.

When you mount a file system, any files or directories in the mount point directory are unavailable as long as the file system is mounted. These files are not permanently affected by the mounting process, and they become available again when the file system is unmounted. However, mount directories are typically empty, because you usually do not want to obscure existing files.

For example, Figure 26-1 shows a local file system, starting with a root (/) file system and subdirectories sbin, etc, and opt.

Figure 26-1 Sample root (/) File System

Graphic

Now, say you wanted to access a local file system from the /opt file system that contains a set of unbundled products.

First, you must create a directory to use as a mount point for the file system you want to mount, for example, /opt/unbundled. Once the mount point is created, you can mount the file system (by using the mount command), which makes all of the files and directories in /opt/unbundled available, as shown in Figure 26-2. See Chapter 28, Mounting and Unmounting File Systems (Tasks) for detailed instructions on how to perform these tasks.

Figure 26-2 Mounting a File System

Graphic

Unmounting a file system removes it from the file system mount point. Some file system administration tasks cannot be performed on mounted file systems. You should unmount a file system when:

It is a good idea to unmount a file system before doing a complete backup of it. See Chapter 33, Backing Up and Restoring File Systems (Overview) for more information about doing backups.


Note -

File systems are automatically unmounted as part of the system shutdown process.


The Mounted File System Table

Whenever you mount or unmount a file system, the /etc/mnttab (mount table) file is modified with the list of currently mounted file systems. You can display the contents of the mount table using the cat or more commands, but you cannot edit it. Here is an example of a /etc/mnttab file:


$ more /etc/mnttab
/dev/dsk/c0t3d0s0    /       ufs     rw,suid,dev=800018,largefiles 863804345
/dev/dsk/c0t3d0s6    /usr    ufs     rw,suid,dev=80001e,largefiles 863804345
/proc   /proc   proc    rw,suid,dev=2900000     863804345
fd      /dev/fd fd      rw,suid,dev=29c0000     863804345
/dev/dsk/c0t3d0s3   /export ufs     suid,rw,largefiles,dev=80001b  863804347
/dev/dsk/c0t3d0s7   /export/home ufs suid,rw,largefiles,dev=80001f 863804348
/dev/dsk/c0t3d0s4   /export/swap ufs suid,rw,largefiles,dev=80001c 863804348
/dev/dsk/c0t3d0s5   /opt  ufs   suid,rw,largefiles,dev=80001d  863804347
swap    /tmp    tmpfs   dev=2a80000     863804347
$

The Virtual File System Table

It would be a very time-consuming task to manually mount file systems every time you wanted to access them. To fix this, the virtual file system table (the /etc/vstab file) was created to maintain a list of file systems and how to mount them. The /etc/vfstab file provides two important features: you can specify file systems to automatically mount when the system boots, and you can mount file systems by using only the mount point name, because the /etc/vfstab file contains the mapping between the mount point and the actual device slice name.

A default /etc/vfstab file is created when you install a system depending on the selections you make when installing system software; however, you can edit the /etc/vfstab file on a system whenever you want. To add an entry, the main information you need to specify is the device where the file system resides, the name of the mount point, the type of the file system, whether you want it to boot automatically when the system boots (by using the mountall command), and any mount options.

The following is an example of an /etc/vfstab file. Comment lines begin with #. This example shows an /etc/vfstab file for a system with two disks (c0t0d0 and c0t3d0).


Example 26-1 Sample /etc/vfstab File


$ more /etc/vfstab
#device         device          mount           FS      fsck   mount  mount
#to mount       to fsck         point           type    pass   at boot options
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 /          ufs     1       no      -
/proc           -               /proc           proc    -       no      -
/dev/dsk/c0t0d0s1 -                -            swap    -       no      -
swap            -               /tmp            tmpfs   -       yes     -
/dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6 /usr       ufs     2       no      -
/dev/dsk/c0t3d0s7 /dev/rdsk/c0t3d0s7 /test      ufs     2       yes     -
$

In Example 26-1, the last entry specifies that a UFS file system on the /dev/dsk/c0t2d0s7 slice will be automatically mounted on the /test mount point when the system boots. Note that, for root (/) and /usr, the mount at boot field value is specified as no, because these file systems are mounted by the kernel as part of the boot sequence before the mountall command is run.

See Chapter 28, Mounting and Unmounting File Systems (Tasks) for descriptions of each of the /etc/vfstab fields and information on how to edit and use the file.

The Network File System (NFS)

NFS is a distributed file system service that can be used to share resources (files or directories) from one system, typically a server, with other systems across the network. For example, you might want to share third-party applications or source files with users on other systems.

NFS makes the actual physical location of the resource irrelevant to the user. Instead of placing copies of commonly used files on every system, NFS allows you to place one copy on one system's disk and let all other systems access it across the network. Under NFS, remote files are virtually indistinguishable from local ones.

A system becomes an NFS server if it has resources to share or export over the network. A server keeps a list of currently exported resources and their access restrictions (such as read/write or read-only).

When you share a resource, you make it available for mounting by remote systems.

You can share a resource in these ways:

See Chapter 28, Mounting and Unmounting File Systems (Tasks) for information on how to share resources. See the NFS Administration Guide for a complete description of NFS.

AutoFS

You can mount NFS file systems by using a client-side service called automounting, or AutoFS, which enables a system to automatically mount and unmount NFS file systems whenever you access them. The file system remains mounted as long as you remain in the file system and are using a file. If the file system is not accessed for a certain period of time, it is automatically unmounted.

AutoFS provides the following features:

The AutoFS service is initialized by automount, which is run automatically when a system is booted. The automount daemon, automountd, runs continuously and is responsible for the mounting and unmounting of the NFS file systems on an as-needed basis. By default, the Solaris operating environment automounts /home.

AutoFS works with file systems specified in the name service. This information can be maintained in NIS, NIS+, or local /etc files. With AutoFS, you can specify several multiple servers to provide the same file system. This way, if one of the servers is down, AutoFS can try to mount from another machine. You can specify which servers are preferred for each resource in the maps by assigning each server a weighting factor.

See the NFS Administration Guide for complete information on how to set up and administer AutoFS.

The Cache File System (CacheFS)

If you want to improve the performance and scalability of your NFS-mounted file system, you should use the Cache File System (CacheFS). CacheFS is a general purpose file system caching mechanism that improves NFS server performance and scalability by reducing server and network load.

Designed as a layered file system, CacheFS provides the ability to cache one file system on another. In an NFS environment, CacheFS increases the client per server ratio, reduces server and network loads, and improves performance for clients on slow links, such as Point-to-Point Protocol (PPP). You can also combine CacheFS with the AutoFS service to help boost performance and scaliability.

See Chapter 29, The Cache File System (Tasks) for detailed information about CacheFS.

Deciding How to Mount File Systems

Table 26-3 provides guidelines on mounting file systems based on how you use them.

Table 26-3 Determining How to Mount File Systems

If You Need to Mount ... 

Then You Should Use ... 

Local or remote file systems infrequently 

The mount command entered manually from the command line.

Local file systems frequently 

The /etc/vfstab file, which will mount the file system automatically when the system is booted in multi-user state.

Remote file systems frequently, such as home directories 

  • The /etc/vfstab file, which will automatically mount the file system when the system is booted in multi-user state.

  • AutoFS, which will automatically mount or unmount the file system when you change into (mount) or out of (unmount) the directory.

To enhance performance, you can also cache the remote file systems by using CacheFS. 

You can mount a CD-ROM containing a file system by simply inserting it into the drive (Volume Management will automatically mount it). You can mount a diskette containing a file system by inserting it into the drive and running the volcheck command. See Part IV for more information.

Determining a File System's Type

You can determine a file system's type by using the following:

How to Determine a File System's Type

This procedure works whether the file system is mounted or not.

Determine a file system's type by using the grep command.


$ grep mount-point fs-table

mount-point

Specifies the mount point name of the file system for which you want to know the type. 

fs-table

Specifies the absolute path to the file system table in which to search for the file system's type. If the file system is mounted, fs-table should be /etc/mnttab. If it isn't mounted, fs-table should be /etc/vfstab.

Information for the mount point is displayed.


Note -

If you have the raw device name of a disk slice, you can use the fstyp(1M) command to determine a file system's type (if the disk slice contains a file system).


Example--Determining a File System's Type

The following example uses the /etc/vfstab to determine the type of the /export file system.


$ grep /export /etc/vfstab
/dev/dsk/c0t3d0s6   /dev/rdsk/c0t3d0s6  /export ufs   2       yes    -
$ 

The following example uses the /etc/mnttab file to determine the file system type of the currently mounted diskette (mounted by volume management).


$ grep /floppy /etc/mnttab
/vol/dev/diskette0/unnamed_floppy   /floppy/unnamed_floppy  pcfs    rw,nohidden,
nofoldcase,dev=16c0009      89103376
$