仮想マシンフォルダーがNAS内にある仮想マシンを、別のPCからも操作できるようにする
要望
LAN内だけでRedmineを使うために仮想マシンを作ったが、別のPCからも仮想マシンを起動・終了させたい。
PC1を使用する職員が不在の場合、別の職員のPC2から仮想マシンを起動してRedmineを使えるようにしたい。
解決策
下図のように、PC2にもVirtualBoxとVagrantをインストールし、PC1のVagrantのフォルダをコピーすれば実現します。
目次
- PC2にVirtualBox, Vagrantを導入
- PC1からVagrantのフォルダをPC2へコピーする
- PC2のVirtualBoxにNAS内の仮想マシンを追加する
- PC2で「vagrant up」する
PC2にVirtualBox, Vagrantを導入
下記の記事の1、2番までの手順を実行してください。
PC1からVagrantのフォルダをPC2へコピーする
下図のように、Vagrantfile
や.vagrant/
が入っているフォルダ(この場合はcentos6/
)をPC2へコピーします。
重要なのは、.vagrant
内の仮想マシンのIDなどがそのままコピーされることです。
PC2のVirtualBoxにNAS内の仮想マシンを追加する
VirtualBoxのメニューで仮想マシン > 追加
を選びます。
NAS内にある仮想マシンのフォルダの中から.vbox
という拡張子のファイルを探して選択します。
PC2で「vagrant up」する
PC2のコマンドプロンプトで先ほどコピーしたフォルダへ移動し、vagrant up
します。
これで完了です。
なお、既にPC1で仮想マシンを起動している場合は下記のようになります。
その場合はPC1側でvagrant halt
してください。
要するに、二重に起動したりはしないということです。
> vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: bridged ==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... The guest machine entered an invalid state while waiting for it to boot. Valid states are 'starting, running'. The machine is in the 'poweroff' state. Please verify everything is configured properly and try again. If the provider you're using has a GUI that comes with it, it is often helpful to open that and watch the machine, since the GUI often has more helpful error messages than Vagrant can retrieve. For example, if you're using VirtualBox, run `vagrant up` while the VirtualBox GUI is open. The primary issue for this error is that the provider you're using is not properly configured. This is very rarely a Vagrant issue.