How to use findmnt on CentOS 7
To use findmnt on CentOS 7
findmnt is a linux command that will list all mounted filesystems or search for a filesystem. The findmnt command will search in the following directories, /etc/fstab, /etc/fstab.d, /etc/mtab or proc/self/mountinfo. If the given search filesystem is not found, all the existing filesystems are shown to the user. This tutorial explains the usage of findmnt on CentOS 7.
Usage of findmnt command
List filesystems
To list the filesystems in the target machine, run the following findmnt command without any options, it would simply list out all the mounted filesystems in a tree style layout.
[root@linuxhelp ~]# findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda3 ext4 rw,relatime,data=ordered
??/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime
? ??/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
? ??/sys/fs/cgroup tmpfs tmpfs rw,nosuid,nodev,noexec,mode=755
? ? ??/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd
? ? ??/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuset
? ? ??/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct
? ? ??/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,blkio
? ? ??/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,memory
? ? ??/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,devices
? ? ??/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,freezer
? ? ??/sys/fs/cgroup/net_cls,net_prio cgroup cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio
? ? ??/sys/fs/cgroup/perf_event cgroup cgroup rw,nosuid,nodev,noexec,relatime,perf_event
? ? ??/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec,relatime,hugetlb
? ??/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec,relatime
? ??/sys/kernel/debug debugfs debugfs rw,relatime
? ? ??/sys/kernel/debug/tracing tracefs tracefs rw,relatime
? ??/sys/fs/fuse/connections fusectl fusectl rw,relatime
??/proc proc proc rw,nosuid,nodev,noexec,relatime
? ??/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=27,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
??/dev devtmpfs devtmpfs rw,nosuid,size=768104k,nr_inodes=192026,mode=755
? ??/dev/shm tmpfs tmpfs rw,nosuid,nodev
? ??/dev/pts devpts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
? ??/dev/mqueue mqueue mqueue rw,relatime
? ??/dev/hugepages hugetlbfs hugetlbfs rw,relatime
??/run tmpfs tmpfs rw,nosuid,nodev,mode=755
? ??/run/user/1000/gvfs gvfsd-fuse fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=100
??/boot /dev/sda2 ext4 rw,relatime,data=ordered
List style output format
Next, to view the output in list format, execute the following command. The filesystem is listed in the following order.
[root@linuxhelp ~]# findmnt -l
TARGET SOURCE FSTYPE OPTIONS
/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime
/proc proc proc rw,nosuid,nodev,noexec,relatime
/dev devtmpfs devtmpfs rw,nosuid,size=768104k,nr_inodes=192026,mode=755
/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
/dev/shm tmpfs tmpfs rw,nosuid,nodev
/dev/pts devpts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
/run tmpfs tmpfs rw,nosuid,nodev,mode=755
/sys/fs/cgroup tmpfs tmpfs rw,nosuid,nodev,noexec,mode=755
/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd
/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec,relatime
/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuset
/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct
/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,blkio
/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,memory
/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,devices
/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,freezer
/sys/fs/cgroup/net_cls,net_prio cgroup cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio
/sys/fs/cgroup/perf_event cgroup cgroup rw,nosuid,nodev,noexec,relatime,perf_event
/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec,relatime,hugetlb
/ /dev/sda3 ext4 rw,relatime,data=ordered
/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=27,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
/dev/mqueue mqueue mqueue rw,relatime
/dev/hugepages hugetlbfs hugetlbfs rw,relatime
/sys/kernel/debug debugfs debugfs rw,relatime
/boot /dev/sda2 ext4 rw,relatime,data=ordered
/sys/fs/fuse/connections fusectl fusectl rw,relatime
/run/user/1000/gvfs gvfsd-fuse fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=100
/sys/kernel/debug/tracing tracefs tracefs rw,relatime
df style output format
The findmnt can produce a df style output that reports free and used disk space with the " -D" or " --df" option.
[root@linuxhelp ~]# findmnt -D
SOURCE FSTYPE SIZE USED AVAIL USE% TARGET
devtmpfs devtmpfs 750.1M 0 750.1M 0% /dev
tmpfs tmpfs 755.6M 172K 755.4M 0% /dev/shm
tmpfs tmpfs 755.6M 2.1M 753.5M 0% /run
tmpfs tmpfs 755.6M 0 755.6M 0% /sys/fs/cgroup
/dev/sda3 ext4 17.1G 5.3G 10.9G 31% /
/dev/sda2 ext4 478.2M 53.4M 395.7M 11% /boot
gvfsd-fuse fuse.gvfsd-fuse 0 0 0 - /run/user/1000/gvfs
tracefs tracefs 0 0 0 - /sys/kernel/debug/tracing
Read filesystems from fstab
With the ' -s' or ' --fstab' option, findmnt will read filesystems only from the /etc/fstab file and /etc/fstab.d directory.
[root@linuxhelp ~]# findmnt -s
TARGET SOURCE FSTYPE OPTIONS
swap UUID=cda4ad98-7d97-40e1-8269-48978acfd4ee swap defaults
/ UUID=d615b88e-7e76-4cc1-b0a2-08d405d39af7 ext4 acl,user_xattr
/boot UUID=8f597409-b13d-4998-8f79-919a7f6372ae ext4 acl,user_xatt
Filter filesystems by type
The findmnt command can be viewed by mentioning the specific filesystems based on the type of file. Multiple system types can be specified separated by a comma. Execute the following command to view the filesystems by type.
[root@linuxhelp ~]# findmnt -t ext4
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda3 ext4 rw,relatime,data=ordered
??/boot /dev/sda2 ext4 rw,relatime,data=ordered
Raw output
To view the output in raw style, run the following command and use the ' -r' or ' --raw' option.
[root@linuxhelp ~]# findmnt --raw
TARGET SOURCE FSTYPE OPTIONS
/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime
/proc proc proc rw,nosuid,nodev,noexec,relatime
/dev devtmpfs devtmpfs rw,nosuid,size=768104k,nr_inodes=192026,mode=755
/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
/dev/shm tmpfs tmpfs rw,nosuid,nodev
/dev/pts devpts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
/run tmpfs tmpfs rw,nosuid,nodev,mode=755
/sys/fs/cgroup tmpfs tmpfs rw,nosuid,nodev,noexec,mode=755
/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd
/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec,relatime
/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuset
/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct
/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,blkio
/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,memory
/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,devices
/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,freezer
/sys/fs/cgroup/net_cls,net_prio cgroup cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio
/sys/fs/cgroup/perf_event cgroup cgroup rw,nosuid,nodev,noexec,relatime,perf_event
/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec,relatime,hugetlb
/ /dev/sda3 ext4 rw,relatime,data=ordered
/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=27,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
/dev/mqueue mqueue mqueue rw,relatime
/dev/hugepages hugetlbfs hugetlbfs rw,relatime
/sys/kernel/debug debugfs debugfs rw,relatime
/boot /dev/sda2 ext4 rw,relatime,data=ordered
/sys/fs/fuse/connections fusectl fusectl rw,relatime
/run/user/1000/gvfs gvfsd-fuse fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=100
/sys/kernel/debug/tracing tracefs tracefs rw,relatime
Search by source device
To find the filesystem by the source device, specify the device path with or without the ' -S' option.
[root@linuxhelp ~]# findmnt -S /dev/sda2
TARGET SOURCE FSTYPE OPTIONS
/boot /dev/sda2 ext4 rw,relatime,data=ordered
Search by mount point
To search filesystem by the mount directory , specify the directory with or without the ' -T' /' --target' option.
[root@linuxhelp ~]# findmnt -T /dev/ /dev/hugepages /dev/mqueue /dev/pts /dev/shm [root@linuxhelp ~]# findmnt -T /dev/ /dev/hugepages /dev/mqueue /dev/pts /dev/shm [root@linuxhelp ~]# findmnt -T /dev/shm TARGET SOURCE FSTYPE OPTIONS /dev/shm tmpfs tmpfs rw,nosuid,nodev
Thus we conclude the usage of findmnt command on CentOS 7.
Comments ( 0 )
No comments available