System Administration Guide

Chapter 28 Mounting and Unmounting File Systems (Tasks)

This chapter describes how to mount and unmount file systems individually through the /etc/vfstab file. This is a list of the step-by-step instructions in this chapter.

Mounting File Systems

After you create a file system, you need to make it available. You make file systems available by mounting them. 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 these ways:

When file systems are shared from a server, a client can mount them as NFS file systems in any of these three ways:

CD-ROMs containing file systems are mounted when the CD-ROM is inserted. Diskettes containing file systems are mounted by running the volcheck(1) command.

Prerequisites

The prerequisites to mount file systems are:

Verifying a Mounted File System

To verify that you mounted a file system or a number of file systems, look at the output from the mount command. This is described in "How to See Which File Systems Are Mounted".

Commands Used to Mount and Unmount File Systems

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

Table 28-1 Commands for Mounting and Unmounting File Systems

Command 

Description 

mount(1M)

Mounts file systems and remote resources. 

mountall(1M)

Mounts all file systems specified in the /etc/vfstab file. The mountall command is run automatically when entering multiuser run states.

umount(1M)

Unmounts file systems and remote resources. 

umountall(1M)

Unmounts all file systems specified in the /etc/vfstab file.

The mount commands will 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. See Chapter 31, Checking File System Integrity for information on how to check the file system.

The umount commands will 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.

General Mount Options

Table 28-2 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 28-2 General Mount Options

Option 

File System 

Description 

-rw | ro

CacheFS, NFS, PCFS, UFS, S5FS 

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

-nosuid

HSFS, NFS, UFS 

Disallows setuid execution and prevents devices on the file system from being opened. The default is to allow setuid execution and allow devices to be opened.

-remount

NFS, UFS, S5FS 

With rw, remounts a file system with read/write access.

-f

UFS, S5FS 

Fakes an entry in /etc/mnttab, but doesn't really mount any file systems.

-n

UFS, S5FS 

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

-bg | fg

NFS 

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

-soft | hard

NFS 

Specifies 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 

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

-retry=n

NFS 

Retries the mount operation when it fails. n is the number of times to retry.

Field Descriptions of the /etc/vfstab File

An entry in the /etc/vfstab file has seven fields, which are described in Table 28-3.

Table 28-3 Field Descriptions of the /etc/vfstab File

Field Name 

Description 

device to mount

The device to mount can be: 

  • The block special device for local UFS file systems (for example, /dev/dsk/c0t0d0s0).

  • The resource name for remote file systems (for example, myserver:/export/home for an NFS file system). For more information on remote file systems, see the NFS Administration Guide.

  • The name of the slice on which to swap (for example, /dev/dsk/c0t3d0s1).

  • The /proc directory and proc file system type.

device to fsck

The raw (character) special device that corresponds to the file system identified by the device to mount field (for example, /dev/rdsk/c0t0d0s0). This determines the raw interface that is used by fsck. Use a dash (-) when there is no applicable device, such as for a read-only file system or a remote file system.

mount point

The default mount point directory (for example, /usr for /dev/dsk/c0t0d0s6).

 

FS type

The type of file system identified by the device to mount field.

fsck pass

The pass number used by fsck to decide whether to check a file system. When the field contains a dash (-), the file system is not checked. When the field contains a value greater than zero, the file system is checked; non-UFS file systems with a zero value for fsck pass are checked. For UFS file systems only, when the field contains a zero, the file system is not checked. When fsck is run on multiple UFS file systems that have fsck pass values greater than one and the preen option (-o p) is used, fsck automatically checks the file systems on different disks in parallel to maximize efficiency. When the field contains a value of 1, the file system is checked sequentially. Otherwise, the value of the pass number does not have any effect. In SunOS system software, the fsck pass field does not explicitly specify the order in which file systems are checked.

mount at boot

Set to yes or no for whether the file system should be automatically mounted by mountall when the system is booted. Note that this field has nothing to do with AutoFS.

mount options

A list of comma-separated options (with no spaces) that are used in mounting the file system. Use a dash (-) to show no options. See mount(1M) for a list of the available options.


Note -

You must have an entry in each field in the /etc/vfstab file. If there is no value for the field, be sure to enter a dash (-).


How to See Which File Systems Are Mounted

To see which file systems are mounted:


$ mount

Example--Seeing Which File Systems Are Mounted


$ mount
/ on /dev/dsk/c0t3d0s0 read/write/setuid/largefiles on ...
/usr on /dev/dsk/c0t3d0s6 read/write/setuid/largefiles on ...
/proc on /proc read/write/setuid on Fri May 16 11:39:05 1997
/dev/fd on fd read/write/setuid on Fri May 16 11:39:05 1997
/export on /dev/dsk/c0t3d0s3 setuid/read/write/largefiles on ...
/export/home on /dev/dsk/c0t3d0s7 setuid/read/write/largefiles on ...
/export/swap on /dev/dsk/c0t3d0s4 setuid/read/write/largefiles on ...
/opt on /dev/dsk/c0t3d0s5 setuid/read/write/largefiles on ...
/tmp on swap read/write on Fri May 16 11:39:07 1997
$

How to Add an Entry in the /etc/vfstab File

  1. Make sure you have met the prerequisites listed on "Prerequisites".

  2. Edit the /etc/vfstab file and add an entry.

    See Table 28-3for detailed information about the /etc/vfstab field entries. Make sure you:

    • Separate each field with white space (a space or a tab).

    • Enter a dash (-) if a field has no contents.

  3. Save the changes.

Examples--Adding an Entry in the /etc/vfstab File


 
#device           device             mount    FS      fsck   mount    mount
#to mount         to fsck            point    type    pass   at boot  options
	#
/dev/dsk/c0t3d0s7 /dev/rdsk/c0t3d0s7 /files1  ufs     2      yes       -
pluto:/export/man   -                /usr/man nfs     -      yes     ro,soft
/                   -                /tmp/newroot lofs -     yes     -                   

This example mounts the disk slice /dev/dsk/c0t3d0s7 as a UFS file system attached to the mount point directory /files1 with the default mount options (read/write). It specifies the raw character device /dev/rdsk/c0t3d0s7 as the device to fsck. The fsck pass value of 2 means that the file system will be checked, but not sequentially.

This example mounts the directory /export/man from the system pluto as an NFS file system on mount point /usr/man. It does not specify a device to fsck or a fsck pass because it's an NFS file system. In this example, mount options are ro (read-only) and soft. For greater reliability, specify the hard mount option for read/write NFS file systems.

This example mounts the root (/) file system on a loopback mount point named /tmp/newroot. It specifies yes for mount at boot, no device to fsck, and no fsck pass number. Loopback file systems must always be mounted after the file systems used to make up the loopback file system. Be sure that the loopback entry is the last entry in the /etc/vfstab file so that it follows the entries that it depends on.

How to Mount Multiple File Systems Listed in the /etc/vfstab File

  1. Make sure you have met the prerequisites listed on "Prerequisites".

  2. Mount the file systems listed in the /etc/vfstab file.


    # mountall [-l | -r] [-F fstype]

    If no options are specified, all file systems listed in the /etc/vfstab file with yes in the mount at boot field are mounted.

    -l

    Mounts all the local file systems listed in the /etc/vfstab file with yes in the mount at boot field.

    -r

    Mounts all the remote file systems listed in the /etc/vfstab file with yes in the mount at boot field.

    -F fstype

    Mounts all file systems of the type fstype listed in the /etc/vfstab file with yes in the mount at boot field.

    All the file systems with a device to fsck entry are checked and fixed, if necessary, before mounting.

Examples--Mounting Multiple File Systems Listed in the /etc/vfstab File

This example shows the messages displayed if file systems are already mounted when you use the mountall command.


# mountall
mount: /tmp already mounted
nfs mount: mount: /usr/openwin: Device busy
nfs mount: mount: /usr/man: Device busy

This example mounts all the local systems listed in the /etc/vfstab file.


# mountall -l
# mount
/ on /dev/dsk/c0t3d0s0 read/write/setuid/largefiles on ...
/usr on /dev/dsk/c0t3d0s6 read/write/setuid/largefiles on ...
/proc on /proc read/write/setuid on Fri May 16 11:39:05 1997
/dev/fd on fd read/write/setuid on Fri May 16 11:39:05 1997
/tmp on swap read/write on Fri May 16 11:39:07 1997

This example mounts all the remote file systems listed in the /etc/vfstab file.


# mountall -r
# mount
/ on /dev/dsk/c0t3d0s0 read/write/setuid/largefiles on ...
/usr on /dev/dsk/c0t3d0s6 read/write/setuid/largefiles on ...
/proc on /proc read/write/setuid on Fri May 16 11:39:05 1997
/dev/fd on fd read/write/setuid on Fri May 16 11:39:05 1997
/tmp on swap read/write on Fri May 16 11:39:07 1997
/nfs/mars.dist on mars:/usr/dist intr/remote on ...
/nfs/mars.mail on mars:/var/mail intr/noac/remote on ...

How to Mount a File System Listed in the /etc/vfstab File

  1. Make sure you have met the prerequisites listed in "Prerequisites".

  2. Mount a file system listed in the /etc/vfstab file.


    # mount mount-point
    

    mount-point

    An entry in the mount point or device to mount field in the /etc/vfstab file. It is usually easier to specify the mount point.

Example--Mounting a File System Listed in the /etc/vfstab File

This example mounts the /usr/openwin file system listed in the /etc/vfstab file.


# mount /usr/openwin

How to Mount a UFS File System

  1. Make sure you have met the prerequisites listed in "Prerequisites".

  2. Mount the UFS file system.


    # mount [-o mount-options] /dev/dsk/device-namemount-point
    

    -o mount-options

    Specifies mount options that you can use to mount a UFS file system. See Table 28-2 for the list of general mount options or mount_ufs(1M) for a complete list of options.

    /dev/dsk/device-name

    The special block device file for the disk slice holding the file system (for example, /dev/dsk/c0t3d0s7). See Chapter 26, File Systems (Overview) for information about how to find out disk device names.

    mount-point

    The directory where the file system is mounted. 

Example--Mounting a UFS File System

In this example, /dev/dsk/c0t3d0s7 is mounted on the /files1 directory.


# mount /dev/dsk/c0t3d0s7 /files1

How to Mount a File System With Large Files

The new largefiles mount option, the default state for the Solaris 2.6 environment, allows users to mount a file system containing files larger than 2Gbytes.

The procedure for mounting file systems with large files is identical to the one described previously in "How to Mount a UFS File System".

The largefiles option means that a file system mounted with this option may contain one or more files larger than 2 Gbytes. It is not required that a file system mounted with this option contain files larger that 2Gbytes, but the option allows such files within the file system.

You must explicitly use the nolargefiles mount option to disable this behavior. The nolargefiles option provides total compatibility with previous file system behavior, enforcing the 2 Gbytes maximum file size limit.

How to Remount a File System Without Large Files

After you mount a file system with the default largefiles mount option 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.

  1. Become superuser.

  2. Make sure there are no large files in the file system.


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

    file-system

    The file system you want to check for large files. 

    If large files exist within this file system, they must be removed or moved to another file system.

  3. Unmount the file system.


    # umount /file-system
    
  4. Reset the file system state.


    # fsck /dev/rdsk/device-name
    
  5. Remount the file system with the nolargefiles option.


    # mount -o nolargefiles /dev/rdsk/device-name
    

Example -- Mounting a File System Without Large Files

In this example, /datab is checked for large files and /dev/dsk/c0t3d0s7 is then mounted on the /datab directory.


# cd /datab
# find . xdev -size +2000000 -exec ls -l {} \;
# find . xdev -size +2000000 -exec ls -l {} \;
# umount /datab 
# fsck /dev/rdsk/c0t3d0s7 /files1
# mount -o nolargefiles /dev/dsk/c0t3d0s7 /files1

How to Mount an NFS File System

  1. Make sure you have met the prerequisites listed in "Prerequisites".

  2. Make sure the file system is available from a server.

    To mount an NFS file system, it must be made available from the server system. The share(1M) command creates a list of file systems on a server that can be shared across the network. See NFS Administration Guide for information on how to share file systems.

  3. Mount the NFS file system.


    # mount -F nfs [-o mount-options] server:/directory mount-point
    

    -o mount-options

    Specifies mount options that you can use to mount a NFS file system. See Table 28-2 for the list of general mount options or mount_nfs(1M) for a complete list of options.

    server:/directory

    The server's host name on which the file system is mounted, and the name of the file system to mount. 

    mount-point

    The directory where the file system is mounted. 

Example--Mounting an NFS File System

In this example, packages from the server pluto in the directory /export/packages are mounted on /mnt.


# mount -F nfs pluto:/export/packages /mnt

x86: How to Mount a System V (S5FS) File System

  1. Make sure you have met the prerequisites listed in "Prerequisites".

  2. Mount the S5FS file system.


    # mount -F s5fs [-o mount-options] /dev/dsk/device_name mount-point
    

    -o mount-options

    Specifies mount options that you can use to mount a S5FS file system. See Table 28-2 for the list of common mount options or mount_s5fs(1M) for a complete list of options.

    /dev/dsk/device-name

    The device name of the disk slice holding the file system (for example, /dev/dsk/c0t3d0s7). See Chapter 20, Accessing Devices (Overview) for information about finding out disk device names.

    mount-point

    The directory where the file system is mounted. 

Example--Mounting an S5FS File System

In this example, /dev/dsk/c0t3d0s7 is mounted on the /files1 directory.


# mount -F s5fs /dev/dsk/c0t3d0s7 /files1

x86: How to Mount a PCFS (DOS) File System From a Hard Disk

Use the following procedure to mount a PCFS (DOS) file system from a hard disk.

  1. Make sure you have met the prerequisites listed oin "Prerequisites".

  2. Mount the PCFS file system.


    # mount -F pcfs [-o rw | ro] /dev/dsk/device-name:logical-drive mount-point
    

    -o rw | ro

    Specifies that you can mount a PCFS file system read/write or read-only. If you do not specify this option, the default is read/write. 

    /dev/dsk/device-name

    The device name of the whole disk (for example, /dev/dsk/c0t0d0p0).

    logical-drive

    Specifies either the DOS logical drive letter (c through z) or a drive number 1 through 24. Drive c is equivalent to drive 1 and represents the Primary DOS slice on the drive; all other letters or numbers represent DOS logical drives within the Extended DOS slice. 

    mount-point

    The directory where the file system is mounted. 

    Note that the device-name and logical-drive must be separated by a colon.

Examples--Mounting a PCFS (DOS) File System From a Hard Disk

In this example, the logical drive in the Primary DOS slice is mounted on the /pcfs/c directory.


# mount -F pcfs /dev/dsk/c0t0d0p0:c /pcfs/c

In this example, the first logical drive in the Extended DOS slice on the disk is mounted read-only on /pcfs/d.


# mount -F pcfs -o ro /dev/dsk/c0t0d0p0:2 /pcfs/d

Unmounting File Systems

Unmounting a file system removes it from the file system mount point, and deletes the entry from the /etc/mnttab file. Some file system administration tasks cannot be performed on mounted file systems. You should unmount a file system when:

Prerequisites

The prerequisites to unmount file systems are:

Verifying an Unmounted File System

To verify that you unmounted a file system or a number of file systems, look at the output from the mount command. This is described in "How to See Which File Systems Are Mounted".

How to Stop All Processes for a File System

  1. Become superuser.

  2. List all the processes that are using the file system, so you know which processes you are going to stop.


    # fuser -c [ -u ] mount-point
    

    -c

    Reports on files that are mount points for file systems and any files within those mounted file systems. 

    -u

    Displays the user login name for each process ID. 

    mount-point

    The name of the file system for which you want to stop processes. 

  3. Stop all processes for the file system.


    Note -

    You should not stop a user's processes without warning.



    # fuser -c -k mount-point
    

    A SIGKILL is sent to each process using the file system.

  4. Verify that there are no processes using the file system.


    # fuser -c mount-point
    

Example--Stopping All Processes for a File System

In this example, process 4006c that is using the /export/home file system is stopped.


# fuser -c /export/home
/export/home:     4006c
# fuser -c -k /export/home
/export/home:     4006c
# fuser -c /export/home
/export/home: 

How to Unmount a File System

Use the following procedure to unmount a file system (except / or /usr):


Note -

The root (/) and /usr file systems are special cases. The root (/) file system can be unmounted only during a shutdown, since the system needs the root (/) file system to function.


  1. Make sure you have met the prerequisites listed on "Prerequisites".

  2. Unmount the file system.


    # umount mount-point
    

    mount-point

    The name of the file system that you want to unmount. This can either be the directory name where the file system is mounted, the device name path of the file system, the resource for an NFS file system, or the loopback directory for LOFS file systems. 

Examples--Unmounting a File System

In this example, a local home file system is unmounted.


# umount /export/home

In this example, the file system on slice 7 is unmounted.


# umount /dev/dsk/c0t0d0s7

How to Unmount File Systems Listed in the /etc/vfstab File

Use the following procedure to unmount all the file systems listed in the /etc/vfstab file, except for the /, /proc, /var, and /usr file systems.

  1. Make sure you have met the prerequisites listed on "Prerequisites".

  2. Unmount all the file systems listed in the /etc/vfstab file.


    # umountall
    

    All systems that can be unmounted are unmounted. File systems that are busy are not unmounted.

  3. For the file systems that were busy and not unmounted, make them available to be unmounted as described in "How to Stop All Processes for a File System".

  4. Repeat Step 2 as needed until all file systems are unmounted.