151

Possible Duplicate:
How to tell what type of filesystem you’re on?
Find filesystem of an unmounted partition from a script

How can I quickly check the filesystem of the partition? Can I do that by using df?

tux_drummer
  • 1,853

2 Answers2

199

Yes, according to man df you can:

-T, --print-type      print file system type

Another way is to use the mount command. Without parameters it lists the currently mounted devices, including their file systems.

In case you need to find out only one certain file system, is easier to use the stat command's -f option instead of parsing out one value from the above mentioned commands' output.

manatwork
  • 31,277
  • 5
    mount won't show the file system mounted by fuse, just that it's a fuseblk – Evan Carroll Dec 25 '16 at 21:46
  • 1
    stat -f /var, for example. – CivFan Apr 12 '17 at 16:09
  • @EvanCarroll in the fuse case, this helps: lsblk -no name,fstype – Basj Nov 26 '20 at 20:13
  • What's an example of a full df command to accomplish this? It seems to require more arguments than simply -t (mine does -t instead of -T). – Brōtsyorfuzthrāx Aug 18 '22 at 01:22
  • 1
    @Brōtsyorfuzthrāx, mine is the GNU coreutils df and for -T (list types) expects nothing else. For -t (filter types) indeed expects one of the files system types listed by -T. Sure when executing df on your machine is run the command you are expecting and not an alias or a function? The type df command may shed light on that. To make sure no alias or function with the same name interferes, try to execute command df -T instead. Here you can see how it works on my machine: https://pastebin.com/UkmNyNGG – manatwork Aug 18 '22 at 03:01
  • @manatwork I'm using the df on Termux (on Android). When I do df --version it says toybox 0.8.0-android. There's no -T option on mine, but I do get similar output as your -T if I just run df with no arguments, except there's no type column. – Brōtsyorfuzthrāx Aug 18 '22 at 03:39
  • 1
    @Brōtsyorfuzthrāx, unfortunately that implementation will not do it. Your best option may be mount without parameters, though that will probably display a huge list of mountpoints. – manatwork Aug 18 '22 at 04:00
87

If the filesystem is not mounted (but if it is as well):

blkid -o value -s TYPE /dev/xxx

or:

file -Ls /dev/xxx

where xxx stands for actual block device name like sda1.

You'll generally need read access to the block device. However, in the case of blkid, if it can't read the device, it will try to get that information as cached in /run/blkid/blkid.tab or /etc/blkid.tab.

lsblk -no FSTYPE /dev/xxx

will also give you that information, this time by querying the udev data (something like /run/udev/data/b$major:$minor).

ᄂ ᄀ
  • 364
  • Perfect, this works also for unmounted filesystems and even images. And looks less weird than (eval $(blkid $DEV | awk ' { print $3 } '); echo $TYPE)... – Tobias Kienzler Nov 02 '12 at 06:59
  • 2
    I like this because it does not require mounting the device, and uses common "off the shelf" utilities, like file . Good stuff. – Felipe Alvarez Sep 15 '15 at 03:53
  • 2
    For exfat and probably other fuse mounted filesystems, only the last lsblk example works. Or lsblk -f /dev/sdX for more verbose output. – mivk Jul 13 '17 at 07:53
  • the most awesome answer in the internet ever – Alex Jul 09 '23 at 20:51