System Administration Guide, Volume I

Chapter 28 Mounting and Unmounting File Systems (Tasks)

This chapter describes how to mount and unmount file systems. 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 to the system so you can use it. You make a file system available by mounting it, which attaches the file system to the system directory tree at the specified mount point. The root (/) file system is always mounted. Any other file system can be connected or disconnected from the root (/) file system.

Table 28-1 provides guidelines on mounting file systems based on how you use them.

Table 28-1 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(1) command. See Chapter 11, Guidelines for Using CDs and Diskettes (Overview) for more information.

Commands Used to Mount and Unmount File Systems

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

Table 28-2 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.

Commonly Used Mount Options

Table 28-3 describes the commonly used 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.

For a complete list of mount options for each file system type, refer to the specific mount command man pages (for example, mount_ufs(1M)).

Table 28-3 Commonly Used -o Mount Options

Option 

File System 

Description 

bg | fg

NFS 

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

f

UFS 

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

hard | soft

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).

largefiles | nolargefiles

UFS 

Enables you to create file systems containing files larger than 2 Gbytes. The largefiles option means that a filesystem mounted with this option may contain files larger than 2 Gbytes, but it is not a requirement. The default is largefiles.

logging | nologging

UFS 

Enables logging for the file system. 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. Because the file system can never become inconsistent, fsck can be bypassed, which reduces the time to reboot a system if it crashes, or after an unclean halt.

The log is allocated from free blocks on the file system, and is sized approximately 1 Mbyte per 1 Gbyte of file system, up to a maximum of 64 Mbytes. The default is nologging.

m

CacheFS, NFS, PCFS, S5FS, UFS 

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

noatime

UFS 

Ignores access time updates on files, except when they coincide with updates to the ctime or mtime. See stat(2). This option reduces disk activity on file systems where access times are unimportant (for example, a Usenet news spool). The default is normal access time (atime) recording.

remount

NFS, S5FS, UFS 

Remounts a read-only file system as read-write (using the rw option). This option can be used only in conjunction with the f, logging | nologging, and m options. This option works only on currently mounted read-only file systems.

retry=n

NFS 

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

ro | rw

CacheFS, NFS, PCFS, UFS, S5FS 

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

suid | nosuid

CacheFS, HSFS, NFS, S5FS, UFS 

Allows or disallows setuid execution The default is to allow setuid execution.

How to Determine Which File Systems Are Mounted

You can determine which file systems are mounted by using the mount command.


$ mount -v

-v

Displays the list of mounted file systems in verbose mode. 

Example--Determining 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 Mon Jun 8 10:28:31 1998
/dev/fd on fd read/write/setuid on Mon Jun 8 10:28:31 1998
/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 Mon Jun 8 10:28:31 1998
$

Mounting File Systems Using the /etc/vfstab File

/etc/vfstab Field Descriptions

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

Table 28-4 /etc/vfstab Field Descriptions

Field Name 

Description 

device to mount

  • The block device name for a local UFS file system (for example, /dev/dsk/c0t0d0s0).

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

  • The block device 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) device name 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).

 

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 zero, UFS file systems are not checked; non-UFS file systems are checked. When the field contains a value greater than zero, the file system is checked.  

When the field contains a value of 1, the file system is checked sequentially. 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 automatcially checks the file systems on different disks in parallel to maximize efficiency. Otherwise, the value of the pass number does not have any effect.

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 Table 28-3 for a list of commonly used mount 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 Add an Entry to the /etc/vfstab File

  1. Become superuser.

    Also, there must be a mount point on the local system to mount a file system. A mount point is a directory to which the mounted file system is attached.

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


    Note -

    Since the root (/) file system is mounted read-only by the kernel during the boot process, only the remount option (and options that can be used in conjunction with remount) affect the root (/) entry in the /etc/vfstab file.


    See Table 28-4 for detailed information about the /etc/vfstab field entries. Make sure that 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 to the /etc/vfstab File

The following 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.


#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       -
/                   -                /tmp/newroot lofs -      yes       -                   

The following 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.


#device           device             mount    FS       fsck   mount    mount
#to mount         to fsck            point    type     pass   at boot  options
pluto:/export/man   -                /usr/man nfs      -      yes       ro,soft

The following 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. LOFS file systems must always be mounted after the file systems used to make up the LOFS file system.


#device           device             mount    FS       fsck   mount    mount
#to mount         to fsck            point    type     pass   at boot  options
#
/                   -                /tmp/newroot lofs -      yes       -                   

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

  1. Become superuser.

    Also, there must be a mount point on the local system to mount a file system. A mount point is a directory to which the mounted file system is attached.

  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 specified type 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

The following 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

The following 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 Wed May 27 09:11:50 1998
/dev/fd on fd read/write/setuid on Wed May 27 09:11:50 1998
/tmp on swap read/write on Wed May 27 09:11:50 1998

The following 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 Mon Jun  8 10:28:31 1998
/dev/fd on fd read/write/setuid on Mon Jun  8 10:28:31 1998
/tmp on swap read/write on Mon Jun  8 10:28:31 1998
/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. Become superuser.

    Also, there must be a mount point on the local system to mount a file system. A mount point is a directory to which the mounted file system is attached.

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


    # mount mount-point
    

    mount-point

    Specifies 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

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


# mount /usr/openwin

Mounting File Systems Using the mount Command

How to Mount a UFS File System

  1. Become superuser.

    Also, there must be a mount point on the local system to mount a file system. A mount point is a directory to which the mounted file system is attached.

  2. Mount the UFS file system by using the mount command.


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

    -o mount-options

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

    /dev/dsk/device-name

    Specifies the disk device name for the slice holding the file system (for example, /dev/dsk/c0t3d0s7). See "How to Display Disk Slice Information" to get slice information for a disk.

    mount-point

    Specifies the directory on which to mount the file system. 

Example--Mounting a UFS File System

The following example mounts /dev/dsk/c0t3d0s7 on the /files1 directory.


# mount /dev/dsk/c0t3d0s7 /files1

Example--Mounting a UFS File System With Logging Enabled

UFS logging eliminates file system inconsistency, which can significantly reduce the time of system reboots. The following example mounts /dev/dsk/c0t3d0s7 on the /files1 directory with logging enabled.


# mount -o logging /dev/dsk/c0t3d0s7 /files1

How to Remount a UFS File System Without Large Files

When you mount a file system, the largefiles option is selected by default, which enables you to create files larger than 2 Gbytes. Once a file system contains large files, 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.

This procedure assumes that the file system is in the /etc/vfstab file.

  1. Become superuser.

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


    # cd mount-point
    # find . -xdev -size +2000000 -exec ls -l {} \;
     
    

    mount-point

    Specifies the mount point of 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 mount-point
    
  4. Reset the file system state.


    # fsck mount-point
    
  5. Remount the file system with the nolargefiles option.


    # mount -o nolargefiles mount-point
    

Example--Mounting a File System Without Large Files

The following example checks the /datab file system and remounts it with the nolargefiles option.


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

How to Mount an NFS File System

  1. Become superuser.

    Also, there must be a mount point on the local system to mount a file system. A mount point is a directory to which the mounted file system is attached.

  2. Make sure the resource (file or directory) is available from a server.

    To mount an NFS file system, the resource must be made available on the server by using the share command. See NFS Administration Guide for information on how to share resources.

  3. Mount the NFS file system by using the mount command.


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

    -o mount-options

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

    server:/directory

    Specifies the server's host name that contains the shared resource, and the path to the file or directory to mount. 

    mount-point

    Specifies the directory on which to mount the file system. 

Example--Mounting an NFS File System

The following example mounts the /export/packages directory on /mnt from the server pluto.


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

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

  1. Become superuser.

    Also, there must be a mount point on the local system to mount a file system. A mount point is a directory to which the mounted file system is attached.

  2. Mount the S5FS file system by using the mount command.


    # 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-3 for the list of commonly used mount options or mount_s5fs(1M) for a complete list of options.

    /dev/dsk/device-name

    Specifies the disk device name of the slice holding the file system (for example, /dev/dsk/c0t3d0s7). See "How to Display Disk Slice Information" to get slice information for a disk.

    mount-point

    Specifies the directory on which to mount the file system. 

Example--Mounting an S5FS File System

The following example mounts /dev/dsk/c0t3d0s7 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. Become superuser.

    Also, there must be a mount point on the local system to mount a file system. A mount point is a directory to which the mounted file system is attached.

  2. Mount the PCFS file system by using the mount command.


    # 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

    Specifies 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

    Specifies the directory on which to mount the file system. 

    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

The following example mounts the logical drive in the Primary DOS slice on the /pcfs/c directory.


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

The following example mounts the first logical drive in the Extended DOS slice 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 Determine 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

The following example stops process 4006c that is using the /export/home file system.


# 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

The following example unmounts a local home file system.


# umount /export/home

The following example unmounts the file system on slice 7.


# 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 are unmounted, except those that are busy.

  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.