unmountDisk
UnmountDisk is a subcommand of Apple's diskutil utility. It unmounts all mounted volumes on a specified disk, allowing the device to be safely prepared for removal or reconfiguration. Unlike detaching a disk, which disconnects the device from the kernel, unmountDisk only unmounts the filesystem volumes while the device node remains present in the system.
Usage: The command typically takes a disk identifier such as /dev/disk2. The basic form is: diskutil unmountDisk
Relation to other diskutil verbs: diskutil also offers unmount (for a single volume) and detachDisk (to detach
Limitations and notes: If a process holds a file on any of the volumes, unmountDisk may fail