Categories
Uncategorized

How to determine what is mounted and where

Determine what filesystem is mounted where, what is using particular options and how much free space is available.

Display all filesystems.

$ findmnt --all
TARGET                                SOURCE     FSTYPE     OPTIONS
/                                     /dev/vda1  ext4       rw,relatime,errors=remount-ro,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      ro,nosuid,nodev,noexec,mode=755
│ │ ├─/sys/fs/cgroup/systemd          cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd
│ │ ├─/sys/fs/cgroup/cpu,cpuacct      cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,cpu,cpuacct
│ │ ├─/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/cpuset           cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,cpuset
│ │ ├─/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/blkio            cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,blkio
│ │ ├─/sys/fs/cgroup/perf_event       cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,perf_event
│ │ └─/sys/fs/cgroup/pids             cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,pids
│ ├─/sys/fs/pstore                    pstore     pstore     rw,nosuid,nodev,noexec,relatime
│ └─/sys/kernel/debug                 debugfs    debugfs    rw,relatime
├─/proc                               proc       proc       rw,nosuid,nodev,noexec,relatime
│ └─/proc/sys/fs/binfmt_misc          systemd-1  autofs     rw,relatime,fd=35,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=8942
├─/dev                                udev       devtmpfs   rw,nosuid,relatime,size=499100k,nr_inodes=124775,mode=755
│ ├─/dev/pts                          devpts     devpts     rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
│ ├─/dev/shm                          tmpfs      tmpfs      rw,nosuid,nodev
│ ├─/dev/mqueue                       mqueue     mqueue     rw,relatime
│ └─/dev/hugepages                    hugetlbfs  hugetlbfs  rw,relatime
└─/run                                tmpfs      tmpfs      rw,nosuid,noexec,relatime,size=102040k,mode=755
  ├─/run/lock                         tmpfs      tmpfs      rw,nosuid,nodev,noexec,relatime,size=5120k
  └─/run/user/1000                    tmpfs      tmpfs      rw,nosuid,nodev,relatime,size=102036k,mode=700,uid=1000,gid=1000

Display static filesystem information defined in fstab file.

$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/vda1 during installation
UUID=9d749b55-a024-4d89-b1c0-950bd38b98d8 /               ext4    errors=remount-ro 0       1
# swap was on /dev/vda5 during installation
UUID=33d7420a-1ab7-4872-8944-369c37354d1b none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0

Display static filesystem information.

$ findmnt --fstab
TARGET        SOURCE                                    FSTYPE      OPTIONS
/             UUID=9d749b55-a024-4d89-b1c0-950bd38b98d8 ext4        errors=remount-ro
none          UUID=33d7420a-1ab7-4872-8944-369c37354d1b swap        sw
/media/cdrom0 /dev/sr0                                  udf,iso9660 user,noauto

Display static filesystem information for ext4 filesystem type.

$ findmnt --fstab --type ext4
TARGET SOURCE                                    FSTYPE OPTIONS
/      UUID=9d749b55-a024-4d89-b1c0-950bd38b98d8 ext4   errors=remount-ro

Display mounted filesystem information.

$ findmnt --mtab
TARGET                          SOURCE     FSTYPE     OPTIONS
/sys                            sysfs      sysfs      rw,nosuid,nodev,noexec,relatime
/proc                           proc       proc       rw,nosuid,nodev,noexec,relatime
/dev                            udev       devtmpfs   rw,nosuid,relatime,size=499100k,nr_inodes=124775,mode=755
/dev/pts                        devpts     devpts     rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
/run                            tmpfs      tmpfs      rw,nosuid,noexec,relatime,size=102040k,mode=755
/                               /dev/vda1  ext4       rw,relatime,errors=remount-ro,data=ordered
/sys/kernel/security            securityfs securityfs rw,nosuid,nodev,noexec,relatime
/dev/shm                        tmpfs      tmpfs      rw,nosuid,nodev
/run/lock                       tmpfs      tmpfs      rw,nosuid,nodev,noexec,relatime,size=5120k
/sys/fs/cgroup                  tmpfs      tmpfs      ro,nosuid,nodev,noexec,mode=755
/sys/fs/cgroup/systemd          cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd
/sys/fs/pstore                  pstore     pstore     rw,nosuid,nodev,noexec,relatime
/sys/fs/cgroup/cpu,cpuacct      cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,cpu,cpuacct
/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/cpuset           cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,cpuset
/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/blkio            cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,blkio
/sys/fs/cgroup/perf_event       cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,perf_event
/sys/fs/cgroup/pids             cgroup     cgroup     rw,nosuid,nodev,noexec,relatime,pids
/proc/sys/fs/binfmt_misc        systemd-1  autofs     rw,relatime,fd=35,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=8942
/dev/mqueue                     mqueue     mqueue     rw,relatime
/dev/hugepages                  hugetlbfs  hugetlbfs  rw,relatime
/sys/kernel/debug               debugfs    debugfs    rw,relatime
/run/user/1000                  tmpfs      tmpfs      rw,nosuid,nodev,relatime,size=102036k,mode=700,uid=1000,gid=1000

Display mounted filesystem information for ext4 filesystem type and show available space.

$ findmnt --mtab --type ext4 --df
SOURCE    FSTYPE  SIZE   USED AVAIL USE% TARGET
/dev/vda1 ext4   18.6G 936.8M 16.7G   5% /

Display mounted filesystem information for /dev/vda1 device.

$ findmnt --kernel --source /dev/vda1
TARGET SOURCE    FSTYPE OPTIONS
/      /dev/vda1 ext4   rw,relatime,errors=remount-ro,data=ordered

Notice, –kernel options does not need to be specified as it is used by default (proc filesystem).

$ cat /proc/self/mountinfo
16 21 0:16 / /sys rw,nosuid,nodev,noexec,relatime shared:7 - sysfs sysfs rw
17 21 0:4 / /proc rw,nosuid,nodev,noexec,relatime shared:12 - proc proc rw
18 21 0:6 / /dev rw,nosuid,relatime shared:2 - devtmpfs udev rw,size=499100k,nr_inodes=124775,mode=755
19 18 0:17 / /dev/pts rw,nosuid,noexec,relatime shared:3 - devpts devpts rw,gid=5,mode=620,ptmxmode=000
20 21 0:18 / /run rw,nosuid,noexec,relatime shared:5 - tmpfs tmpfs rw,size=102040k,mode=755
21 0 254:1 / / rw,relatime shared:1 - ext4 /dev/vda1 rw,errors=remount-ro,data=ordered
22 16 0:15 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:8 - securityfs securityfs rw
23 18 0:19 / /dev/shm rw,nosuid,nodev shared:4 - tmpfs tmpfs rw
24 20 0:20 / /run/lock rw,nosuid,nodev,noexec,relatime shared:6 - tmpfs tmpfs rw,size=5120k
25 16 0:21 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:9 - tmpfs tmpfs ro,mode=755
26 25 0:22 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:10 - cgroup cgroup rw,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd
27 16 0:23 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:11 - pstore pstore rw
28 25 0:24 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:13 - cgroup cgroup rw,cpu,cpuacct
29 25 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:14 - cgroup cgroup rw,freezer
30 25 0:26 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,net_cls,net_prio
31 25 0:27 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,cpuset
32 25 0:28 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,memory
33 25 0:29 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,devices
34 25 0:30 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,blkio
35 25 0:31 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:20 - cgroup cgroup rw,perf_event
36 25 0:32 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:21 - cgroup cgroup rw,pids
37 17 0:33 / /proc/sys/fs/binfmt_misc rw,relatime shared:22 - autofs systemd-1 rw,fd=35,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=8942
38 18 0:14 / /dev/mqueue rw,relatime shared:23 - mqueue mqueue rw
39 18 0:34 / /dev/hugepages rw,relatime shared:24 - hugetlbfs hugetlbfs rw
40 16 0:7 / /sys/kernel/debug rw,relatime shared:25 - debugfs debugfs rw
115 20 0:38 / /run/user/1000 rw,nosuid,nodev,relatime shared:71 - tmpfs tmpfs rw,size=102036k,mode=700,uid=1000,gid=1000

Display mounted filesystems information mounted under /dev directory.

$ findmnt --submounts --target /dev
TARGET           SOURCE    FSTYPE    OPTIONS
/dev             udev      devtmpfs  rw,nosuid,relatime,size=499100k,nr_inodes=124775,mode=755
├─/dev/pts       devpts    devpts    rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
├─/dev/shm       tmpfs     tmpfs     rw,nosuid,nodev
├─/dev/mqueue    mqueue    mqueue    rw,relatime
└─/dev/hugepages hugetlbfs hugetlbfs rw,relatime

Display mounted filesystems information using particular options.

$ findmnt --options mode=755,nosuid
TARGET         SOURCE FSTYPE   OPTIONS
/sys/fs/cgroup tmpfs  tmpfs    ro,nosuid,nodev,noexec,mode=755
/dev           udev   devtmpfs rw,nosuid,relatime,size=499100k,nr_inodes=124775,mode=755
/run           tmpfs  tmpfs    rw,nosuid,noexec,relatime,size=102040k,mode=755

Display mounted filesystem information for ext4 and tmpfs filesystems type and display using JSON format.

$ findmnt --types ext4,tmpfs --json
{
   "filesystems": [
      {"target": "/", "source": "/dev/vda1", "fstype": "ext4", "options": "rw,relatime,errors=remount-ro,data=ordered",
         "children": [
            {"target": "/sys/fs/cgroup", "source": "tmpfs", "fstype": "tmpfs", "options": "ro,nosuid,nodev,noexec,mode=755"},
            {"target": "/dev/shm", "source": "tmpfs", "fstype": "tmpfs", "options": "rw,nosuid,nodev"},
            {"target": "/run", "source": "tmpfs", "fstype": "tmpfs", "options": "rw,nosuid,noexec,relatime,size=102040k,mode=755",
               "children": [
                  {"target": "/run/lock", "source": "tmpfs", "fstype": "tmpfs", "options": "rw,nosuid,nodev,noexec,relatime,size=5120k"},
                  {"target": "/run/user/1000", "source": "tmpfs", "fstype": "tmpfs", "options": "rw,nosuid,nodev,relatime,size=102036k,mode=700,uid=1000,gid=1000"}
               ]
            }
         ]
      }
   ]
}

Display mounted filesystem information for tmpfs filesystems type and display available space using key=”value” format, which is very useful for shell scripting .

$ findmnt --type tmpfs --pairs --df
SOURCE="tmpfs" FSTYPE="tmpfs" SIZE="99.7M" USED="3M" AVAIL="96.7M" USE%="3%" TARGET="/run"
SOURCE="tmpfs" FSTYPE="tmpfs" SIZE="498.2M" USED="0" AVAIL="498.2M" USE%="0%" TARGET="/dev/shm"
SOURCE="tmpfs" FSTYPE="tmpfs" SIZE="5M" USED="0" AVAIL="5M" USE%="0%" TARGET="/run/lock"
SOURCE="tmpfs" FSTYPE="tmpfs" SIZE="498.2M" USED="0" AVAIL="498.2M" USE%="0%" TARGET="/sys/fs/cgroup"
SOURCE="tmpfs" FSTYPE="tmpfs" SIZE="99.7M" USED="0" AVAIL="99.7M" USE%="0%" TARGET="/run/user/1000"

Display static filesystem information, evaluate it and display using raw format without headings.

$ findmnt --fstab --evaluate --raw --noheadings
/ /dev/vda1 ext4 errors=remount-ro
none /dev/vda5 swap sw
/media/cdrom0 /dev/sr0 udf,iso9660 user,noauto