【问题标题】:psutil.disk_partitions() is unable to detect NFS file systempsutil.disk_partitions() 无法检测 NFS 文件系统
【发布时间】:2021-07-01 15:04:07
【问题描述】:

我在 Linux 平台的 NFS 文件系统上挂载了一个目录 (/export/sheisey_R)。

Linux 命令mountdf 能够将其类型识别为nfs

# mount -l|grep nfs
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
rwsnas437.xxx.com:/export/sheisey_R on /export/sheisey_R type nfs (rw,relatime,sync,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,hard,noac,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=1X.32.2X.2X,mountvers=3,mountport=20048,mountproto=tcp,local_lock=none,addr=1X.32.2X.2X)
# df -P -T /export/sheisey_R/
Filesystem                                Type 1024-blocks       Used  Available Capacity Mounted on
rwsnas437.us.oracle.com:/export/sheisey_R nfs  11336370560 4100561376 7235809184      37% /export/sheisey_R

psutil.disk_partitions() 无法识别 nfs 类型的目录。

Python 3.9.4 (default, May  4 2021, 00:13:06) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.disk_partitions()
[sdiskpart(device='/dev/mapper/VGExaDb-LVDbSys1', mountpoint='/', fstype='ext4', opts='rw,relatime,stripe=256,data=ordered'), sdiskpart(device='/dev/sda1', mountpoint='/boot', fstype='ext4', opts='rw,nodev,relatime,stripe=256,data=ordered'), sdiskpart(device='/dev/mapper/VGExaDb-LVDbOra4', mountpoint='/opt/orainv', fstype='ext4', opts='rw,nodev,relatime,stripe=256,data=ordered'), sdiskpart(device='/dev/mapper/VGExaDb-LVDbOra1', mountpoint='/u01', fstype='ext4', opts='rw,nodev,relatime,stripe=256,data=ordered'), sdiskpart(device='/dev/mapper/VGExaDb-LVDbOra5', mountpoint='/opt/oracrs', fstype='ext4', opts='rw,nodev,relatime,stripe=256,data=ordered'), sdiskpart(device='/dev/mapper/VGExaDb-LVDbOra2', mountpoint='/opt/oracle', fstype='ext4', opts='rw,nodev,relatime,stripe=256,data=ordered'), sdiskpart(device='/dev/asm/acfsvol01-441', mountpoint='/acfs01', fstype='acfs', opts='rw,relatime,device,rootsuid,ordered'), sdiskpart(device='/dev/asm/sbyacfs01-483', mountpoint='/acfsrep/sbyacfs01', fstype='acfs', opts='rw,relatime,device,rootsuid,ordered'), sdiskpart(device='/dev/asm/sbychkbase-483', mountpoint='/acfsrep/sbychkbase', fstype='acfs', opts='rw,relatime,device,rootsuid,ordered')]

有没有python库可以检测文件系统类型是否为nfs?

【问题讨论】:

    标签: python linux nfs psutil


    【解决方案1】:

    尝试将True 传递为psutil.disk_partitions(True)

    https://psutil.readthedocs.io/en/latest/#psutil.disk_partitions

    如果所有参数为 False,它会尝试区分并仅返回物理设备(例如硬盘、CD-ROM 驱动器、USB 密钥)并忽略所有其他设备(例如伪、内存、重复、不可访问的文件系统)。

    NFS 默认被排除在外。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多