1
1

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.

ゲストOS(ubuntu)からホストOS(windows)の共有フォルダにアクセスする

Last updated at Posted at 2015-02-17

VMWareToolsを使うと簡単
[VMware player で共有フォルダ設定の仕方]
(http://www.atmarkit.co.jp/flinux/rensai/linuxtips/756fstabnum.html)

以下、手作業で設定する。ただし、

  • 最新版のubuntuでも有効かどうかは未確認
  • ディレクトリ名とかは環境に合わせる
  • kernel2.6以降
  1. windows共有フォルダを作成する

    [ドライブのルートを共有する方法]
    (http://windows.microsoft.com/ja-jp/windows7/how-do-i-share-the-root-of-a-drive)(Win7)

    他のユーザーとファイルを共有する(Win7)

    Vistaより前のバージョンなら、共有フォルダ名に$(ドル)をつけると外部からエクスプローラで見えなくなる
    最後に「$」文字で、共有名は表示されません。

  2. sambaをインストール

    インストール確認

which smbclient

     なければインストール

    ```shell-session
apt-get install samba
  1. マウントポイントを作成する

mkdir -p /volumes/hogedir


1. __mountできるか確認__
 
    ```shell-session
mount -t cifs -o username=hoge,password=hoge,uid=1000,gid=1000,codepage=cp932,iocharset=utf8 //hostname/shared /volumes/hogedir

linuxからwindows共有フォルダへのマウントは、cifs でマウントする(kernel2.6以降)

マウントできなかったとき、`dmesg | grep CIFS` でエラーコード確認

22のときは、//hostname/ を IPアドレスに変えてみる

マウントできたら、マウントポイントに cd して ls でファイル一覧が出るか確認する。
  1. 起動時にマウントする

    viなどで/etc/fstabを開く

sudo vi /etc/fstab


    > [vi コマンドリファレンス](http://hp.vector.co.jp/authors/VA016670/unix/vi_reference.html)

    最終行に以下を追加して保存

    ```shell-session
//hostname/shared /volumes/hogedir cifs username=hoge,password=hoge,uid=1000,gid=1000,codepage=cp932,iocharset=utf8 0 0
> [/etc/fstabに記述されている数字の意味](http://www.atmarkit.co.jp/flinux/rensai/linuxtips/756fstabnum.html)

4.で行ったマウントを削除する

```shell-session

umount -a -t cifs

 
    /etc/fstabで追加したマウントが正しいか確認

    ```shell-session
mount -a -t cifs
マウントポイントに移動して ls で確認
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?