Linuxめも

VirtualBoxをインストール

https://www.virtualbox.org/wiki/Downloads

Vagrantをインストール

ベイグラントと呼ぶようです。

https://www.vagrantup.com/downloads.html

boxの登録

VirtualBox用boxファイルを指定して登録する。

http://www.vagrantbox.es

C:\Users\user>vagrant box add CentOS66 https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.0.0/centos-6.6-x86_64.box
mkdir centos
cd centos
vagrant init CentOS66

フォルダ内に Vagrantfile ファイルが生成されていることを確認

Vargrantfileの以下のコメントを外す

config.vm.network "private_network", ip: "192.168.33.10"

起動

vargrant up

TeraTermで 192.168.33.10 へ接続

ID:vargrant
PW:vagrant

サーバ停止は

vagrant halt

もしくはCentOS側で

shutdown -h now

共有フォルダの設定

Vagrantfile ファイルを編集

config.vm.synced_folder "../home", "/home"

C\Users\user\home\vagrant フォルダを作成し、test.txt ファイルを作成

sshにて

cd /home/vagrant
ls -l

で test.txt ファイルが見えれば成功

$ cd
$ vi .bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# User specific aliases and functions
$ source ~/.bashrc

日本語環境に変更

# vi /etc/sysconfig/i18n
LANG="ja_JP.UTF-8"
SYSFONT="latarcyrheb-sun16"
# source /etc/sysconfig/i18n

日本時間に設定

# cp /usr/share/zoneinfo/Japan /etc/localtime
# vi /etc/sysconfig/clock
ZONE="Asia/Tokyo"

inaccessibleで立ち上がらなくなった

vagrant up しても inaccessible と表示されて立ち上がらくなってしまった。

Bringing machine 'default' up with 'virtualbox' provider...
Your VM has become "inaccessible." Unfortunately, this is a critical error
with VirtualBox that Vagrant can not cleanly recover from. Please open VirtualBox
and clear out your inaccessible virtual machines or find a way to fix them.

Virtual Box VMs 以下のフォルダ内のファイル

centos_default_1456133417390_64892.vbox-prev
centos_default_1456133417390_64892.vbox-tmp

ができていたので、.vbox-tmp ファイルを .vbox に拡張子変更したら立ち上がりました。

Windows updateすると立ち上がらなくなった

Windows10でupdateがかかった後に vagrant up すると以下のようなエラーが途中で出力されてWEBアクセスできなくなってしまいました。

The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'unknown' 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.

原因はよくわかりませんが、VirtualBoxがインストールされているフォルダで以下のファイルを右クリックしてインストールすれば無事に接続できるようになりました。

Oracle\VirtualBox\drivers\vboxdrv\VBoxDrv.inf

参考


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS