This chapter describes how to mount and unmount file systems. This is a list of the step-by-step instructions in this chapter.
"How to Mount Multiple File Systems Listed in the /etc/vfstab File"
"x86: How to Mount a PCFS (DOS) File System From a Hard Disk"
"How to Unmount File Systems Listed in the /etc/vfstab File"
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
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.
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 |
---|---|
Mounts file systems and remote resources. |
|
Mounts all file systems specified in the /etc/vfstab file. The mountall command is run automatically when entering multiuser run states. |
|
Unmounts file systems and remote resources. |
|
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.
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. |
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. |
$ 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 $ |
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 |
|
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. |
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 (-).
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.
Edit the /etc/vfstab file and add an entry.
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.
Save the changes.
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 - |
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.
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.
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 ... |
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.
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. |
The following example mounts the /usr/openwin file system listed in the /etc/vfstab file.
# mount /usr/openwin |
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.
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. |
The following example mounts /dev/dsk/c0t3d0s7 on the /files1 directory.
# mount /dev/dsk/c0t3d0s7 /files1 |
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 |
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.
Become superuser.
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.
Unmount the file system.
# umount mount-point |
Reset the file system state.
# fsck mount-point |
Remount the file system with the nolargefiles option.
# mount -o nolargefiles mount-point |
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 |
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.
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.
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. |
The following example mounts the /export/packages directory on /mnt from the server pluto.
# mount -F nfs pluto:/export/packages /mnt |
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.
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. |
The following example mounts /dev/dsk/c0t3d0s7 on the /files1 directory.
# mount -F s5fs /dev/dsk/c0t3d0s7 /files1 |
Use the following procedure to mount a PCFS (DOS) file system from a hard disk.
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.
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.
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 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:
It is no longer needed or has been replaced by a file system that contains more current software.
You need to check and repair it using the fsck command. See Chapter 31, Checking File System Integrity for more information about the fsck command.
It is a good idea to unmount a file system before doing a complete backup. See Chapter 34, Backing Up Files and File Systems (Tasks) for more information about doing backups.
File systems are automatically unmounted as part of the system shutdown procedure.
The prerequisites to unmount file systems are:
You must be superuser.
A file system must be available for unmounting. You cannot umount 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. You can make a file system available for unmounting by:
Changing to a directory in a different file system.
Logging out of the system.
Using the fuser command to list all processes accessing the file system and to stop them if necessary. See "How to Stop All Processes for a File System" for more details.
Notify users if you need to unmount a file system they are using.
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".
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. |
Stop all processes for the file system.
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.
Verify that there are no processes using the file system.
# fuser -c mount-point |
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: |
Use the following procedure to unmount a file system (except / or /usr):
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.
Make sure you have met the prerequisites listed on "Prerequisites".
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. |
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 |
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.
Make sure you have met the prerequisites listed on "Prerequisites".
Unmount all the file systems listed in the /etc/vfstab file.
# umountall |
All systems that are unmounted, except those that are busy.
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".
Repeat Step 2 as needed until all file systems are unmounted.