User has a (incremental) backup script using rsync, to external device. This was erroring on an SSD he had. Turns out (I had no idea) his device was formatted exFAT. Unfortunately that means I need to detect this in script, as I need to alter the options to rsync (e.g. exFAT cannot handle symbolic links, no owner/group permissions, etc.).

User is running Mint. I run Ubuntu. I can only assume/hope that a solution for my Ubuntu will work for his Mint.

I have looked at:

There are a variety of good suggestions there, but I do not see one which meets my requirements, which are:

  • Must report (parseable) ntfs/exfat explicitly, not just say fuseblk (which it will for both exfat & ntfs, I need to distinguish).
  • Must not require sudo.
  • Must be runnable starting from a directory path on the file system (can assume it will be mounted), not just starting from a /dev/....

From the suggestions I have tried:

  • fdisk -l, parted -l, file -sL: require sudo and/or /dev/... block device
  • mount: requires /dev/..., only reports fuseblk
  • df -T, stat -f -c %T: accept directory, but report only fuseblk
  • lsblk -f, blkid: require /dev/... block device

Is there a single, simple command which meets all these criteria? Or, lsblk/blkid seem to report exfat/ntfs correctly, if I need to pass them the /dev how do I get that suitably from the directory path in script?


Thanks to the other posters for replying/suggesting. Here is my full solution.

df -P can be used to obtain device from path, and that can be fed to lsblk --fs to obtain exact file system. So a one-liner is:

fs=$( lsblk --fs --noheadings $( df -P $path | awk 'END{print $1}' ) | awk 'END{print $2}' )

If all you need to know is that the file system is fuseblk --- which covers both ntfs & exfat and turns out in the end to be sufficient for my purposes after all --- this can be determined with the much simpler:

fs=$( stat -f -c '%T' $path )
  • 1
    Interesting problem... good to hear you got this worked out. – Seamus Mar 14 '20 at 6:14

I'm not sure I follow your question completely, so I'll offer this as a "point of departure". If it gets you close, I'm sure you can tweak it to get what you need:

$ lsblk --fs | grep / | awk '{print $1, $2}'  

what about df . and mount ?

first let's get mount point

 cd /a/dir
 mp=$(df . | awk 'NR==2 { print $1}')
  • $mp while hold device name hoding /a/dir

now, mount point

mount | awk -v mp=$mp '$1 == mp { print $5}'

this should return mount type (be it xfs, etx3, ...)


  • I see my answer is covered in one of the link, you might whish to explore line returned by mount, not just $5
  • As I said, mount reports type fuseblk, which is why I didn't discover ntfs/exfat in the first place? But if your df command is how to convert directory to /dev maybe I can use it with blkid/lsblk -f which do seem to report exact fs. – JonBrave Mar 20 '19 at 9:54
  • 1
    I don't have a ubuntu with ntfs/fat at hand, I'll give a look later on. – Archemar Mar 20 '19 at 10:12

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.