Getting Linux partition info programmatically

Christian Heimes lists at cheimes.de
Fri Sep 12 20:38:17 CEST 2008


python dev wrote:
> Hello everyone,
> 
> I am trying to get a list of all the partitions (along with their respective
> file system types) listed in the /media directory.  Does anybody know if
> there is a way to do this using Python, or do I have to get this information
> by parsing the output of a Linux command?

The /sys and /proc file system provide all the information you need:

for line in open("/proc/mounts"):
     ...

Christian




More information about the Python-list mailing list