VM name을 검색하기 위해서 이하의 커멘드를 실행한다.
여기서 default가 VM name이 된다.
$ vagrant status
Current machine states:
default running (virtualbox)
The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.
이하의 커멘드로 box 파일을 만든다.
$ vagrant package [:VN_name] --output [:output_file_name].box
실행 과정
$ vagrant package default --output ubuntu_trusty64_test.box
==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Exporting VM...
==> default: Compressing package to: /Users/user_name/ubuntu_trusty64/ubuntu_trusty64_test.box
백업이 완료됨.
이 box 파일의 사용법은
$ vagrant box add [:VM name] [:box file path]
실행과정
$ vagrant box add ubuntu_trusty64_test2 ubuntu_trusty64_test.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ubuntu_trusty64_test2' (v0) for provider:
box: Unpacking necessary files from: file:///Users/user_name/ubuntu_trusty64_test2/ubuntu_trusty64_test.box
==> box: Successfully added box 'ubuntu_trusty64_test2' (v0) for 'virtualbox'!
확인방법
$ vagrant box list
ubuntu/trusty64 (virtualbox, 20190429.0.0)
ubuntu_trusty64_test2 (virtualbox, 0)
리스트에 추가 되어진 것을 볼 수 있다.
그럼 이 box를 이용해서 새롭게 시작하면 된다.
$ vagrant init ubuntu_trusty64_test2
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
$ vagrant up