1

I am using latest BusyBox v1.22.1 in my target. I want to check the filesystem type using stat -f or df -T but busybox doesn't support such commands. busybox help shows stat command as supported but while executing its showing as

stat: not found.

How can I check the filesystem type using BusyBox?

0
1

A lot of components of BusyBox are optional. Depending on what compromise was made between size and functionality at compile time, utilities and options may or may not be available.

On Linux, you can get filesystem information from /proc. Run df -P /some/file to find the mount point for /some/file, then search that in /proc/mounts and extract the filesystem type. Assuming you have awk and have no whitespace in mount points, the following command prints the filesystem type that /some/file is on:

</proc/mounts awk -v mount_point="$(df -P /some/file | awk 'NR==2 {print $6}')" '$2 == mount_point {print $3}'
1
  • @user81906 you should mark this answer as accepted if it works for you
    – pqnet
    Aug 26 '14 at 10:11
1

You need to enable stat and du on the .config before build:

CONFIG_DU=y
CONFIG_STAT=y
0

Also, busybox commands may not always have the symlink to busybox, or may not be on your PATH. On RHEL6 "busybox stat -f /dev/XXXX" works.

0

If busybox help shows stat, that would imply the applet is implemented. And if stat returns "not found", that may just be that a link for it to busybox was not created (and busybox has been configured to execute files when invoking applets).

Then since you're able to run busybox help, you should also be able to run busybox stat as an alternative to stat:

busybox stat -fc %T /

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.