LoginSignup
8
8

More than 5 years have passed since last update.

Linux で Samba をマウント

Posted at

主に自分向け。

はじめに

ローカルのパソコンで開発や動作確認をとるため仮想環境を構築することがあると思う。

そこで、たとえばローカルのファイルをリモートとやり取りすることを検討すると思う。

VirtualBox であれば、 共有フォルダの仕組みがあり使えると思う。

しかし、 client Hyper-V などの共有フォルダの仕組みを提供しない環境を利用する場合困ると思う。

これを mount.cifs を利用し samba でローカルのディレクトリを仮想環境にマウントすることで対応する。

事前準備

  1. ローカルのパソコンの共有したいディレクトリを共有する。 (セキュリティに注意)
  2. cifs-utils をインストールする。

設定

仮想環境で以下のコマンドを叩く。以下は例なので適宜設定を見直すこと。

# mount -t cifs -o credentials=</path/to/samba/.credential>,uid=<uid>,gid=<gid>,file_mode=0777,dir_mode=0777,rw </samba/path> </path/to/mount/target>

なお、 </path/to/samba/.credential> は以下の書式。詳しくは man mount.cifs とすること。

username=<value>
password=<value>
domain=<value>

/etc/fstab の場合

以下の設定を /etc/fstab に記載する。状況によっては /etc/rc.local に上記のコマンドを設定しないと動かないケースがあるかも。

</samba/path> </path/to/mount/target> cifs credentials=</path/to/samba/.credential>,uid=<uid>,gid=<gid>,file_mode=0777,dir_mode=0777,rw 0 0
8
8
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
8
8