This is a follow-up question to
How can I change where Vagrant looks for its virtual hard drive?
Is it possible to set the machine-folder relative/inside the current Vagrant project (maybe is there a provider-option for that) ?
Scenario: Vagrant project is stored on an external drive. The created machine files (vbox & vmdk) should also be stored on the external drive (whose mount point / drive letter differs from host to host and might change on the host itself) inside the same project folder. Therefore the general Virtualbox setting is not an option.
With that setting I should be able to have instantly the same state of my virtual machine on any host system.
(this is my first question here - please excuse any unintended noobness :) )
Related
I have tried installing latest versions of VirtualBox and Vagrant, but I keep receiving the error message below when trying to run vagrant. How can I find the problem and correct it?
No usable default provider could be found for your system.
Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.
The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.
If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.
Be sure to install VirtualBox first, since Vagrant depends on it.
-Download and install VirtualBox
-Download and install Vagrant
-Adjust VirtualBox and Vagrant
The next step is to make some tweaks to VirtualBox and Vagrant. We need to do this because, by default, both tools store data in the same drive where they were installed (tipically the C drive). The thing with virtual machines is they can take up a lot of space, so they can eat up your main drive’s storage very quickly.
First we’ll change the storage path in Virtual Box, since it’s pretty straightforward. You now should have a program called Oracle VM VirtualBox installed. Open it and then go to File > Preferences. A
new dialog will open where you can change the folder next to the option that reads Default Machine Folder. Click the dropdown and choose Other…. Here you can choose the new folder for VirtualBox to store data.
Now we’ll do the same for Vagrant.
By default the path where data related to virtual machines is
stored is C:\Users\YourUser\.vagrant.d so I recommend changing it to a different drive. This can be done with environment variables. We need to create a variable called VAGRANT_HOME and point it to our desired location.
Open the control panel and search for the word environment. From the results choose the one that says edit environment variables for your account.
On the new dialog that appears, click the New… button.
Here you will create the new variable. Enter VAGRANT_HOME as the value for the field named Variable name.
For the field named Variable value enter the path of your choice. In my case I used C:\VM\Vagrant
I was messing with systemd in my Vagrant box and I think I did something wrong since the box won't boot anymore. What I need to do is to remove certain files under /etc/systemd in my Vagrant box. However since I can't boot it, I have to remove those files from the host, but I don't know how to do it.
The VM provider is virtualbox. Both the host and the guest are ubuntu 15.04.
Thanks in advance!
option 1: you can try to add vagrant ssh -c 'cmd to run' in your vagrant file, but as you said it really does not boot, I give it really low chance to success.
option 2: create a new VM and add the hard drive from the old box to the new box (add new hard drive from existing disk), boot it and you might need to mount the new hard drive then you should be able to access your data so make the change in your /etc/systemd or whatever files you need and save. once you have made all your fix, you should be able to reboot from the old vm.
I ended up just creating a new VM but I'm fairly certain that this would work: you just mount the virtual disk file (.vmdk in my case) as a hard drive and make the fix. For different formats of virtual disks you need different tools to mount them, which I'm not going to cover here.
I just ran vagrant provision in a futile attempt at getting my customized synced_folders directive to work and now my whole guest box is wiped out.
Is this normal? I don't see any references to Vagrant docs about this behavior.
As per the doc:
Provisioners in Vagrant allow you to automatically install software, alter configurations, and more on the machine as part of the vagrant up process.
The only thing I have in my config provision shell commands are installation commands. Nothing about wiping anything out.
I do have app.vm.provision for puppet that sets fqdn, user name and box name (along with the normal module_path, manifests_path and manifests_file). Maybe this caused things to be reset?
The Answer
Is Vagrant Provision suppose to wipe out all your data?
No. Vagrant should never harm your "data" (i.e., websites, code, etc.).
...now my whole guest box is wiped out. Is this normal?
Yes. Your Vagrant environment (in other words, the guest operating system created in a virtual environment by Vagrant) is volatile, and you should be able to destroy and recreate it at will without having any impact on your working files (because those should be kept in your local, or host, file system).
Explanation
On Vagrant's website, the very first thing they tell you is this:
Create and configure lightweight, reproducible, and portable development environments.
Your development environment allows you to work. You work on your data, in your development work environment. When you are done with your "development work environment," you should be able to delete it freely without affecting your data in the least.
Further, you should be able to send a collaborating developer your Vagrantfile so that they can create the exact same development environment you used to create your data (i.e., write your program, build your website, and so forth). Then, when you provide them with your code, they can use it in an environment identical to the one that your code was created in without having to reconfigure their own setup.
For more details about how your data files (code, working files, etc.) are kept safely in your computer while making them accessible to your guest system created by Vagrant, see my answer to this question.
So what appears to have happened was that when I set up a synced folder, it wiped out everything because there was nothing on my host machine in that synced folder. Unless there is a way to recover the lost data, there should be an unmistakable WARNING in their docs that this can happen.
I setup the synced_folder to be on my whole home directory. When I created a new machine, I cloned the one project I had saved and decided to just sync my individual projects instead of my whole user directory this time. When I reloaded, the project directory was empty since it was empty on my host machine.
So I guess, make sure the directories on your host machine are already setup with the data before configuring your Vagrantfile with synced_folder information.
I have a virtual machine (in Virtual PC) that is used to run/update specific COM objects in our solution. Currently, both the host OS and the VM OS have separate workspaces, and I have to check out the files in either location, then check them in separately as work is completed.
It's also a huge branch (several GB of data) that needs to be pulled down over a slow VPN connection. Given that I need the files on my host and the VM, it means pulling this code down twice.
Is there a way I can configure the VM to make use of the Workspace on the host? I'm fairly sure I can map that folder into the VM, but I want, when I check out files in the VM, that it checks them out from the hosts workspace.
Update 1
I tried to fool the system, by setting the _CLUSTER_NETWORK_NAME_ environment variable as per this answer. This certainly allowed Visual Studio to see the workspace as valid for the machine. However, when I rebooted the machine, I couldn't connect to the machine since the Guest and the Host now appear to have the same name.
You cannot have the same workspace on two machines, fullstop. This means that you can fool Team Explorer mapping a common file system for both the machine, but careful! you should always get from one client and not the other.
Now I can suggest you to test this recipe based on DiskMgmt.msc.
Say VM and PM your two clients, say that both map $/YourProj/src and you have $/YourProj/src/Common that you want to download once.
PM workspace mapping is $/YourProj/src -> C:\src.
PM is at least Win7; create a VHD and mount it on C:\src\Common; now you can get latest.
Unmount the VHD, start your VM with the same VHD as a secondary disk. Mount this secondary disk as C:\src\Common inside the VM.
Inside the VM the workspace mapping should be
$/YourProj/src -> C:\src
$/YourProj/src/Common -> (cloacked)
Disclaimers: This question is straddling a weird boundary between coding and SuperUser territory. I'm not even sure what terminology to use for half of what I'm asking so bear with me...
I'm working on a check in/out type of function for a remote client where they want to move some files back and forth between users' local machines and a central network location. They want the network location to be configurable. During the development for the past few weeks we've had the configured directory set to something simple like "C:\Storage" for initial testing purposes, and I created a Storage directory on the C: drive of my dev environment.
Today I got the network configuration they want to start using. I was hoping they'd use a mapped network drive so I could just map the same letter to my local drive and have my dev environment continue to work using their new configuration file. Unfortunately, the path they want to use points directly to some machine on their internal network using "\machinename\dir\dir\dir...".
Is there some way to set up my development environment such that when I encounter their network path using DirectoryInfo or whatever it will resolve to a local directory? If it was a mapped network drive I could use subst at the command prompt to point their letter at a directory on my local drive, but with this full path I don't know how to do something similar or if it's possible.
Now that I understand your problem a little better:
If you want to access your local computer using a UNC path, you'll need to setup a share, which it sounds like you already have. Then you can access it via:
\\localhost\c$\dir\dir
Hopefully that is good enough to get your work done on the dev side.