Python Forum
Looping Through Linux Filesystems
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looping Through Linux Filesystems
#5
There is one file system in Linux. What you are talking about is mounted points. You can't read a disk partition before mount it. Actual reading not with tools like dd for example.

fstab is a file and you have to open it in order to read its content.

See psutil module.

An example:
import psutil

devs = psutil.disk_partitions()

for dev in devs:
    print(dev.device, psutil.disk_usage(dev.mountpoint).percent, dev.mountpoint)
Output:
/dev/sda7 96.1 / /dev/sda8 96.2 /home /dev/sda5 99.2 /media/storage /dev/sda7 96.1 /var/lib/docker/btrfs
As you can see I have more partitions but they are not mounted.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
Looping Through Linux Filesystems - by anelliaf - Mar-02-2018, 07:44 PM
RE: Looping Through Linux Filesystems - by Larz60+ - Mar-02-2018, 07:48 PM
RE: Looping Through Linux Filesystems - by anelliaf - Mar-05-2018, 06:59 PM
RE: Looping Through Linux Filesystems - by wavic - Mar-05-2018, 08:20 PM
RE: Looping Through Linux Filesystems - by anelliaf - Mar-06-2018, 03:27 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020