Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7040617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:56:22+00:00 2026-05-28T01:56:22+00:00

I want to be able to take a device name (eg: /dev/disk2 ) and

  • 0

I want to be able to take a device name (eg: /dev/disk2) and determine where (if anywhere) it’s mounted (eg: /mnt/cdrom or /Volumes/RANDLABEL) in Python.

One way I can do this is to run df or mount and then parse the output, but this seems pretty cheesy and unreliable. For example, mount uses " on " as the delimiter between the device and the mountpoint. While very unlikely, either of these could potentially include that very string, making the output ambiguous.

On Linux I could read /proc/mounts, but this won’t work on Mac OS X, for example.

So I’m looking for a way to find the mountpoint for a device in a way that’s reliable (ie: can deal with arbitrary (legal) device/mountpoint names) and is “as portable as possible”. (I’m guessing that portability to Windows might not be possible — I’m not sure if it even has an analogous concept of device mountpoints.) I particularly want something that will work on both Linux and OS X.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:56:23+00:00Added an answer on May 28, 2026 at 1:56 am

    (From my comment above: mtab is the standard Linux way. It doesn’t exist on FreeBSD, Mac OS X or Solaris. The former two have the getfsstat(2) and getmntinfo(2) system calls; on Solaris you can use getmntent(3C). Unfortunately the list of currently-mounted filesystems is not defined by POSIX AFAIK, so it is wildly different on different platforms.)

    There’s the experimental mount module in the PSI package from PyPI, which appears to attempt to bundle all the platform-specific methods into a simple abstraction, and which is advertised as working on Mac OS X (Darwin), AIX, Linux and Solaris. The Darwin module probably works on *BSD.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to take still images with a web cam, via
I want to be able to take a dynamically created string, say Pigeon and
i want to be able to take html code and render plain text out
Core problem: I want to be able to take an instance of a templated
In a Java application I want to be able to take a timestamp at
I have an ASP.NET web application and I want to be able to take
I have a .Net 2.0/3.5 WebApplication. I want to be able to take money
I want to be able to measure the time it take to execute an
I really want to be able to have a way to take an app
I want to be able to take the files I found with my first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.