2

I recently learned that you can mount two different types of filesystems: logical filesystems and physical filesystems.

From my understanding, physical filesystems are the hardware are located on disks that are physically connected to the machine.

Whereas logical filesystems exist somewhere remotely and are mounted through a network.

A day ago, I ssh into a server and ran the command mount | wc -l and got the answer 17. Today I did the same command and got 70. I am guessing mount lists both physical and logically mounted filesystems.

Is there a way that I can count the number of just the physical file systems that are mounted? Preferably with a short command?

  • 1
    The distinction you are making can mislead you. NFS mounts set up as hard, nointr behave very much like a local filesystem. Autofs and FUSE can be very schroedinger. Then there are AoE and iSCSI. Try a linux md or lvm device made of a mix of nbd and local devices for an industrial grade hd fk. – rackandboneman Apr 8 '18 at 0:49
6

“Logical” file systems aren’t necessarily mounted over the network; for example on your system with 70 mounted file systems, it’s likely most of those were file systems corresponding to kernel features rather than network file systems. Logical file systems include sysfs, proc, all the cgroup file systems, tmpfs, devtmpfs, etc., which are all “local” file systems.

“Non-physical” file systems are identified by the kernel in /proc/filesystems using nodev, so you can use that to list “physical” file systems only, using findmnt:

findmnt -t $(grep -v nodev /proc/filesystems | paste -sd, - | tr -d \\t)

To count the file systems, drop the header and feed the output to wc -l:

findmnt -n -t $(grep -v nodev /proc/filesystems | paste -sd, - | tr -d \\t) | wc -l

It is possible to mount such file system types from image files and other non-device files, even remote block devices over the network; however this approach will give you good results on most systems.

Another approach is to start from the disk devices themselves, using lsblk; lsblk -f will output the tree of physical devices through however many layers are required to reach actual mounted file systems. You can combine that with the above information about physical file systems to list only file systems which match a block device on the system:

lsblk -f | grep -F -f <(grep -v nodev /proc/filesystems | tr -d \\t)

Counting that gives the desired result:

lsblk -f | grep -F -f <(grep -v nodev /proc/filesystems | tr -d \\t) | wc -l

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.