The USB_FREE command returns the available space on an attached USB external storage device.

Advanced payloads can use this to determine available space.

If there is no USB drive attached, USB_FREE will return 0

Return values

USB_FREE returns as output the amount of space free on an attached USB storage device, in bytes.

To learn how to write payloads which can handle responses, check the Advanced Bash section!


You can experiment using the USB_FREE command live, either in the Web Shell in the web UI, or via ssh!


Payloads using the USB_FREE command must handle the output; for example the following payload sets the LED based on the free space. For more information about writing advanced payloads, see the Advanced Bash section!


# Title: USBFREE demo
# Description: Set the LED color based on the free space.



if [ $SPACE = 0 ]; then
        # No storage, blink red
        LED R SINGLE
elif [ $SPACE -lt $((1024*1024)) ]; then 
        # Less than a meg free, blink magenta
        LED M SINGLE
        # Blink green
        LED G SINGLE

Last updated