Virtualizing my development environment

Last week I have been busy moving my development environment from my laptop to a virtual server running on my laptop. This my seem like a hassle and the advantages are not all obvious, so I would like to share my findings and the specifics of my setup that I settled on.

Security / Privacy

First I would like to point out the problems I had with my current setup.The most urgent concern I had was that if my laptop would get stolen all my projects would be out in the open. I use the laptop primarily for my company projects and thus contains at lot of information from my clients. Think about copies of a database with maybe lots of user account information. It would be bad if my company would be responsible for the leaking of private information of other company’s. It is clear that I needed a way to protect my information (probably encryption), but I didn’t want it to get to much in my way.

It should just work

My primary OS is Archlinux. As a desktop OS it suits my needs just fine. I like to tweak things and it runs very fast. On the other hand I am very used to Ubuntu and typically setting up a LAMP environment is less work on Ubuntu that it is on Archlinux. It also matches better with the servers we deploy on and the other developers are also Ubuntu users.

Most important my development environment should just work ALWAYS! I’ve had some occasions that I reinstalled my system and forgot to install some tools only to discover at an appointment with a client. Not good… Isolating the development environment from my host OS enables me to chose a different environment and also allows me to preserve it during reinstalls of the host OS.

The setup

Enough blabla, on with the details. For virtualization I used Virtualbox. I haven’t used anything else and directly admit I use it for its simplicity. As a guest OS I use Ubuntu Server. I installed it with encrypted LVM. This way all data inside the virtual server is encrypted (and thus sort of safe). This safes me from all the trouble of keeping track where my database is stored and where my documentroot is from the webserver and if they are exposed or not.

Networking

So far all has been nice. But I can’t use my virtual server without access to it. There are a number of options to try and I will discuss 2 possible setups.

First I went for bridged networking. This way the virtual server will appear in the same network as the host. This is quite flexible and only has two problems. The first being that it is not always good to have your virtual server accessible for the hole network (for instance when connecting directly to the internet or hotel wireless). Second is more of a bug and that is that it just not always works on all networks. Some routers just don’t seem to get it when two operating systems request an ip from one physical network card.

To solve the to issues a made a second setup. This time I configure two network cards on the virtual server. One uses NAT and is primarily for internet access. The second uses host-only networking and is used by myself for accessing the virtual server. This has some advantages. First being that it works on buggy routers and second, it makes the network layout much more predictable as you have your own internal network address space. This allows you to hard code the network addresses in scripts. The only disadvantage of this setup is that other computers can’t access the server.

At the moment I use the second solution. Maybe I will switch the NAT to bridged networking when the routers allow it, but I’m not sure if I will need it. The host only network is great and saves me the trouble of looking up the ip from my server every time. I can now use a script to mount the document root using NFS.

Hope this was useful comments are welcome.

cheers.