#Bash 的 mountpoint 命令
mountpoint [OPTION]... FILE
功能
判断文件是否是挂载点。
类型
可执行文件(/usr/bin/mountpoint),属于 util-linux。
参数
OPTION选项:-d,--fs-devno- 查看挂载点对应设备的主设备号:次设备号-q,--quiet- 不打印任何内容,仅通过返回值返回--nofollow- 检测符号链接本身,而非其链接的文件-x,--devno- 判断文件是否是块设备,如果是则查看该块设备的主设备号:次设备号-h,--help- 显示帮助-V,--version- 显示版本
FILE- 要判断的文件
返回值
- 0 - 是挂载点(或块设备)
- 1 - 调用失败
- 32 - 不是挂载点(或块设备)
#示例
$ mountpoint / # 查看 / 是否是挂载点
/ is a mountpoint
$ mountpoint /home # 查看 /home 是否是挂载点
/home is not a mountpoint
$ mountpoint /run # 查看 /run 是否是挂载点
/run is a mountpoint
$ mountpoint /dev/nvme0n1p1 # 查看 /dev/nvme0n1p1 是否是挂载点
/dev/nvme0n1p1 is not a mountpoint
$ mountpoint /dev/nvme0n1p1 -x # 查看 /dev/nvme0n1p1 是否是块设备,打印设备号
259:1
#推荐阅读
#手册
MOUNTPOINT(1) User Commands MOUNTPOINT(1)
NAME
mountpoint - see if a directory or file is a mountpoint
SYNOPSIS
mountpoint [-d|-q] directory|file
mountpoint -x device
DESCRIPTION
mountpoint checks whether the given directory or file is mentioned in
the /proc/self/mountinfo file.
OPTIONS
-d, --fs-devno
Show the major/minor numbers of the device that is mounted on the
given directory.
-q, --quiet
Be quiet - don’t print anything.
--nofollow
Do not follow symbolic link if it the last element of the directory
path.
-x, --devno
Show the major/minor numbers of the given blockdevice on standard
output.
-h, --help
Display help text and exit.
-V, --version
Print version and exit.
EXIT STATUS
mountpoint has the following exit status values:
0
success; the directory is a mountpoint, or device is block device
on --devno
1
failure; incorrect invocation, permissions or system error
32
failure; the directory is not a mountpoint, or device is not a
block device on --devno
ENVIRONMENT
LIBMOUNT_DEBUG=all
enables libmount debug output.
NOTES
The util-linux mountpoint implementation was written from scratch for
libmount. The original version for sysvinit suite was written by Miquel
van Smoorenburg.
AUTHORS
Karel Zak <kzak@redhat.com>
SEE ALSO
mount(8)
REPORTING BUGS
For bug reports, use the issue tracker at
https://github.com/util-linux/util-linux/issues.
AVAILABILITY
The mountpoint command is part of the util-linux package which can be
downloaded from Linux Kernel Archive
<https://www.kernel.org/pub/linux/utils/util-linux/>.
util-linux 2.39.3 2023-10-23 MOUNTPOINT(1)