How do I package an existing VM that was not created using vagrant up command?

前端 未结 9 1824
你的背包
你的背包 2021-01-30 02:29

I installed a VirtualBox and then installed a Ubuntu 12.10 Server Base OS in it. I have installed all kinds of php packages and other packages in it. My friends recommended me t

相关标签:
9条回答
  • 2021-01-30 02:48

    While not a complete answer, I think you can get what you need from the documentation, which is quite extensive. I believe that vagrant up is merely a convenient means to setting up a Vagrant "box". There are a number of requirements for a box to be Vagrant compliant. They are described here...

    Documentation: Vagrant - Base Boxes

    The bare bones needed for a box are as follows...

    • VirtualBox Guest Additions for shared folders, port forwarding, etc.
    • SSH with key-based auth support for the vagrant user
    • Ruby & RubyGems to install Chef and Puppet
    • Chef and Puppet for provisioning support

    Once a box is compliant with these requirements, it should simply be a matter of using the vagrant package command to create a portable installation...

    More documentation: Vagrant - Boxes

    So, while I don't have a complete answer, having never done it this way, I think it's possible to get your installation into a state that will allow you to package and distribute it.

    0 讨论(0)
  • 2021-01-30 02:56

    Personally, the illusive aspect of the packaging process was the --base switch. I suspect that might be the case with a lot of people. Check out vagrant package --help for the description. The documentation does not seem to make mention of it either.

    I found these two great, in-depth, step-by-step guides to create Vagrant boxes from machines that were originally VirtualBox machines:

    1. How to Create a CentOS Vagrant Base Box
    2. Creating base box from scratch for Vagrant
    0 讨论(0)
  • 2021-01-30 03:00

    Use the 'VBoxManage list vms' command!I used it with sudo only to see there were no VMS listed.So use the command with the right authenticated user.The answers above also helped with making the box.

    0 讨论(0)
  • 2021-01-30 03:02

    As mentioned here - http://sysadm.pp.ua/linux/sistemy-virtualizacii/vagrant-box-creation.html You need three things for box to be imported and packaged:

    • Install Guest additions
    • Passwordless sudo
    • SSH access So you just need to login to your Ubuntu 12.10, install Vbox Guest additions, add user "vagrant" with passwordless sudo access.
    0 讨论(0)
  • 2021-01-30 03:03

    Any VirtualBox can be packaged to Vagrant Base Boxes (basically OVA with a Vagrantfile).

    Problems are: the VM is not build as per the vagrant base boxes, if you are not sharing it on vagrantbox.es then it'll be fine.

    Just install vagrant (via gem or the installer), run the following command in the VM folder to package it to .box

    NOTE: For Vagrant 1.2.x, the recommended install method is using the OS specific package. Ruby Gem is NOT available for 1.2.x.

    vagrant package --base ubuntu --output /path/to/ubuntu.box

    Remember, if you want to share the vagrant base box with others, better to read the docs and follow those rules to make it easier for others.

    0 讨论(0)
  • 2021-01-30 03:05

    vagrant package --output box_name.box --base "vm machine name" --vagrantfile Vagrantfile

    Make sure that port forwarding and SSH keys are setup properly.

    This may be a good example: https://github.com/okfn/ckan/wiki/How-to-Create-a-CentOS-Vagrant-Base-Box

    0 讨论(0)
提交回复
热议问题