FileSystem class

class diskinfo.FileSystem(_device)[source]

This class encapsulates filesystem-related information read from a block device’s udev properties. It is used by both Partition and Disk to represent filesystem data.

Note

  1. The mounting point and available space are determined by reading /proc/mounts and calling os.statvfs(). If the file system is not mounted, the mounting point will be empty and the free size will be 0.

  2. Instances are created internally by Partition and Disk.

Parameters:

_device (pyudev.Device) – pyudev.Device class

get_fs_free_size()[source]

Returns the free size of the file system in 512-byte blocks. The result could be 0 if the device does not contain a file system or if the file system is not mounted.

Return type:

int

get_fs_free_size_in_hrf(units=0)[source]

Returns the free size of the file system in human-readable form. The result could be 0 if the device does not contain a file system or if the file system is not mounted.

Parameters:

units (int) –

unit system will be used for the calculation and in the result:

  • 0 metric units (default)

  • 1 IEC units

  • 2 legacy units

Read more about units here.

Returns:

size in human-readable form, proper unit

Return type:

Tuple[float, str]

get_fs_label()[source]

Returns the label of the file system. The result could be empty if the file system does not have a label.

Return type:

str

get_fs_mounting_point()[source]

Returns the mounting point of the file system. The result could be empty if the device does not contain any file system, or it is not mounted.

Return type:

str

get_fs_size()[source]

Returns the total size of the file system in 512-byte blocks. The result could be 0 if the device does not contain a file system or if the file system is not mounted.

Return type:

int

get_fs_size_in_hrf(units=0)[source]

Returns the total size of the file system in human-readable form. The result could be 0 if the device does not contain a file system or if the file system is not mounted.

Parameters:

units (int) –

unit system will be used for the calculation and in the result:

  • 0 metric units (default)

  • 1 IEC units

  • 2 legacy units

Read more about units here.

Returns:

size in human-readable form, proper unit

Return type:

Tuple[float, str]

get_fs_type()[source]

Returns the type of the file system. The result could be empty if the device does not contain a file system.

Return type:

str

get_fs_usage()[source]

Returns the usage of the file system. The result could be empty if the device does not contain a file system. Valid values are filesystem or other for special devices (e.g. for a swap partition).

Return type:

str

get_fs_uuid()[source]

Returns the UUID of the file system. The result could be empty if the device does not contain a file system.

Return type:

str

get_fs_version()[source]

Returns the version of the file system. The result could be empty if the device does not contain a file system or does not have a version.

Return type:

str