You can simply use the linux df command. This will return you a summary of all available disks on your computer.
public static class ServersManager
{
public static string GetDiskSpace()
{
return string.Join(" ", "df").Bash();
}
private static string Bash(this string cmd)
{
var escapedArgs = cmd.Replace("\"", "\\\"");
var process = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = "/bin/bash",
Arguments = $"-c \"{escapedArgs}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
}
};
process.Start();
string result = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return result;
}
}
GetDiskSpace :
| 1K- | | | % |
/dev/sda4 | 497240864 | 31182380 | 466058484 | 7% |/