umount - macOS


Overview

The umount command in macOS detaches a mounted volume from the file system, making it unavailable to the system. It is primarily used to unmount external storage devices such as USB drives, SD cards, and network shares.

Syntax

umount [-f] [-v] [-C] [-A] [-A -t fstype] [-a] [-d] [device | mountpoint]

Options/Flags

  • -f: Force unmount, even if the volume is busy or has open files.
  • -v: Verbose output, showing additional details during the unmount process.
  • -C: Cancel the unmount request if the volume is busy or has open files.
  • -A: Unmount all mounted volumes.
  • -A -t fstype: Unmount all mounted volumes with the specified file system type (fstype).
  • -a: Auto-unmount all mounted volumes that are not busy or have no open files.
  • -d: Detach the unmounted volume from the Disk Arbitration service, allowing it to be ejected without unmounting.

Examples

To unmount a USB drive mounted at /Volumes/MyDrive:

umount /Volumes/MyDrive

To force unmount a busy volume:

umount -f /Volumes/BusyVolume

To verbosely unmount a network share:

umount -v /Volumes/NetworkShare

To unmount all mounted volumes:

umount -A

To automatically unmount all volumes that are ready:

umount -a

Common Issues

Unmounting a volume while files are open or being used can lead to data loss. Use the -f flag with caution.

Integration

The umount command can be combined with the diskutil command to manage and unmount disk partitions:

diskutil unmount /dev/disk0s3
  • mount: Mounts a volume or file system.
  • diskutil: A utility for managing disk drives, partitions, and volumes.
  • df: Displays information about mounted file systems.