Harddrive space - EA

Contributor II

I am trying to find a working extension attribute for space. Most interested in space left on drive in Megabytes - or maybe also the total capacity

Have found the following that I put into a EA - but don´t seem to work as nothing is rapported

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE extensionAttribute PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <displayName>Boot Volume Free Space</displayName>
  <description>Returns the free space on the current boot volume in GB, rounded down to the nearest integer.</description>

free=`diskutil info /|grep "Free Space"|awk '{print $4}'`

echo "&lt;result&gt;"${free%.*}"&lt;/result&gt;"</scriptContentsMac>

Do any has some working on this on Mojave?


Contributor III

There is already a native Jamf inventory for “Boot Drive Available MB” and “Boot Drive Pecentage Full”. Would those work for you?

Contributor II

Arh yes . I actually looked on the extension but looked at harddrive/volume where there was nothing

Legendary Contributor III

Try this for the EA:


echo "<result>$(diskutil info / | awk '/Free Space|Available Space/{print $4}')</result>"

The reason you're not getting any results is because, I think around 10.12, it changed from "Volume Free Space to "Volume Available Space"
The EA above should work on older OSes and current ones as it looks for either term.

I suggest saving it as an integer style EA, then you can use it to create Smart Groups using a greater than or less than modifier.

New Contributor

I was able to get the following script to work for me but, I haven't been able to modify the script to make the unit(GB) show up after the free space amount is listed. Any help/ideal would be greatly appreciated!


echo "<result>$(diskutil info / | awk '/Free Space|Available Space/{print $4}')</result>"

Contributor II

add the 5th column, it would be diskutil info / | awk '/Free Space|Available Space/{print $4,$5}'

Going to give this a try and report back. Running Catalina and Big Sur. Curious about this... Specifically:


echo "<result>$(diskutil info / | awk '/Free Space|Available Space/{print $4,$5}')</result>"

@efil4xiN and @user-HKroWEoJlf 

Hey @rcole 


 I ended up going with


DU=$(df -h / | awk 'END{ print $(NF-4) }')

echo "<result>$DU</result>"

the following which works in Catalina and Big Sur. As always ..test,test,test