Can I list the filesystems a running kernel can support?

I’m trying to detect what filesystems a kernel can support. Ideally in a little list of their names but I’ll take anything you’ve got.

Note that I don’t mean the current filesystems in use, just ones that the current kernel could, theoretically support directly (obviously, fuse could support infinite numbers more).

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Can I list the filesystems a running kernel can support?

Well, answer /proc/filesystems is bluntly wrong — it reflects only those FSes that already were brought in use, but there are way more of them usually that kernel can support:

ls /lib/modules/$(uname -r)/kernel/fs

Another source is /proc/config.gz which might be absent in your distro (and I always wonder «why?!» in case), but a snapshot of config used to build the kernel typically can be found in the boot directory along with kernel and initrd images.

Method 2

/proc/filesystems lists all of the filesystem types supported by the running kernel, along with filesystem attributes, nodev to indicate that this filesystem is not backed by a block device, for example.

man 5 filesystems gives some more in-depth information.

Method 3

I believe this will give you what you want:

(cat /proc/filesystems | awk '{print $NF}' | sed '/^$/d'; ls -1 /lib/modules/$(uname -r)/kernel/fs) | sort -u

Explanation

Based on my best understanding:

  • cat /proc/filesystems | awk '{print $NF}' | sed '/^$/d' gives you all the filesystems that are natively supported by the kernel (like sysfs) along with those that have their kernel modules currently loaded
  • ls -1 /lib/modules/$(uname -r)/kernel/fs gives you the list of available filesystem modules available for your kernel
  • sort -u sorts the combined results of the first two commands with duplicates removed (only show unique results -u)

I am still learning linux, this works on Arch linux but I believe for at least ubuntu you may need to change the path /lib/modules/$(uname -r)/kernel/fs to a different directory appropriate for your distribution.

Method 4

tl;dr

cat /proc/filesystems will show you which filesystems your running kernel can support right now.

ls /lib/modules/$(uname -r)/kernel/fs will provide clues as to which additional filesystems it could support, if you loaded the appropriate module.

Explanation

The question has already been answered, but all of the other answers are in some way incomplete, misleading, untrue, or at least not true any more.

From man 8 mount (emphasis mine):

-t, –types fstype

The argument following the -t is used to indicate the filesystem type. The filesystem types which are currently supported depend on the running kernel. See /proc/filesystems and /lib/modules/$(uname -r)/kernel/fs for a complete list of the filesystems. The most common are ext2, ext3, ext4, xfs, btrfs, vfat, sysfs, proc, nfs and cifs.

I therefore can’t fault anyone suggesting these approaches. However, as others have pointed out, the /lib/modules/$(uname -r)/kernel/fs directory contains filesystem-related kernel modules, which is not the same thing as currently supported filesystems:

  • If the module is not loaded, the filesystem will not be supported currently.
  • If support is built-in to the kernel, the filesystem will be supported but won’t show up in the list of modules.
  • Module names are not guaranteed to map 1:1 to the filesystems they support.

The list can therefore contain additions, deletions and/or substitutions. It’s not very reliable. It’s possible to have a so-called “monolithic kernel” which has everything built-in already – in that (admittedly unusual) case the module list will be completely empty but the kernel will still support an arbitrary number of things – including, of course, various filesystems.

On the other hand, this is the contents of my /proc/filesystems file:

nodev   sysfs
nodev   tmpfs
nodev   bdev
nodev   proc
nodev   cgroup
nodev   cgroup2
nodev   cpuset
nodev   devtmpfs
nodev   binfmt_misc
nodev   configfs
nodev   debugfs
nodev   tracefs
nodev   securityfs
nodev   sockfs
nodev   bpf
nodev   pipefs
nodev   ramfs
nodev   hugetlbfs
nodev   rpc_pipefs
nodev   devpts
        ext3
        ext4
        ext2
        cramfs
        squashfs
        vfat
        msdos
        exfat
        iso9660
nodev   nfs
nodev   nfs4
nodev   nfsd
nodev   cifs
nodev   smb3
        ntfs3
nodev   autofs
        fuseblk
nodev   fuse
nodev   fusectl
        udf
        f2fs
nodev   efivarfs
nodev   mqueue
nodev   resctrl
        btrfs
nodev   pstore

There are filesystems in that list that my system has never even seen, let alone has currently mounted.

So on my system at least, that’s the answer. I can’t speak to why the currently accepted answer leads with the opposite conclusion; perhaps this is a new development…


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x