System Administration Guide: Devices and File Systems

Unmounting UFS File Systems

The unmounting of a UFS 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 UFS file system when the following occurs:

In an emergency situation, you can use the umount -f option to forcibly unmount a busy file system. 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.

Prerequisites for Unmounting File Systems

The prerequisites for unmounting file systems include the following:

How to Verify a File System is Unmounted

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

ProcedureHow to Stop All Processes Accessing a File System

  1. Become superuser or assume an equivalent role.

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

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


    Note –

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


  4. Verify that no processes are accessing the file system.


    # fuser -c /mount-point
    

Example 18–9 Stopping All Processes Accessing a File System

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: 

ProcedureHow to Unmount a File System

Use the following procedure to unmount a file system, except for the root (/), /usr, or /var file systems.


Note –

The root (/), /usr, and /var file systems can be unmounted only during a shutdown. The system needs these file systems to function.


  1. Ensure that you have met the prerequisites listed in Prerequisites for Unmounting File Systems.

  2. Unmount the file system.


    # umount /mount-point
    

    where /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 an LOFS file system


Example 18–10 Unmounting a File System

The following example shows how to unmount a local UFS home file system.


# umount /export/home

The following example shows how to unmount the UFS file system on slice 7.


# umount /dev/dsk/c0t0d0s7

The following example shows how to forcibly unmount the UFS /export file system.


# umount -f /export
# 

The following example shows how to unmount all UFS file systems in the /etc/vfstab file, except for the root (/), /proc, /var, and /usr file systems.


# umountall

The following example shows to unmount all ZFS file systems.


# zfs umount -a

All file systems are unmounted, except for those file systems that are busy.