Reading USB Drive or SD Card Disk Space on NI Linux Real-Time Target

Updated Oct 21, 2023

Environment

Hardware

  • cRIO-9031
  • CompactRIO Controller

Software

  • LabVIEW
  • LabVIEW Real-Time Module

Operating System

  • NI Linux Real-Time

I have an NI Linux Real-Time cRIO and am logging data to an SD card or USB thumb drive. How do I determine or read the free available space on the SD card or USB drive with LabVIEW?

  • You can use the System Exec VI to run a Linux command script.
  • You will want to use the df command as the command line input to get the amount of disk space used and available of a particular file system. For example, df /U will output the disk space information of the U drive.
  • External USB drives and SD cards in cRIOs will default to /u for the first drive, then /v, and so forth.
The following screenshot shows how to implement this all together in LabVIEW.

Additional Information

The standard output will contain a string with the following information: Filesystem, 1K-blocks, Used, Available, Use%, and Mounted on. You can utilize the Scan From String Function to parse through the command line's output to get the specific information you want.