44

Is there a command to tell what type of filesystem you're using?

4

10 Answers 10

29

Your question can be taken several ways. Literally Karlson's answer is pretty cool because it tells you the filesystem of the volume | partition that you are currently on.

df -hT I have always liked this command because it shows you all the "standard" filesystems that are mounted and does it in human-readable size format.

However, you may have other disks or volumes that are not mounted (commented out), failed to mount, or have been unmounted. Another thing you can do is to run cat /etc/fstab this will show you the "filesystem table" and list the filesystems that are supposed to be mounted on boot along with the location, filesystem type, mountpoint, and more.

2
  • I just want to note that if you see fuseblk, it's (most likely) NTFS.
    – phunehehe
    Commented Feb 3, 2016 at 12:46
  • @phunehehe No, it can be exFAT as well.
    – Basj
    Commented Nov 26, 2020 at 20:13
24

The stat command on Linux systems is used to display file or file system status. For more information read manpage by running man stat in terminal.

$ stat -f -c %T /
xfs
$ stat -f -c %T /boot
ext2/ext3
$ stat -f -c %T /srv
btrfs
$ stat -f -c %T /tmp
tmpfs

Flags used above:

-f, --file-system - display file system status instead of file status

-c --format=FORMAT - use the specified FORMAT instead of the default output a newline after each use of FORMAT

Valid format sequences for file systems:

%T - Type in human readable form

5
  • 3
    If it matters, I believe this is specific to Linux.
    – Chris Down
    Commented Mar 21, 2012 at 14:17
  • 6
    It never shows ext4!
    – Pandya
    Commented Jan 22, 2016 at 8:52
  • @ChrisDown is right, at least on MacOS the stat command lacks the --file-system option (-f is stilla valid option, but have a different meaning).
    – gerlos
    Commented Dec 12, 2017 at 9:12
  • For anyone else who misinterpreted the manual pages, man stat lists %T among others, twice. The "valid format sequences for file systems" section of relevant when using the -f option. Commented Sep 9, 2021 at 9:09
  • On an Azure Ubuntu VM, I get tmpfs for every block device, and ext2/ext3 for directories. This contradicts the output from df -T, lsblk -f, blkid, etc.
    – daviewales
    Commented Oct 24, 2023 at 22:22
10

If you do:

df -k .

It will tell you what filesystem your current directory is on.

3
  • 18
    df . is enough for this. And, if you need to know the filesystem type, df -T . will do.
    – Alexios
    Commented Mar 20, 2012 at 22:29
  • To see the partition of some specific file check here. Commented Mar 21, 2012 at 14:08
  • Only df -T or df --print-type works on the latest Mint. Commented Feb 12, 2019 at 18:29
7

You can also use lsblk -f and blkid to get information about your filesystems and their properties.

4
df -T . | awk '{ getline ; print $2 }'
2

Run df ., which will tell you on what filesystem the current directory resides. Then run mount, which will produce a list of mounted filesystems along with their types and mount options. This works for me:

mount | fgrep -w "`df . | grep '%' | sed -e 's/.*% *//'`"
2

Just use blkid -o value -s TYPE "$DEV", it also works for unmounted devices or even image files.

2

On GNU Linux you can get an overview of your storage using lsblk and then get the file system type for the device you're interested using something like one of the following:

  • $ fsck -N /dev/sda1 (you don't need superuser powers to use this command)
  • $ df -T /dev/sda1 (doesn't require superuser powers, but requires the file system to be mounted)
  • # file -s /dev/sda1
  • # blkid /dev/sda1

These may be useful if your file system is on a LVM volume, since lsblk won't tell you what file system is in there.

0

cat /etc/mtab for mounted filesystems.

0

For an overview of all filesystems:

lsblk -f

To get just the name, type, filesystem, and partition type:

$ lsblk -o NAME,TYPE,FSTYPE,PTTYPE
NAME    TYPE FSTYPE   PTTYPE
sda     disk          gpt
├─sda1  part ext4     gpt
├─sda14 part          gpt
└─sda15 part vfat     gpt
sdb     disk          dos
└─sdb1  part ext4     dos
sdd     disk

To get just the filesystem for a specific partition (-n removes the header):

$ lsblk -n -o FSTYPE /dev/sda1
ext4

You must log in to answer this question.

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