How do I determine if a given path or drive is formatted to EXT4, EXT3, EXT2, FAT32, NTFS or some such, in Python?
psutil is a cross-platform package which can identify partition types:
>>> psutil.disk_partitions()
[sdiskpart(device='/dev/sda1', mountpoint='/', fstype='ext4', opts='rw,nosuid'),
sdiskpart(device='/dev/sda2', mountpoint='/home', fstype='ext4', opts='rw')]
Warning: On linux, the fstype may be reported as ext4
or ntfs
, but on Windows, the fstype is limited to "removable", "fixed", "remote", "cdrom", "unmounted" or "ramdisk"
.