How to get the complete and exact list of mounted filesystems in Linux?
The definitive list of mounted filesystems is in /proc/mounts
.
If you have any form of containers on your system, /proc/mounts
only lists the filesystems that are in your present container. For example, in a chroot, /proc/mounts
lists only the filesystems whose mount point is within the chroot. (There are ways to escape the chroot, mind.)
There's also a list of mounted filesystems in /etc/mtab
. This list is maintained by the mount
and umount
commands. That means that if you don't use these commands (which is pretty rare), your action (mount or unmount) won't be recorded. In practice, it's mostly in a chroot that you'll find /etc/mtab
files that differ wildly from the state of the system. Also, mounts performed in the chroot will be reflected in the chroot's /etc/mtab
but not in the main /etc/mtab
. Actions performed while /etc/mtab
is on a read-only filesystem are also not recorded there.
The reason why you'd sometimes want to consult /etc/mtab
in preference to or in addition to /proc/mounts
is that because it has access to the mount command line, it's sometimes able to present information in a way that's easier to understand; for example you see mount options as requested (whereas /proc/mounts
lists the mount
and kernel defaults as well), and bind mounts appear as such in /etc/mtab
.
As of v. 2.18 (July 2010) util-linux
includes a tool that allows you to display a list of currently mounted file systems:
findmnt
You can switch from the default tree view to list view with -l
, define output columns with -o
(similar to lsblk
), filter results based on filesystem type with -t
etc...
findmnt -lo source,target,fstype,label,options,used -t ext4
SOURCE TARGET FSTYPE LABEL OPTIONS USED
/dev/sda1 / ext4 ARCH rw,noatime,discard,data=ordered 17.6G
/dev/sdb2 /media/DATA ext4 DATA rw,noatime,discard,data=ordered 44M
For more details read the man
page (and findmnt --help
to get the list of available columns)
Maybe because it has been 5 years since this question was answered things have changed. The cat /proc/mounts
creates a lot of info you do not care about. Today, IMHO, I find this to be the ultimate solution.
df -h --output=source,target
when you read the man pages there are all kinds of options you can do but this is what you what. For example to clean up the results even more you can exclude file types of "tmpfs" with this command:
df -hx tmpfs --output=source,target
df
works on the filesystem level and not the file level.
The commands above will include network mounts as well.
To see a little more information use this:
df -hT
NOTE With slow mounted network connections this can take several minutes!
If you don't have or care about mounted network connections (and you have root permissions) than this is even better:
sudo lsblk -f