Vagrant/インスタンスからBoxファイルを作る

Vagrant/インスタンスからBoxファイルを作る

まず http://www.vagrantbox.es/ 等からダウンロードした既存のBoxファイル(今回はcentos70)からインタンスを立ち上げる

$ vagrant init centos70

この box はVagrantのファイル共有が失敗するという致命的な問題を抱えているのでそれを解決した版をつくりたい

$ vagrant up
==> default: Mounting shared folders...
    default: /vagrant => /Users/hoge/myvagrant/centos70003
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:

/sbin/mount.vboxsf: mounting failed with the error: No such device

となるので、

インスタンスに入り込んで・・・

$ vagrant ssh

インスタンス側で

$ sudo /etc/init.d/vboxadd setup

ドン

これでマウントできるようになったので、抜けて

$ exit

電源OFF

$ vagrant halt

Box化

$ vagrant package

出来上がったやつを使えるように登録

$ vagrant box add centos70ore01 package.box
vm/vagrant/make_box_from_instance.txt · 最終更新: 2017-09-27 17:25 by ore