psutil.disk_partitions() 无法检测到 NFS 文件系统

psutil.disk_partitions() is unable to detect NFS file system

我在 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?

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

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

If all parameter is False it tries to distinguish and return physical devices only (e.g. hard disks, cd-rom drives, USB keys) and ignore all others (e.g. pseudo, memory, duplicate, inaccessible filesystems).

默认排除 NFS。