Thursday, December 19, 2013

How I use Virtual Machines

So sometimes it's nice to have custom environments to play with "new" toys. For example I decided the other day I wanted to install Ruby and play with it. Of course I can download the installer (if i'm using windows) or sudo apt-get install, however what happens when I forget about it and don't want to play with it anymore, do i want to deal with the hassle of uninstalling? Do I want to leave it and let it bog down my PC? of course not. So this is where virtual machines come in. Virtual machines can be costly in terms of space though, so today I'm going to teach you about linked clones.

Here is what I did.

I bought a Sandisk Cruzer Extreme (these things rock).

1. Download the ubuntu Server instance (this will keep memory low)
2. Install VirtualBox.
3. Create that virtual machine and install (pointing to your usb drive, or if you already have an SSD then that I suppose).
4. Basically we want a very minimal install, so don't put any of the LAMP stuff in, basically if it says "Hey should I install this extra wiz bang thing?". Say no
5. Install samba (sudo apt-get install samba)
6. Setup a configuration similar to the following:
    6a. Create a folder (whatever you want to name it) in your home folder.
    6b. chmod the shared folder to this:  sudo chmod 777 folder
    6c. Update samba configuration (from /etc/samba/smb.conf) replacing path with the folder you created in 6a.
 
7. Once that was all setup, I start making linked clones for various tasks, I.E. Ruby Machine, NodeJS Machine, etc (be sure that network is set to NAT, in this case I have a HTTP Proxy that is a hassle, so this is my workaround, you may have a better way and I'd love to hear it.)
  7a. So select your Ubuntu Server, right click clone,
  7b. Give it a good descriptive name when it asks,
  7c. When prompted select LINKED clone, this gives you a standard setup, but clean environment!
8. Logging in I see that occasionally my network takes FOREVER to come up, so that's because of some oddball thing so remove this file and it should resolve it, you're welcome to google around but you'll probably find that deleting this file is the solution:
sudo rm /etc/udev/rules.d/70-persistent-net.rules
9. after installing everything you need. halt the machine, shut down, and change the network adapter to Bridged, boot your VM up again, your local machine should be able to see the samba drives at \\\shared_folder (or whatever you called it in the smb.conf file).

Now whenever you want to work, you can startup the Linked Clone and start playing (and reference the folder you setup so you can work from your local machine with all your custom setups, just to play).