Hard Disk Size of System on Linux and Windows

Hello Team,

I need one help i want to check the free space on Hard Disk of a system and the Used space could you please help

Regards,
DB

Linux:

(device name of it | logical volume of it as string,(if size of it < (1024*1024*1024) then (size of it/(1024*1024)) as string & "MB" else (size of it/(1024*1024*1024)) as string & "GB"),(if used space of it < (1024*1024*1024) then (used space of it/(1024*1024)) as string & "MB" else (used space of it/(1024*1024*1024)) as string & "GB"),(if free space of it < (1024*1024*1024) then (free space of it/(1024*1024)) as string & "MB" else (free space of it/(1024*1024*1024)) as string & "GB"),used percent of it,mount point of it) of filesystems whose (size of it > 0)

Windows:

((name of it & " - " & (total space of it / 1024 / 1024 /1024) as string & "GB") | (name of it & " - Error"), (free space of it / 1024 / 1024 /1024) as string & "GB") of drives whose (type of it = "DRIVE_FIXED")

Thanks Jay for the Answer, However it says Logical Volume Not Defined.

Regards,
DB

Q: (device name of it | logical volume of it as string,(if size of it < (102410241024) then (size of it/(10241024)) as string & "MB" else (size of it/(102410241024)) as string & "GB"),(if used space of it < (102410241024) then (used space of it/(10241024)) as string & "MB" else (used space of it/(102410241024)) as string & "GB"),(if free space of it < (102410241024) then (free space of it/(10241024)) as string & "MB" else (free space of it/(10241024*1024)) as string & "GB"),used percent of it,mount point of it) of filesystems whose (size of it > 0)
E: The operator “logical volume” is not defined.

name of operating system contains “Win” then ((if exists string value of properties “Name” of it then string value of properties (“Name”) of it else “”), (if exists string value of properties “Label” of it then string value of properties (“Label”) of it else “”)) of (select objects (“Name, Label from Win32_Volume”) of WMI) as string else (device names of it, names of it) of filesystems whose (total space of it !=0). Try combination of this.

forgot a few characters at the begining:

if name of operating system contains “Win” then ((if exists string value of properties “Name” of it then string value of properties (“Name”) of it else “”), (if exists string value of properties “Label” of it then string value of properties (“Label”) of it else “”)) of (select objects (“Name, Label from Win32_Volume”) of WMI) as string else (device names of it, names of it) of filesystems whose (total space of it !=0)

For Lin/Ux, this should be the one:
(device names of it, names of it) of filesystems whose (total space of it !=0)

and then you add the disk space stuff from the first one I sent to this.

1 Like

We have one Query below which will give the details of portion however i am looking for complete hard disk Free and Utilizes Space.

Query for drive -

Q:(name of it & " - Size: " & ((total space of it /(1024*1024*1024)) as string & " GB") & ", Used:(" & (((total space of it - free space of it)*100/(total space of it)) as string) & "%25) " & (((total space of it - free space of it) /(1024*1024*1024)) as string & " GB") & ", Free:(" & (((free space of it)*100/(total space of it)) as string) & "%25) "& ((free space of it /(1024*1024*1024)) as string & " GB")) of drives whose(exists name of it AND exists free space of it AND exists type of it AND exists total space of it AND type of it = "DRIVE_FIXED" AND total space of it != 0 AND total space of it > 1024*1024*1024)
A: C: - Size: 38 GB, Used:(41%25) 15 GB, Free:(58%25) 22 GB
A: D: - Size: 61 GB, Used:(0%25) 0 GB, Free:(99%25) 61 GB

Thanks a lot Jay. Query for windows with whose (type of it = “DRIVE_FIX”) not working. It is working without it but instead of giving the disk information, it is giving the drive information. Please help.

I have tested ((name of it & " - " & (total space of it / 1024 / 1024 /1024) as string & "GB") | (name of it & " - Error"), (free space of it / 1024 / 1024 /1024) as string & "GB") of drives this one.

Can you show me how do you see it on the Windows box? The drive is mapped to a disk I’d guess?

I believe he is referring to one physical disk having multiple logical partitions (C: and D: being partitions of one physical disk).

I’m not able to look into this at the moment, but you’d need to find a way to associate which partitions share a physical disk and sum up those sizes.

I have to ask, what’s the use case for this? I don’t really see the value in retrieving the full disk free space in that way.
You should be able to get the full disk size from the builtin inspectors or WMI.

2 Likes

This is related: https://bigfix.me/analysis/details/2994706

Would be helpful to know what an example state is of an example device in terms of partitions and disks and what the desired output would look like based upon those.