Tag: Program

Vagrant に関する覚え書き。

Vagrant とは

Vagrant は VirtualBox 上の仮想マシンをコマンドラインから作成してくれるソフトウェア。ソフトウェアのビルドなど GUI を必要としない環境を容易に構築出来る。

仮想マシン(Ubuntu Lucid)の構築

  1. Vagrantダウンロード して、インストール。
  2. VirtualBox をダウンロード して、インストール。
  3. ターミナルを起動し、Ubuntu Lucid (10.04) 32-bit をインストール。
    $ vagrant box add base http://files.vagrantup.com/lucid32.box
  4. 仮想マシンを初期化。
    $ vagrant init

仮想マシンの利用

  • 起動
    $ vagrant up
  • SSH でログイン
    $ vagrant ssh
  • シャットダウン
    $ vagrant halt
  • 一時的な停止
    $ vagrant suspend
  • suspendからの復帰
    $ vagrant resume
  • 仮想マシンの削除
    $ vagrant destroy

共有フォルダの設定

デフォルトでは次のような設定になっている。

  • ホストOS : Vagrant を起動したフォルダ
  • ゲストOS : /Vgrant

これに、別の共有フォルダを追加してみる。
起動したフォルダにあるファイル "Vagrantfile" を編集し、Vagrant::Config.run do |config| ~ end の間に、下記のようなコマンドを追加。

config.vm.share_folder "v-data", "ゲストOS のフォルダ", "ホストOS のフォルダ"

config.vm.share_folder "v-data", "~/share", "~/Vagrant_share"

共有フォルダが機能しない場合、Vagrant-vbguest plugin で、VirtualBox guest additions をアップデートしてみる。

$ vagrant gem install vagrant-vbguest
$ vagrant vbguest

その他

git のインストール

sudo apt-get install git-core