[ Team LiB ] Previous Section Next Section

Making File Systems Available

When you have created a file system, you need to make it available; you do this by mounting it. A mounted file system is attached to the system directory tree at the specified mount point and becomes 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.

You can mount a local file system in the following ways.

  • By creating an entry in the /etc/vfstab (virtual file system table) file. The /etc/vfstab file contains a list of file systems that are automatically mounted when the system is booted in multiuser state. See "The Virtual File System Table (/etc/vfstab)" on page 190 for a description of the /etc/vfstab file.

  • From a command line by using the mount command.

File systems on disk slices must always be mounted on the server system and shared (exported) before other systems can access them. See "Sharing Files from a Server" on page 207 for information about sharing file systems. When file systems are shared from a server, a client can mount them as NFS file systems in any of the following three ways.

  • By adding an entry to the /etc/vfstab file so that the file system is automatically mounted when the system is booted in multiuser state.

  • By using the automount program to automatically mount or unmount the file system when a user changes into (mount) or out of (umount) the automounting directory.

  • By using the mount command at a command line.

Understanding Mounting and Unmounting

File systems can be attached to the hierarchy of directories available on a system. This process is called mounting. To manually mount a file system, you need the following things.

  • To be superuser.

  • A mount point on the local system. The mount point is a directory to which the mounted file system is attached.

  • The resource name of the file system to be mounted (for example, /usr).

As a general rule, local disk slices should always be included in the /etc/vfstab file. Any software from servers, such as CDE, OpenWindows, or manual pages, and home directories from a server can either be included in the /etc/vfstab file or be automounted, depending on the policy at your site.

When you mount a file system, any files or directories that might be present 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 become available again when the file system is unmounted. However, mount directories typically are empty because you usually do not want to obscure existing files.

Using Mount and Unmount File System Commands

Table 48 lists the commands in the /usr/sbin directory that you use to mount and unmount file systems.

Table 48. Commands for Mounting and Unmounting File Systems

Command

Description

mount(1M)

Mount file systems and remote resources.

mountall(1M)

Mount all file systems specified in a file system table.

umount(1M)

Unmount file systems and remote resources.

umountall(1M)

Unmount all file systems specified in a file system table.

The mount command does not mount a read/write file system that has inconsistencies. If you receive an error message from the mount or mountall command, you may need to check the file system.

The umount command does not unmount a file system that is busy. A file system is considered busy if a user is in a directory in the file system or if a program has a file open in that file system.

Table 49 describes the general mount options that you can specify with the -o option of the mount command. If you specify multiple options, separate them with commas (no spaces). For example, -o ro, nosuid.

Table 49. Commands for Mounting and Unmounting File Systems

Option

File System

Description

rw | ro

CacheFS, NFS, PCFS, UFS, S5FS, UDFS

Specify read/write or read-only. If you do not specify this option, the default is read/write.

nosuid

HSFS, NFS, UFS, UDFS

Prevent setuid execution and prevent devices on the file system from being opened. The default is to enable setuid execution and enable devices to be opened.

remount

NFS, UFS, S5FS, UDFS

Remount a file system with different options.

graphics/new.gif f

None

Forcibly unmount a file system. Without this option, umount does not allow a file system to be unmounted if a file on that file system is busy. This option can result in data loss for open files; programs that access files after the file system has been unmounted get an error (IEO).

m

UFS, S5FS

Mount the file system without making an entry in /etc/mnttab.

logging | nologging

 

UFS

Enable or disable UFS logging. See "UFS Logging" on page 202 for more information.

bg | fg

NFS

If the first attempt fails, retry in the background (bg) or in the foreground (fg). The default is fg.

soft | hard

 

NFS

Specify the procedure if the server does not respond. soft indicates that an error is returned. hard indicates that the retry request is continued until the server responds. The default is hard.

intr | nointr

  
 

NFS

Specify whether keyboard interrupts can be used to kill a process hung while waiting for a response on hard-mounted file systems. The default is intr (interrupts allowed).

retry=n

NFS

Retry the mount operations when it fails.

largefiles

 

NFS

A file system mounted using this option may contain files larger than 2 Gbytes, but it is not a requirement. This option is the default.

nolargefiles

 

NFS

Disable the -largefiles mount option to provide backward compatibility with previous file system behavior and enforcing the 2-Gbyte maximum file size limit.

index filename

 

NFS URL

Automatically load a file matching filename if it is found in a directory referenced by an NFS URL.

public

NFS URL

Reset the public file handle to the current directory to enable you to access an NFS URL even if the file system cannot be mounted in the usual way.

size=sz

XMEMFS

Specify the size of the XMEMFS file system. This option is required.

largebsize

XMEMFS

Specify the large memory page size as the file system block size.

UFS Logging

UFS logging, new starting with the Solaris 7 Operating Environment, is the process of storing transactions (the changes that make up a complete UFS operation) in a log file before the transactions are applied to the UFS file system. Once a transaction is stored, the file system can apply the transactions to the file system later, if needed, during a recovery.

UFS logging is not enabled by default. To enable UFS logging, specify the -o logging option with the mount command when mounting a file system.

If you specify logging, then logging is enabled while the file system is mounted. This option prevents file systems from becoming inconsistent, thereby eliminating the need to run fsck. And, because you can bypass fsck, logging reduces the time required to reboot a system after a crash or after an unclean halt. The default behavior is nologging.

The log is allocated from free blocks on the file system and sized at approximately 1 Mbyte per 1 Gbyte of file system up to a maximum of 64 Mbytes. You can enable logging on any UFS file system, including root (/). The log created by UFS logging is continually flushed as it fills up. The log is totally flushed when the file system is unmounted when the lockfs -f command is run.

The fsdb command has been updated with new debugging options to support UFS logging.

Finding the Mounted File Systems

To display a list of mounted file systems, type mount and press Return. All the file systems currently mounted are displayed, as shown in the following example.


oak% mount
/ on /dev/dsk/c0t0d0s0 read/write/setuid on Wed Oct 23 10:08:50 1999

/usr on /dev/dsk/c0t0d0s6 read/write/setuid on Wed Oct 23 10:08:50 1999

/proc on /proc read/write/setuid on Wed Oct 23 10:08:50 1999

/tmp on swap on Wed Oct 23 10:08:52 1999

/usr/openwin on cheers:/export/openwin hard/remote on Wed Oct 23
10:11:08 1999

/home on blowup:(pid136) read only/intr/map=auto.home/indirect on Wed Oct 23
   10:11:10 1999

/vol on blowup:(pid136) read only/intr/map=auto.vol/indirect on Wed Oct 23
   10:11:10 1999

/nse on blowup:(pid136) read only/intr/map=/etc/auto.nse /indirect on Wed Oct
   23 10:11:10 1999
oak%



Mounting All File Systems in the /etc/vfstab File

Use the following steps to mount all file systems in the /etc/vfstab file.

  1. Become superuser.

  2. Type mountall and press Return.

    All the file systems in the local /etc/vfstab file are mounted, as shown in the following example.


oak% su
Password:
# mountall
oak#



Mounting All File Systems of a Specific Type

Use the following steps to mount all file systems of a specific type that are in the /etc/vfstab file. The most common file system types are ufs for local disk slices and nfs for network file systems. See "Types of File Systems" on page 197 for a complete list of file system types.

  1. Become superuser.

  2. Type mountall -F filesystem-type and press Return.

    All the file systems of the type you specify that are in the local /etc/vfstab file are mounted.

The following example mounts all NFS file systems.


oak% su
Password:
# mountall -F nfs
#

Starting with the Solaris 2.6 release, the -largefiles mount option is used as the default for mounting UFS file systems. If you want to prevent users from mounting file systems that contain files larger than 2 Gbytes, you must explicitly use the nolargefiles mount option to disable the default behavior.

Mounting a Single File System (mount)

Use the following steps to mount a single file system that has an entry in the /etc/vfstab file.

  1. Become superuser.

  2. Type mount mount-point and press Return.

    The file system is mounted, as shown in the following example.


oak% su
Password:
# mount /opt
#



Remounting a UFS File System Without Large Files (mount)

After you mount a file system with the default largefiles option to mount and large files have been created, you cannot remount the file system with the nolargefiles option until you remove any large files and run fsck to reset the state to nolargefiles.

The nolargefiles option to mount provides total compatibility with previous file system behavior and enforces the 2-Gbyte maximum file size limit.

Use the following steps to remount a UFS file system without large files.

  1. Become superuser.

  2. Type cd /filesystem and press Return.

  3. Type find. -xdev -size +2147485647c -exec ls -l {} \; and press Return.

  4. Remove any large files listed as the result of the find command.

  5. Type umount / filesystem and press Return.

  6. Type fsck /dev/rdsk/ device-name and press Return.

  7. Type mount -o nolargefiles /dev/rdsk/ device-name and press Return.

    The file system is mounted.

In the following example, the directory /files1 is searched for large files, unmounted, fsck is run, and the directory is mounted again with the nolargefiles option.


oak% su
Password:
# cd /files1
# find. -xdev -size +2000000 -exec ls -l {} \;
# umount /files1
# fsck /dev/rdsk/c0t3dos7 /files1
# mount -o nolargefiles /dev/dsk/c0t3d0s7 /files1
#



Unmounting All Remote File Systems (umountall -F nfs)

Follow these steps to unmount all remote file systems.

  1. Become superuser.

  2. Type umountall -F nfs and press Return.

    All the remote file systems in the local /etc/vfstab file are unmounted, as shown in the following example.


oak% su
Password:
# umountall -F nfs
#

CAUTION. If you unmount all file systems (by using umountall without any arguments), the system may be unusable and you may need to reboot it.


Unmounting Individual File Systems (umount)

You cannot unmount a directory that is being used. If you want to unmount a directory that is being used, all users must close any open files and change out of the directory.

  1. Become superuser.

  2. If necessary, have users change out of the directory you want to unmount.

  3. Type umount mount-point and press Return.

    The file system you specify is unmounted.

In the following example, the mount command is used first to find the mount point for the file system to be unmounted.


oak% mount
/ on /dev/dsk/c0t0d0s0 read/write/setuid on Wed Oct 23 10:08:50 1999

/usr on /dev/dsk/c0t0d0s6 read/write/setuid on Wed Oct 23 10:08:50 1999

/proc on /proc read/write/setuid on Wed Oct 23 10:08:50 1999

/tmp on swap on Wed Oct 23 10:08:52 1999

/usr/openwin on cheers:/export/openwin hard/remote on Wed Oct 23
10:11:08 1999

/home on blowup:(pid136) read only/intr/map=auto.home/indirect on Wed Oct 23
   10:11:10 1999

/vol on blowup:(pid136) read only/intr/map=auto.vol/indirect on Wed Oct 23 10:11:10
   1999

/nse on blowup:(pid136) read only/intr/map=/etc/auto.nse /indirect on Wed Oct 23
10:11:10 1999
[41]oak% su
Password:
# cd /
# umount /home
#




Automounting Directories

You can mount file systems shared through NFS by using a method called automounting. The AutoFS subsystem runs in the background and mounts and unmounts remote directories as they are needed. Whenever a user on a client system running the automounter accesses a remote file or directory available through the automounter, the automounter mounts the file system on the user's system. The remote file system remains mounted as long as the user remains in the directory and has one or more files open. If the remote file system is not accessed for a certain period of time, it is automatically unmounted. The automounter mounts and unmounts file systems as required without any intervention on the part of the user other than changing into or out of a directory.

You can mount some file hierarchies with the automounter, and you can change others by using the /etc/vfstab file and the mount command. A diskless machine must have entries for / (root), /usr, and /usr/kvm in the /etc/vfstab file.

The automounter works with the file systems specified in maps. These maps can be maintained as NIS, NIS+, or local files. The automounter maps can specify several remote locations for a particular file system. This way, if one of the servers is down, the automounter 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. The automounter starts automatically when a system enters run level 3. You can also start it from a command line. (Describing how to set up and administer the automounter is beyond the scope of this book.) By default, the Solaris Operating Environment automounts /home.

Sharing Files from a Server

NFS is a distributed file system that can be used to share files or directories from one system to other systems across a network. Computers that are running different operating systems can also share files. For example, systems running DOS can share files with systems running UNIX.

NFS makes the actual physical location of the file system irrelevant to the user. You can use NFS to enable users to see all the relevant files, regardless of location. Instead of placing copies of commonly used files on every system, NFS enables you to place one copy on one system's disk and let all other systems access it across the network. Under NFS, remote file systems are virtually indistinguishable from local ones.

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

You may want to share resources, such as files, directories, or devices from one system on the network (typically, a server) with other systems. For example, you might want to share third-party applications or source files with users on other systems.

When you share a resource, you make it available for mounting by remote systems. You can share a resource in the following ways.

  • Using the share or shareall command. For the shareall command to run, the /etc/dfs/dfstab file must already exist. The share command can be run without the dfstab file.

  • Adding an entry to the /etc/dfs/dfstab (distributed file system table) file.

The default /etc/dfs/dfstab file shows the syntax and an example of entries.


paperbark% more /etc/dfs/dfstab

#    Place share(1M) commands here for automatic execution
#    on entering init state 3.
#
#    Issue the command '/etc/init.d/nfs.server start' to run the NFS
#    daemon processes and the share commands, after adding the very
#    first entry to this file.
#
#    share [-F fstype] [ -o options] [-d "<text>"] <pathname> [resource]
#       .e.g,
#    share -F nfs -o rw=engineering -d "home dirs" /export/home2

paperbark%



    [ Team LiB ] Previous Section Next Section