- How to get the complete and exact list of mounted filesystems in Linux?
- 5 Answers 5
- How do I see all mounts in Linux?
- See mount points using findmnt:
- As you can see in the output, there are 4 columns:
- Show mount points using cat:
- See mount points using the mount command:
- Show mount points using df (Disk Free):
- What happens when we mount or unmount a device in Linux?
- Conclusion:
- About the author
- David Adams
- How to show mounted devices in Linux?
- Using /proc/mounts or /proc/self/mounts files or /etc/mtab
- ZIADI Mohamed Ali
- Latest posts by ZIADI Mohamed Ali (see all)
How to get the complete and exact list of mounted filesystems in Linux?
I usually use mount to check which filesystems are mounted. I also know there is some connection between mount and /etc/mtab but I’m not sure about the details. After reading How to check if /proc/ is mounted I get more confused. My question is: How to get the most precise list of mounted filesystems? Should I just use mount , or read the contents of /etc/mtab , or contents of /proc/mounts ? What would give the most trustworthy result?
I can’t help linking to What is /etc/mtab in Linux? because it covers non-Linux details that none of the answers here give.
5 Answers 5
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 .
How do I see all mounts in Linux?
I was asked how to see all mount points in Linux. Even though I always did it for myself using the mount command, I was surprised when I found there was no more human-friendly way I could explain. Thus I decided to write a tutorial that includes different techniques to achieve it.
While running commands to get mount points information is pretty easy, dealing with the output may not be comfortable for some users. After reading this tutorial, you’ll know how to get different outputs through different available commands: cat, findmnt, mount and df. Yet no format is really human friendly.
See mount points using findmnt:
The command findmnt lists all mount points. To do this the findmnt reads files /etc/fstab, /etc/fstab.d, /etc/mtab or /proc/self/mountinfo.
To run it, simply just the command below.
As you can see in the output, there are 4 columns:
- TARGET: This column shows the mount point.
- SOURCE: In this column, you can see the mounted device.
- FSTYPE: Here is described the file system.
- OPTIONS: This column shows mount point options, such as Read-Only or Writable.
You can get additional information on findmnt at https://linux.die.net/man/8/findmnt.
Show mount points using cat:
The most accurate technique to see mount points in Linux is reading the /proc/mounts file using cat. This is also the less human-friendly way, with the worse visual output.
The advantage of this method is that the kernel directly provides the information to see mount points over more human-friendly ways as alternatives explained in this tutorial
To see all mount points using cat, run the command as shown below.
As you can see, the output isn’t user friendly, but it is considered the most accurate method to check mounted devices in Linux.
See mount points using the mount command:
The mount is probably the most known command explained in this tutorial. Once we needed to run it every time we wanted to mount a device, it wasn’t automatic like today. By running it, you’ll get an output with all mounted filesystems. If followed by the -l flag, it will also show the mount point name; the output is similar to the mount command without flags.
As you can see, in the last two lines, there is a mounted pen drive containing a Kali Linux distribution.
Show mount points using df (Disk Free):
The df (Disk Free) command is also useful to print all mount points. The df command is mainly used to show available and used space on all storage devices.
To get an output with all mount points using df, just run it without additional options, as shown below.
Again you can see in the last line the /dev/sdb1 storage device is mounted.
This output displays 4 columns:
- Filesystem: This column shows the filesystem.
- 1K-Blocks: Here, you can see the size.
- Used: This column shows used space (in 1K blocks).
- Available: Available used space (in 1K blocks).
- Use%: Percentage of used space
- Mounted on: Mount point.
You can get more information on df at Linux Commands for Disk Space.
What happens when we mount or unmount a device in Linux?
When you mount a filesystem, like a cd, or a hard disk or USB stick, you create a mount point within your system. This mount point means virtually storing the cd, hard disk or USB stick’s content within your system. The files are not really stored in your system’s storage, but the system makes them accessible from itself by importing them under its filesystem hierarchy.
When you unmount a device, do exactly the opposite and instruct the system to stop providing mount points for external files.
Today mounting devices isn’t a common task since more user-friendly Linux distributions took over the market. Once, users needed to mount every external device manually, specifying the external device path and filesystem.
Conclusion:
As you can see, seeing all mounts in Linux is pretty easy. Linux offers you a variety of techniques to achieve this task by just running a command. As highlighted in the tutorial, the cat method is the most accurate and less human-friendly.
Other tools like findmnt feature a little improvement in the format, making it more user-friendly. Mounting, unmounting, and checking mount points status is a basic knowledge any Linux user-level must hold. Some Unix-like Linux distributions like Slackware don’t include automount enabled by default.
Thank you for reading this tutorial explaining how to see all mounts in Linux. Keep following Linux Hint for more Linux tips and tutorials.
About the author
David Adams
David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.
How to show mounted devices in Linux?
mount have many exciting options (see man mount). In our case, we will only use -l which adds the labels in the mount output.
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) devtmpfs on /dev type devtmpfs (rw,nosuid,size=979900k,nr_inodes=244975,mode=755) securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000) tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755) tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd) pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime) cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset) cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices) cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer) cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory) cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event) cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio) cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb) cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls) cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu) configfs on /sys/kernel/config type configfs (rw,relatime) /dev/vda1 on / type xfs (rw,relatime,attr2,inode64,noquota) rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime) hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime) debugfs on /sys/kernel/debug type debugfs (rw,relatime) systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=32,pgrp=1,timeout=300,minproto=5,maxproto=5,direct) mqueue on /dev/mqueue type mqueue (rw,relatime) nfsd on /proc/fs/nfsd type nfsd (rw,relatime) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime) tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=199984k,mode=700)
Using /proc/mounts or /proc/self/mounts files or /etc/mtab
root@server:~ # cat /proc/mounts
root@server:~ # cat /proc/self/mounts
rootfs / rootfs rw 0 0 sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 devtmpfs /dev devtmpfs rw,nosuid,size=979900k,nr_inodes=244975,mode=755 0 0 securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0 tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0 devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0 tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0 cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0 pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0 cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0 cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0 cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0 cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0 cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0 cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0 cgroup /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0 cgroup /sys/fs/cgroup/net_cls cgroup rw,nosuid,nodev,noexec,relatime,net_cls 0 0 cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpuacct,cpu 0 0 configfs /sys/kernel/config configfs rw,relatime 0 0 /dev/vda1 / xfs rw,relatime,attr2,inode64,noquota 0 0 rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0 hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0 debugfs /sys/kernel/debug debugfs rw,relatime 0 0 systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=32,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0 mqueue /dev/mqueue mqueue rw,relatime 0 0 nfsd /proc/fs/nfsd nfsd rw,relatime 0 0 binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0 tmpfs /run/user/0 tmpfs rw,nosuid,nodev,relatime,size=199984k,mode=700 0 0
I hope that this blog helped you. Please visit our website for other interesting blogs and feel free to leave your feedbacks and thoughts. Till next time!
ZIADI Mohamed Ali
I am a hands-on, competent Linux system engineer with 9 years’ experience. I have a strong performance background in wide variety of professional Linux system support including monitoring, configuration, troubleshooting and maintenance. I have worked on numerous projects from concept to completion. A specialist in LAMP platforms, I take pride in administrating Linux systems and regularly refresh my skills to ensure I keep up with ongoing developments and new technologies.
Latest posts by ZIADI Mohamed Ali (see all)
- How to show mounted devices in Linux? — July 25, 2017
- How to use Positional parameters and special variables in Linux — June 28, 2017
- Linux: Connect to your WiFi network through CLI? — June 25, 2017
- How to find a file in Linux? — March 19, 2017
- Mysql: How to find table and database size? — January 9, 2017