質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

Q&A

解決済

1回答

10807閲覧

Vagrantで共有フォルダが機能しない

anvinon

総合スコア38

Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

0グッド

1クリップ

投稿2016/09/03 03:19

環境:Windows 10(ホストOS)
CentOS 6.5(ゲストOS)
Vagrant 1.8.5
VirtualBox 5.1.4
PuTTY ごった煮

Windows 10に、Chocolateyをインストールして、そこからVirtualBoxとVagrantをインストールして、VagrantからCentOS 6.5のboxを加え、PuTTYからSSHでログインしています。以上の手順は、こちらのサイトに掲載されている手順と全く同じ手順を踏みました。

しかし、共有フォルダが機能していません。具体的には

Linux

1[vagrant@vagrant-centos65 ~]$ touch test9 2[vagrant@vagrant-centos65 ~]$ ls 3test9

と、CentOSではなりますが、Windows上では、何もファイルが出来ません。逆に、Windows上で何かファイルを作っても、CentOS上に何もファイルが出来ません。

目指しているのが、Windows上の共有フォルダでAtomを使ってプログラミングをし、ファイルの変更をしたら、それが即座にCentOS上の共有フォルダ内の同一ファイルに反映される・・・という環境です。

何かアドバイスなど頂ければ幸いです。どうぞ宜しくお願い致します。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

共有フォルダが機能していません。

Vagrantfileで共有フォルダの対象として指定したディレクトリ同士でしかフォルダは共有されません。
こちらのサイトに掲載されている手順と全く同じ手順を踏みました。との事なので、
Vagrantfileの中身をコピペしても別段困る事は無いと思いますので、もし良かったら貼り付けてみてください。

ざっと解説しておきますと、
Vagrant + VirtualBOXで立ち上げた場合、
デフォルトの共有機能はVirtualBOXの共有フォルダ設定で確認することが出来ます。
(vagrantfile内の記述を書き換える事で、SambaやRsync等の好きなファイル共有の仕組みを利用する事ができます)

更に、デフォルトの仕様ではvagrantfileがあるディレクトリが、仮想マシン内の/vagrantにつながっているはずです。

bash

1cd /vagrant 2touch hoge

これでvagrantfileと同じ階層にファイルが作成されるかどうか確認してみてください。

投稿2016/09/03 03:34

miyabi-sun

総合スコア21158

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

anvinon

2016/09/03 03:59 編集

早速のご回答、ありがとうございます。 > Vagrantfileの中身をコピペしても別段困る事は無いと思いますので、 > もし良かったら貼り付けてみてください。 はい、とくにVagrantfileもいじってはいないので、そのまま貼り付けます。 # -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("2") do |config| # The most common configuration options are documented and commented below. # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. # Every Vagrant development environment requires a box. You can search for # boxes at https://atlas.hashicorp.com/search. config.vm.box = "centos" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs # `vagrant box outdated`. This is not recommended. # config.vm.box_check_update = false # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. # config.vm.network "forwarded_port", guest: 80, host: 8080 # Create a private network, which allows host-only access to the machine # using a specific IP. # config.vm.network "private_network", ip: "192.168.33.10" # Create a public network, which generally matched to bridged network. # Bridged networks make the machine appear as another physical device on # your network. # config.vm.network "public_network" # Share an additional folder to the guest VM. The first argument is # the path on the host to the actual folder. The second argument is # the path on the guest to mount the folder. And the optional third # argument is a set of non-required options. # config.vm.synced_folder "../data", "/vagrant_data" # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. # Example for VirtualBox: # # config.vm.provider "virtualbox" do |vb| # # Display the VirtualBox GUI when booting the machine # vb.gui = true # # # Customize the amount of memory on the VM: # vb.memory = "1024" # end # # View the documentation for the provider you are using for more # information on available options. # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies # such as FTP and Heroku are also available. See the documentation at # https://docs.vagrantup.com/v2/push/atlas.html for more information. # config.push.define "atlas" do |push| # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" # end # Enable provisioning with a shell script. Additional provisioners such as # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the # documentation for more information about their specific syntax and use. # config.vm.provision "shell", inline: <<-SHELL # apt-get update # apt-get install -y apache2 # SHELL end 以上です。頂いた手順の通り試してみました。以下のとおりです。 login as: vagrant vagrant@127.0.0.1's password: Last login: Sat Sep 3 02:51:51 2016 from 10.0.2.2 [vagrant@vagrant-centos65 ~]$ cd /vagrant [vagrant@vagrant-centos65 vagrant]$ touch hoge [vagrant@vagrant-centos65 vagrant]$ ls hoge Vagrantfile [vagrant@vagrant-centos65 vagrant]$ ls foo.txt hoge Vagrantfile 出来ました!Windows上でfoo.txtを作ってみても、すぐに反映されました。 本当に有難うございます!!ずっとわからなくてgoogleを検索して いたので、本当に助かりました!!もっと早く質問させて頂くべきでした・・・。
miyabi-sun

2016/09/03 04:03

># config.vm.synced_folder "../data", "/vagrant_data" 思った通りデフォルトですね。 この行が共有フォルダの設定部分になります。 Vagrantfileは単なるRubyのソースコードなので、#を消すことで動作するようになります。 その際、第一引数の"../data"は、vagrantfileのあるフォルダから1フォルダ上に遡ってからdataフォルダを共有、 第二引数である"/vagrant_data"は仮想マシン内のパスを置き換えるというイメージです。 一度dataフォルダを作ってみれば次から自在に共有設定が出来るようになるかと思います。 更新する時は「vagrant reload」や「vagrant halt; vagrant up」を実行して仮想マシンを再起動させてください。
anvinon

2016/09/03 04:23

ありがとうございます!!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問