43

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

mattdm
  • 39,535
  • 18
  • 99
  • 133
Moshe
  • 739
  • 6
  • 13
  • Possible duplicate: http://unix.stackexchange.com/q/43237/863 (Yes it's newer, but it has a) an accepted answer and b) also works for unmounted filesystems _and_ image files) – Tobias Kienzler Nov 02 '12 at 06:57
  • 2
    It would help for the target operating system(s) to be specified. Most of the answers assume it is Linux but this isn't stated in the question. – jlliagre Nov 02 '12 at 10:03
  • related: https://askubuntu.com/questions/309047/how-do-i-find-out-what-filesystem-my-partitions-are-using – Ciro Santilli OurBigBook.com Jun 15 '18 at 07:46
  • Related Q&A I just added: [How do I find out which partitions my filesystems (and mount points) are on, and how full they are?](https://unix.stackexchange.com/q/733886/114401) – Gabriel Staples Feb 01 '23 at 02:27

9 Answers9

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.

2bc
  • 3,938
  • 1
  • 17
  • 18
22

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

ephemient
  • 15,640
  • 5
  • 49
  • 39
  • 3
    If it matters, I believe this is specific to Linux. – Chris Down Mar 21 '12 at 14:17
  • 6
    It never shows `ext4`! – Pandya Jan 22 '16 at 08: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 Dec 12 '17 at 09: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. – Jonathan Komar Sep 09 '21 at 09:09
10

If you do:

df -k .

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

Karlson
  • 5,845
  • 32
  • 51
6

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

4
df -T . | awk '{ getline ; print $2 }'
Chris Down
  • 122,090
  • 24
  • 265
  • 262
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.

gerlos
  • 201
  • 2
  • 7
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/.*% *//'`"
Kyle Jones
  • 14,845
  • 3
  • 40
  • 51
1

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

Tobias Kienzler
  • 9,184
  • 13
  • 65
  • 106
0

cat /etc/mtab for mounted filesystems.

Nils
  • 18,202
  • 11
  • 46
  • 82