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 39, 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 43, 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 unmounting file systems are:
You must be superuser.
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:
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 Accessing a File System" for more details.
Notify users if you need to unmount a file system they are using.
Unsharing the 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".
List all the processes that are accessing 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 accessing 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 accessing 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 /, /usr, or /var):
The root (/), /usr, and /var 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 Accessing a File System".
Repeat Step 2 as needed until all file systems are unmounted.