The unmounting of 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 the following occurs:
The file system is no longer needed or has been replaced by a file system that contains more current software.
You need to check and repair the file system by using the fsck command. For more information about the fsck command, see Chapter 43, Checking UFS File System Consistency (Tasks).
It is a good idea to unmount a file system before doing a complete backup. For more information about doing backups, see Chapter 47, Backing Up Files and File Systems (Tasks).
File systems are automatically unmounted as part of the system shutdown procedure.
You can use the umount -f option to forcibly unmount a file system that is busy in an emergency situation. This practice is not recommended under normal circumstances because the unmounting of a file system with open files could cause a loss of data. This option is only available for UFS and NFS file systems.
The prerequisites for unmounting file systems include the following:
You must be superuser or assume an equivalent role.
A file system must be available for unmounting. You cannot unmount a file system that is busy. A file system is considered busy if a user is accessing a directory in the file system, if a program has a file open in that file system, or if it is being shared. You can make a file system available for unmounting by doing the following:
Changing to a directory in a different file system.
Logging out of the system.
Using the fuser command to list all processes that are accessing the file system and to stop them if necessary. For more details, see How to Stop All Processes Accessing a File System.
Notify users if you need to unmount a file system that they are using.
Unsharing the file system. For information about unsharing a file system, see unshare(1M).
To verify that you unmounted a file system or a number of file systems, examine the output from the mount command.
$ mount | grep unmounted-file-system $ |
List all the processes that are accessing the file system so that 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 |
Specifies the name of the file system for which you want to stop processes. |
Stop all processes that are accessing the file system.
# fuser -c -k /mount-point |
A SIGKILL is sent to each process that is using the file system.
You should not stop a user's processes without first warning the user.
Verify that there are no processes that are accessing the file system.
# fuser -c /mount-point |
The following example shows how to stop 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 for the root (/), /usr, or /var file systems.
The root (/), /usr, and /var file systems can be unmounted only during a shutdown, since the system needs these file systems to function.
Make sure that you have met the prerequisites listed in Prerequisites for Unmounting File Systems.
Unmount the file system.
# umount /mount-point |
/mount-point is the name of the file system that you want to unmount. This can be one of the following:
The directory name where the file system is mounted
The device name path of the file system
The resource for an NFS file system
The loopback directory for a LOFS file system
The following example shows how to unmount a local home file system.
# umount /export/home |
The following example shows how to unmount the file system on slice 7.
# umount /dev/dsk/c0t0d0s7 |
The following example shows how to forcibly unmount the /export file system.
# umount -f /export # |
The following example shows how to unmount all file systems in the /etc/vfstab file, except for the root (/), /proc, /var, and /usr file systems.
# umountall |
All file systems are unmounted, except for those file systems that are busy.