Sandbox cover found at http://whatjeffdid.blogspot.com/

Make you dev env fully virtual

Create your own Vagrant sandbox with Parallels

Ilya Zayats
3 min readMay 27, 2013

--

In my first post I’ve described why you shouldn’t be tied to your computer and move all your developer’s environment to the virtual machine.

This post will be a little bit more specific and technical. I’ll tell you about my own steps that I’ve done to “free” myself.

All started from a new mac and the idea to setup all dev things “right” this time. The easiest way was to take Vagrant and setup everything with it. That was quick and really flawless, I was happy when I finished, but then some problems started bubbling up.

Speed

Vagrant use VirtualBox by default and it is slow, like 10x slower than my previous bare metal setup. This was a real disappointment. There are some tries to untie Vagrant from VB, but they are far from production ready state. Also there is Vagrant Fusion plugin that runs your VM under VMware Fusion, but this will cost you, so we will talk about it a little bit later.

Shared FS problems

Best practice when using Vagrant is to leave you code on the host and share it with VM by network. This approach has a lot of problems.

Speed, again: using default VB share or even NFS (which is faster) I have about 1-2 sec lag when doing plain `git status`.

But there is bigger problem: no way to use libraries that are tied to local FS update events. If you are from Ruby/Rails world, then say hi to Zeus and to little note inside Readme:

Please note: Zeus requires your project to be running on a file system that supports FSEvents or inotify.

NFS doesn't support that.

After all this, I thought that I couldn’t fully move to VM and had an idea to setup all again natively. But stubbornness won that time.

I’ve remembered that I had already bought another virtualization platform — Parallels. Latest benchmarks show that it is the fastest across all other solutions and after some googling I found that it has CLI interface too — `prlctl`.

I’ve never ever written bash scripts before, but this looks like an interesting approach to try to create my own vagrant based on Parallels.

Also, why not to buy Fusion plugin? I don’t want to have an entire zoo of virtualization platforms, I already have Parallels and it has created an impression of a stable and solid product.

According to FS and code sharing I’ve gone totally opposite way: I’ve left code inside the VM and shared it to the host (this is because I want to use Sublime Text to edit my files, you can omit this if you are Vim or Emacs adept). That was easy and eliminated all my problems.

In the end I’ve come up with these steps to fully setup a new VM:

  1. Create a VM inside Parallels interface and setup initial OS. Maybe I could automate this step too, but I have no need, this is a very rare action for me
  2. Install my bash script (I use it like a part of my `.zshrc`) and create .vm_config file that will describe all constants for this virtual machine
  3. SSH inside VM, setup the way you want it and then add NFS sharing for the code folder.
  4. All done, when you want to work just up the machine via `vu`, and ssh to it via `vs`. When you want to relax — down it via `vd`. Or halt entirely — `vh`

As a conclusion, I’m fully happy with my current setup. Just one small caveat left — I couldn’t run specs from my editor. I don’t have a big need to do this though,but this just an idea for a future updates.

Also I’ve summed up all the commands and conf files inside the gist, so take a look if you want to repeat my steps and if you are a mac user. For a linux I could suggest to take a look at Vagrant LXC. This is an experimental plugin that adds support for Linux containers to Vagrant what gives you a native speed as a result.

Any comments will be highly appreciated, maybe I’ve missed something and everything could be done more easily?

--

--