System Administration Guide, Volume 3

Mounting File Systems

You can mount file systems in several ways. They can be mounted automatically when the system is booted, on demand from the command line, or through the automounter. The automounter provides many advantages to mounting at boot time or mounting from the command line, but many situations require a combination of all three. In addition to these three ways of mounting a file system, there are several ways of enabling or disabling processes depending on the options you use when mounting the file system. See the following table for a complete list of the tasks associated with file system mounting.

Table 30-2 Mounting File Systems Task Map

Task 

Description 

For Instructions, Go to ... 

Mount a file system at boot time 

 Steps so that a file system is mounted whenever a system is rebooted."How to Mount a File System at Boot Time"

Mount a file system using a command 

 Steps to mount a file system when a system is running. This procedure is useful when testing."How to Mount a File System From the Command Line"

Mount with the automounter 

 Steps to access a file system on demand without using the command line."Mounting With the Automounter"

Disallowing large files 

 Steps to prevent large files from being created on a file system."How to Disable Large Files on an NFS Server"

Using client-side failover 

 Steps to enable the automatic switchover to a working file system if a server fails."How to Use Client-Side Failover"

Disabling mount access for a client 

 Steps to disable the ability of one client to access a remote file system."How to Disable Mount Access for One Client"

Providing access to a file system through a firewall 

 Steps to allow access to a file system through a firewall by using the WebNFS protocol."How to Mount an NFS File System Through a Firewall"

Mounting a file system using a NFS URL 

 Steps to allow access to a file system using an NFS URL. This process allows for file-system access without using the MOUNT protocol."How to Mount an NFS File System Using an NFS URL"

How to Mount a File System at Boot Time

If you want to mount file systems at boot time instead of using autofs maps, follow this procedure. Although you must follow this procedure for all local file systems, it is not recommended for remote file systems because it must be completed on every client.

  1. Become superuser.

  2. Add an entry for the file system to /etc/vfstab.

Entries in the /etc/vfstab file have the following syntax:

special  fsckdev  mountp  fstype  fsckpass  mount-at-boot  mntopts

See the vfstab(4) man page for more information.


Caution - Caution -

NFS servers should not have NFS vfstab entries because of a potential deadlock. The NFS service is started after the entries in /etc/vfstab are checked, so that if two servers that are mounting file systems from each other fail at the same time, each system could hang as the systems reboot.


Example of a vfstab entry

You want a client computer to mount the /var/mail directory from the server wasp. You would like the file system to be mounted as /var/mail on the client and you want the client to have read-write access. Add the following entry to the client's vfstab file.


wasp:/var/mail - /var/mail nfs - yes rw

How to Mount a File System From the Command Line

Mounting a file system from the command line is often done to test a new mount point or to allow for temporary access to a file system that is not available through the automounter.

  1. Become superuser.

  2. Mount the file system.

    Type the following command:


    # mount -F nfs -o ro bee:/export/share/local /mnt
    

    In this case, the /export/share/local file system from the server bee is mounted on read-only /mnt on the local system. Mounting from the command line allows for temporary viewing of the file system. You can unmount the file system with umount or by rebooting the local host.


    Caution - Caution -

    Starting with the 2.6 release, all versions of the mount command will not warn about invalid options. The command silently ignores any options that cannot be interpreted. Make sure you verify all of the options that were used, to prevent unexpected behavior.


Mounting With the Automounter

"Autofs Administration Task Overview" includes the specific instructions for establishing and supporting mounts with the automounter. Without any changes to the generic system, clients should be able to access remote file systems through the /net mount point. To mount the /export/share/local file system from the previous example, all you need to do is type:


% cd /net/bee/export/share/local

Because the automounter allows all users to mount file systems, root access is not required. It also provides for automatic unmounting of file systems, so there is no need to unmount file systems after you are finished.

How to Disable Large Files on an NFS Server

For servers that are supporting clients that cannot handle a file over 2 GBytes, it is necessary to disable the ability to create large files.


Note -

Previous versions of the Solaris operating environment cannot use large files. Check that clients of the NFS server are running at least the 2.6 release if the clients need to access large files.


  1. Become superuser.

  2. Check that no large files exist on the file system.

    Here is an example of a command that you can run to locate large files:


    # cd /export/home1
    # find . -xdev -size +2000000 -exec ls -l {} \;
    

    If large files are on the file system, you must remove or move them to another file system.

  3. Unmount the file system.


    # umount /export/home1
    
  4. Reset the file system state if the file system has been mounted using -largefiles.

    fsck resets the file system state if no large files exist on the file system:


    # fsck /export/home1
    
  5. Mount the file system using nolargefiles.


    # mount -F ufs -o nolargefiles /export/home1
    

    You can do this from the command line, but to make the option more permanent, add an entry like the following into /etc/vfstab:


    /dev/dsk/c0t3d0s1 /dev/rdsk/c0t3d0s1 /export/home1  ufs  2  yes  nolargefiles

How to Use Client-Side Failover

  1. Become superuser.

  2. On the NFS client, mount the file system using the ro option.

    You can do this from the command line, through the automounter, or by adding an entry to /etc/vfstab that looks like:


    bee,wasp:/export/share/local  -  /usr/local  nfs  -  no  -o ro

    This syntax has been allowed by the automounter in earlier releases, but the failover was not available while file systems were mounted, only when a server was being selected.


    Note -

    Servers that are running different versions of the NFS protocol cannot be mixed using a command line or in a vfstab entry. Mixing servers supporting NFS V2 and V3 protocols can only be done with autofs, in which case the best subset of version 2 or version 3 servers is used.


How to Disable Mount Access for One Client

  1. Become superuser.

  2. Add an entry in /etc/dfs/dfstab.

    The first example allows mount access to all clients in the eng netgroup except the host named rose. The second example allows mount access to all clients in the eng.sun.com DNS domain except for rose.


    share -F nfs -o ro=-rose:eng /export/share/man
    share -F nfs -o ro=-rose:.eng.sun.com /export/share/man

    For additional information on access lists, see "Setting Access Lists With the share Command".

  3. Share the file system.

    The NFS server does not use changes to /etc/dfs/dfstab until the file systems are shared again or until the server is rebooted.


    # shareall

How to Mount an NFS File System Through a Firewall

  1. Become superuser.

  2. Manually mount the file system, using a command like:


    # mount -F nfs -o public bee:/export/share/local /mnt
    

    In this example the file system /export/share/local is mounted on the local client using the public file handle. An NFS URL can be used instead of the standard path name. If the public file handle is not supported by the server bee, the mount operation will fail.


    Note -

    This procedure requires that the file system on the NFS server be shared using the public option and any firewalls between the client and the server allow TCP connections on port 2049. Starting with the 2.6 release, all file systems that are shared allow for public file handle access.


How to Mount an NFS File System Using an NFS URL

  1. Become superuser.

  2. Manually mount the file system, using a command such as:


    # mount -F nfs nfs://bee:3000/export/share/local /mnt
    

    In this example, the /export/share/local file system is being mounted from the server bee using NFS port number 3000. The port number is not required and by default uses the standard NFS port number of 2049. You can include the public option with an NFS URL, if you want. Without the public option, the MOUNT protocol is used if the public file handle is not supported by the server. The public option will force the use of the public file handle, and the mount will fail if the public file handle is not supported.