LoginSignup
4
4

More than 5 years have passed since last update.

Windows8.1(64bit)に Vagrant + Ubuntu 15.04 の環境を構築する

Last updated at Posted at 2016-04-12

自分用のメモです。

概要

Windows8.1(64bit)マシンに、Vagrant を使って Ubuntu 15.04(amd64 server) の仮想環境を構築します。
各ソフトウェアのバージョンは、2016/4/11時点での最新。

Virtual Box(5.0.16) インストール

Download VirtualBox
VirtualBox 5.0.16 for Windows hosts x86/amd64

をダウンロードし、インストール実行。
※OS再起動が要ります。

Vagrant(1.8.1) インストール

Download Vagrant
Windows Universal (32 and 64-bit)

をダウンロードし、インストール実行。

Vagrant 設定

BOXの追加

まず、BOX(仮想マシンのテンプレート)を準備します。
コマンドプロンプトで以下を実行。

> vagrant box add ubuntu15.04 https://github.com/kraksoft/vagrant-box-ubuntu/releases/download/15.04/ubuntu-15.04-amd64.box

※OSイメージをダウンロードするため、結構時間がかかります。
※ダウンロード元は、こちらを参照。

仮想マシンの定義ファイル作成

仮想マシン用のディレクトリを作成し、 そちらに仮想マシンの定義ファイルを作成します。

> mkdir C:\vm\ubuntu15.04 #仮想マシンのディレクトリ作成(任意のディレクトリ)
> cd C:\vm\ubuntu15.04
> vagrant init ubuntu15.04

ディレクトリにvagrantfileという設定ファイルが生成されます。
vagrantfileはruby構文で書かれており、NICやポートの設定もこのファイルを編集して行います。

仮想マシンの起動

> vagrant up

これで仮想マシンが作成・起動できました。非常に簡単ですね。
あとは適当なSSHクライアント(TeraTerm, RLogin...)で煮るなり焼くなり好きにしましょう。

Vagrant 補足

仮想マシンのシャットダウン

> vagrant halt

でシャットダウンできます。

起動時にマウントが失敗する場合

vagrant upコマンドで仮想マシンを起動中、以下のエラーメッセージが出る場合は、共有フォルダのマウントに失敗しています。

==> node1: Mounting shared folders...
    node1: /vagrant => C:/vm/ubuntu15.04
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3`
vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

The error output from the last command was:

stdin: is not a tty
mount: unknown filesystem type 'vboxsf'

どうやら、ゲストOSのboxにVirtualBox Guest Additionsがインストールされていないのが原因のようです。
(この問題については、こちらのブログがわかり易かったです。ありがとうございます。)
vagrant up時に「mount: unknown filesystem type 'vboxsf'」が発生する

ゲストOSに VirtualBox Guest Additions をインストールします。
Vagrant に Guest Additions を自動インストール/自動更新してくれる vagrant-vbguest というプラグインがあるので、そちらを利用します。

> vagrant plugin install vagrant-vbguest

プラグインがインストールされたら、

> vagrant reload

で仮想マシンを再起動すれば、Guest Additions がインストールされ、マウントのエラーが発生しなくなります。

参考

Vagrant Command-Line Interface (Vagrantコマンド一覧)
Vagrantbox.es (Vagrant Box一覧)
Vagrantfile (Vagrantfileについて)

4
4
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
4
4