LoginSignup
0
2

More than 5 years have passed since last update.

Vagrant+VirtualBoxで構築した仮想マシンをBox化して復元する

Last updated at Posted at 2017-02-10

Vagrant+VirtualBoxで作成した仮想マシンにPHPライブラリテスト用環境を構築する【1】
Vagrant+VirtualBoxで作成した仮想マシンにPHPライブラリテスト用環境を構築する【2】
Vagrant+VirtualBoxで作成した仮想マシンにPHPライブラリテスト用環境を構築する【3】
Vagrant+VirtualBoxで構築した仮想マシンをBox化して復元する ←イマココ

Boxの生成

$ vagrant package
$ ls
Vagrantfile		package.box

え、簡単にできるやん!

仮想マシンの復元

早速復元してみようと思う。

Boxを追加

先ほど生成したBoxをVagrantに追加する。

$ vagrant box add labelTest package.box
$ vagrant box list
CentOS6     (virtualbox, 0)
labelTest   (virtualbox, 0)

仮想マシンの初期化

$ mkdir test
$ cd test
$ vagrant init labelTest

仮想マシンの起動

うまくいかない

$ vagrant up
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

# Down the interface before munging the config file. This might
# fail if the interface is not actually set up yet so ignore
# errors.
/sbin/ifdown 'eth1'
# Move new config into place
mv -f '/tmp/vagrant-network-entry-eth1-1486695738-0' '/etc/sysconfig/network-scripts/ifcfg-eth1'
# attempt to force network manager to reload configurations
nmcli c reload || true

# Restart network (through NetworkManager if running)
if service NetworkManager status 2>&1 | grep -q running; then
  service NetworkManager restart
else
  service network restart
fi


Stdout from the command:

Schnittstelle eth0 beenden:  [  OK  ]
Loopback-Schnittstelle beenden:  [  OK  ]
Loopback-Schnittstelle hochfahren:  [  OK  ]
Schnittstelle eth0 hochfahren:  
IP-Informationen für eth0 werden bestimmt ... erledigt.
[  OK  ]
Schnittstelle eth1 hochfahren:  Determining if ip address 192.168.33.10 is already in use for device eth1...
[  OK  ]
Schnittstelle eth2 hochfahren:  Gerät eth2 scheint zu fehlen, Initialisierung verzögert.
[FEHLGESCHLAGEN]


Stderr from the command:

bash: Zeile 10: nmcli: Kommando nicht gefunden.

え、え、エラーだー

何やってもエラー...俺には分からんんーんー

対策

Vagrant1.8.7でネットワークの起動に失敗する

やってみよう...
!?本当にVagrant1.8.6にダウングレードしたら直った。
他にも正しい解決方法はあると思うけど、今回はこれで妥協!

無事復元できた

なんやかんやあったけど復元できました。
でもまだまだVagrantの便利なところ引き出しきれてない気がする!
provisionとか使ってもっと便利にしたいと思うのでした...

0
2
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
0
2