Skip to content
Advertisement

Determine Device of Filesystem in Python

How do you use Python to determine which Linux device/partition contains a given filesystem?

e.g.

JavaScript

Advertisement

Answer

It is not the purdiest, but this will get you started:

JavaScript

On OS X:

JavaScript

On Ubuntu:

JavaScript

To get the device name, chop off the minor number from the partition name. On OS X, also chop the ‘s’ + minor number.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement