このチュートリアルでは、Linuxにマウントされたドライブを一覧表示するさまざまな方法を紹介します。 mount、findmnt、およびdfコマンドを使用して、マウントされたデバイスをUbuntuやCentosなどのLinuxディストリビューションで一覧表示できます。
Linuxでは、 mount command
ストレージデバイスまたはファイルシステムをマウントし、それらすべてのマウントを表示できるコマンドを実行してみましょう。
1)catコマンドを使用した/ procからのリスト
マウントポイントを一覧表示するには、ファイル/ proc / mountsの内容を読み取ることができます。
以下では example、catコマンドを使用して /proc/mounts
ファイル:
$ cat /proc/mounts
出力:
$ cat /proc/mounts
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=101468k,mode=755 0 0
/dev/xvda1 / ext4 rw,relatime,discard,data=ordered 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
lxcfs /var/lib/lxcfs fuse.lxcfs rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
tracefs /sys/kernel/debug/tracing tracefs rw,relatime 0 0
tmpfs /run/user/76547979 tmpfs rw,nosuid,nodev,relatime,size=101468k,mode=700,uid=76547979,gid=76546561 0 0
~$ cat /proc/self/mounts
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=101468k,mode=755 0 0
/dev/xvda1 / ext4 rw,relatime,discard,data=ordered 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
lxcfs /var/lib/lxcfs fuse.lxcfs rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
tracefs /sys/kernel/debug/tracing tracefs rw,relatime 0 0
tmpfs /run/user/76547979 tmpfs rw,nosuid,nodev,relatime,size=101468k,mode=700,uid=76547979,gid=76546561 0 0
2)マウントコマンドの使用
マウントコマンドを使用して、マウントポイントを一覧表示できます。 オプションなしでmountコマンドを実行すると、マウントポイントが一覧表示されます。
$ mount
サンプル出力
~$ mount
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=101468k,mode=755)
/dev/xvda1 on / type ext4 (rw,relatime,discard,data=ordered)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
lxcfs on /var/lib/lxcfs type fuse.lxcfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)
tracefs on /sys/kernel/debug/tracing type tracefs (rw,relatime)
tmpfs on /run/user/76547979 type tmpfs (rw,nosuid,nodev,relatime,size=101468k,mode=700,uid=76547979,gid=76546561)
You may also use mount -l command which will list all mounted filesystem with labels.
$ mount -l
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=101468k,mode=755)
/dev/xvda1 on / type ext4 (rw,relatime,discard,data=ordered) [cloudimg-rootfs]
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=27,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
lxcfs on /var/lib/lxcfs type fuse.lxcfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)
tracefs on /sys/kernel/debug/tracing type tracefs (rw,relatime)
tmpfs on /run/user/76547979 type tmpfs (rw,nosuid,nodev,relatime,size=101468k,mode=700,uid=76547979,gid=76546561)
3)dfコマンドを使用する
dfコマンドを使用して、マウントポイントを一覧表示できます。
次のコマンドは、 df
と -aTh
オプション:
$ df -aTh
Filesystem Type Size Used Avail Use% Mounted on
sysfs sysfs 0 0 0 - /sys
proc proc 0 0 0 - /proc
udev devtmpfs 488M 0 488M 0% /dev
devpts devpts 0 0 0 - /dev/pts
tmpfs tmpfs 100M 11M 89M 11% /run
/dev/xvda1 ext4 7.7G 3.1G 4.7G 40% /
securityfs securityfs 0 0 0 - /sys/kernel/security
tmpfs tmpfs 496M 0 496M 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 496M 0 496M 0% /sys/fs/cgroup
cgroup cgroup 0 0 0 - /sys/fs/cgroup/systemd
pstore pstore 0 0 0 - /sys/fs/pstore
cgroup cgroup 0 0 0 - /sys/fs/cgroup/pids
cgroup cgroup 0 0 0 - /sys/fs/cgroup/net_cls,net_prio
cgroup cgroup 0 0 0 - /sys/fs/cgroup/cpu,cpuacct
cgroup cgroup 0 0 0 - /sys/fs/cgroup/cpuset
cgroup cgroup 0 0 0 - /sys/fs/cgroup/freezer
cgroup cgroup 0 0 0 - /sys/fs/cgroup/hugetlb
cgroup cgroup 0 0 0 - /sys/fs/cgroup/blkio
cgroup cgroup 0 0 0 - /sys/fs/cgroup/memory
cgroup cgroup 0 0 0 - /sys/fs/cgroup/perf_event
cgroup cgroup 0 0 0 - /sys/fs/cgroup/devices
systemd-1 - - - - - /proc/sys/fs/binfmt_misc
debugfs debugfs 0 0 0 - /sys/kernel/debug
mqueue mqueue 0 0 0 - /dev/mqueue
hugetlbfs hugetlbfs 0 0 0 - /dev/hugepages
fusectl fusectl 0 0 0 - /sys/fs/fuse/connections
lxcfs fuse.lxcfs 0 0 0 - /var/lib/lxcfs
binfmt_misc binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
tracefs - - - - - /sys/kernel/debug/tracing
tmpfs tmpfs 100M 0 100M 0% /run/user/76547979
使用できます -t
続いてファイルシステムタイプ(ext3、ext4、nfsなど)を入力して、それぞれのマウントポイントを表示します。 以下の例では、dfコマンドですべてのNFSマウントポイントを表示します。
# df -HP -t nfs
4)findmntを使用する
Findmntは、マウントされたファイルシステムを見つけるための強力なツールです。 このコマンドには、マウントファイルシステムを一覧表示するための多くのオプションが付属しています。
次のコマンドは、マウントされているすべてのファイルシステムを出力します。
$ findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /dev/xvda1 ext4 rw,relatime,discard,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/pids cgroup cgroup rw,nosuid,nodev,noexec,relatime,pids
│ │ ├─/sys/fs/cgroup/net_cls,net_prio cgroup cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio
│ │ ├─/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct
│ │ ├─/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuset
│ │ ├─/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,freezer
│ │ ├─/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec,relatime,hugetlb
│ │ ├─/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/perf_event cgroup cgroup rw,nosuid,nodev,noexec,relatime,perf_event
│ │ └─/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,devices
│ ├─/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=0,minproto=5,maxproto=5,direct
│ └─/proc/sys/fs/binfmt_misc binfmt_misc binfmt_misc rw,relatime
├─/dev udev devtmpfs rw,nosuid,relatime,size=499356k,nr_inodes=124839,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=101468k,mode=755
│ ├─/run/lock tmpfs tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k
│ └─/run/user/76547979 tmpfs tmpfs rw,nosuid,nodev,relatime,size=101468k,mode=700,uid=76547979,gid=76546561
└─/var/lib/lxcfs lxcfs fuse.lxcfs rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other
特定のファイルシステムタイプごとにマウントポイントを出力します。
$ findmnt -t ext4
TARGET SOURCE FSTYPE OPTIONS
/ /dev/xvda1 ext4 rw,relatime,discard,data=ordered
fstabの内容を検索して一覧表示します。
$ findmnt -s
すべての/ etc / fstabファイルを表示し、LABEL =およびUUID =タグを実際のデバイス名に変換します。
$ findmnt --fstab --evaluate
結論
このチュートリアルでは、Linuxにマウントされたドライブまたはファイルシステムを一覧表示するコマンドを学習しました。 読んで楽しんでいただければ幸いです。コメント欄に提案を残してください。