Check if a directory is a mount point with python 2.7

There is an os.path.ismount(path).

Return True if pathname path is a mount point: a point in a file system where a different file system has been mounted. The function checks whether path‘s parent, path/.., is on a different device than path, or whether path/.. and path point to the same i-node on the same device — this should detect mount points for all Unix and POSIX variants.

import os
os.path.ismount(dir_name)  # returns boolean

You may also refer to implementation (if you're on POSIX system). Check macpath.py or ntpath.py for other platforms.


in Python 3.7, use Path.is_mount()

>>> from pathlib import Path
>>> p = Path('/some/mounted/dir/')
>>> p.is_mount()
True