On a running linux system, what is a portable (among linux distributions) way to find out what filesystems the current kernel has compiled-in (not through modules) support for?
Consider for example my current Ubuntu x86_64 kernel: 3.11.0-24-generic #41-Ubuntu
. It has for instance no /proc/config.gz
, which would be my first thought otherwise.
The reason I'm interested is that I'd like to (programmatically) build a rescue environment with the current kernel and an initial ramdisk that the kernel will be able to load/mount.
Is is as simple as comparing /proc/filesystems
with lsmod
?
If so: Do the modules always have the exact same name (first column from lsmod
output) as the filesystem name (last column in /proc/filesystems
)?
Is there perhaps a more modern way such as /sys
instead of /proc
to look for info?
My current approach is as follows. Can someone confirm that it is correct, or advise how to do it instead?:
for fscand in $(awk '{print $NF}' /proc/filesystems)
do
if test $(lsmod | grep -c -e '^'${fscand}'[^a-z0-9_-]') -eq 0
then
candlist="${fscand} ${candlist}"
fi
done
for fscand in $candlist
do
echo $fscand is compiled-in
done
Best Answer
No:
Many of these are not built into the kernel on that system.
autofs
is provided by a modules calledautofs4
whilenfs4
is provided by a module callednfs
. Theext4
module providesext2
andext3
as well asext4
;fuse
provides bothfuseblk
andfusectl
.rpc_pipefs
(not to be confused withpipefs
) is provided bysunrpc
.Yet your system is able to load a module for a filesystem on demand: when you run
mount -t foo …
, iffoo
isn't a supported filesystem type, Linux attempts to load a module that provides this filesystem. The way this works is that the kernel detects thatfoo
isn't a supported filesystem, and it callsmodprobe
to load a module calledfs-foo
. The mechanism is similar topci:…
aliases to load the driver for a PCI hardware peripheral by its PCI ID andusb:…
which is similar to USB — see How to assign USB driver to device and Debian does not detect serial PCI card after reboot for more explanations. Thefs-…
module aliases are recorded in/lib/$(uname -r)/modules.alias
. This file is generated when you build the kernel.Under normal conditions, you can use this to determine which filesystems are provided by modules. By elimintation, the filesystems that are not provided by modules are built into the kernel. There are rare edge cases where this approach wouldn't work, for example if you've modified or erased your
modules.alias
file, or if a filesystem is provided both by a module and in a compiled-in form. I don't know of a way to cope with these cases short of writing some kernel code and loading it as a module.