27
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ディレクトリがマウントされているかを確認する

Posted at

例えば自動化スクリプト内でSDカードが正常にマウントされているかのチェックをしたい場合などに使える。

特定のディレクトリがマウント済みであるかを確認するには mountpoint コマンドを使えば良い。

# 通常ディレクトリの場合(マウントされていない)
$ mountpoint /tmp/
/tmp/ is not a mountpoint
$ echo $?
1

# マウントされているディレクトリの場合
$ mountpoint /media/sf_temp/
/media/sf_temp/ is a mountpoint
$ echo $?
0

エラーメッセージを抑制したい場合は -q オプションを使う

$ mountpoint -q /media/sf_temp/
$ echo $?
0

# 参考
mountpoint(1) - Linux manual page

27
23
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?