150

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?

0

2 Answers 2

198

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.

7
  • 5
    mount won't show the file system mounted by fuse, just that it's a fuseblk Dec 25, 2016 at 21:46
  • 1
    stat -f /var, for example.
    – CivFan
    Apr 12, 2017 at 16:09
  • @EvanCarroll in the fuse case, this helps: lsblk -no name,fstype
    – Basj
    Nov 26, 2020 at 20:13
  • 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: pastebin.com/UkmNyNGG
    – manatwork
    Aug 18, 2022 at 3:01
  • 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, 2022 at 4: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).

4
  • Perfect, this works also for unmounted filesystems and even images. And looks less weird than (eval $(blkid $DEV | awk ' { print $3 } '); echo $TYPE)... Nov 2, 2012 at 6:59
  • 2
    I like this because it does not require mounting the device, and uses common "off the shelf" utilities, like file . Good stuff. Sep 15, 2015 at 3: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, 2017 at 7:53
  • the most awesome answer in the internet ever
    – Alex
    Jul 9, 2023 at 20:51

Not the answer you're looking for? Browse other questions tagged .