Monday, April 21, 2014

VirtualBox Ubuntu Slow Shared Folders Under Windows

Often, especially with large file transfers, it seems that the shared folders facility in VirtualBox (running Ubuntu, but not sure that matters), running as a Windows guest, are very slow.

I added these lines

255.255.255.255        VBOXSVR #PRE
255.255.255.255        VBOXSRV #PRE


To this file:

\windows\system32\drivers\etc\lmhosts

And then restarted the VM. I saw a big improvement.

Monday, April 7, 2014

Shared Folders Issue on VirtualBox Ubuntu

I recently upgraded my VirtualBox Guest Editions to 4.3.10 and the shared mounts that I normally create stopped working. I was running this mount:

sudo mount -t vboxsf Dropbox /home/steve/Dropbox
And getting this error:

mount: wrong fs type, bad option, bad superblock on /home/steve/Dropbox,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail  ...

After some research, it turns out that after the Guest Editions upgrade, the symlink for mount.vboxsf was broken. Here's what I ran to correct it:
cd /sbin
sudo rm mount.vboxsf
sudo ln /usr/lib/x86_64-linux-gnu/VBoxGuestAdditions/mount.vboxsf mount.vboxsf
This did the trick. Thanks to this post for the tip:

http://superuser.com/questions/736024/cannot-share-host-directory-with-virtualbox-guest-mint-16-64-bit

UPDATE: this may be fixed in the next Guest Editions release:

https://www.virtualbox.org/ticket/12879

Thursday, March 20, 2014

Creating a Java, Marklogic development stack on an Ubuntu 13.10 VirtualBox VM

I wrote about building a Java-based development stack using Ubuntu on a VirtualBox VM some time back (http://www.tractare.blogspot.com/2011/10/ubuntuvirtualboxjava-team-development.html, and http://www.tractare.blogspot.com/2011/10/ubuntuvirtualboxjava-team-development_04.html). But that was a couple of years ago and the technology has changed, so this is a rewrite. Also, that version didn't include Marklogic, which is a part of the stack for this particular application. So here's the stack I'm building out and the steps I took to get there.

First off, I'm building this in Virtual Box  4.3.8, installed on a Dell XPS laptop quad-code I7, 16GB RAM and dual 750GB HDD running Windows 7. Second, some of these kits I installed using PPAs, so if you have security concerns about PPAs, you'll need to find other ways for those tools.

The development stack I'm installing is this:

  • Ubuntu 64bit 13.10 with VB Guest Editions
  • DropBox
  • Oracle Java 7
  • JEdit
  • Git 
  • Maven
  • Tomcat 7
  • Chrome Browser
  • Eclipse Kepler
  • Marklogic 7
Installation Process:
A. Create the Virtual Machine...
  1. Downloaded the Ubuntu 13.10 64bit Desktop ISO  image from http://www.ubuntu.com/download/desktop
  2. Created a new VirtualBox VM targeting a linux/Ubuntu 64 bit OS with 10GB Ram and an 80GB Drive.
  3. Started that new VM and pointed it at the ISO image to install. (and chose to install rather than to try Ubuntu).
  4. After answering all the usual questions (where am I), restarted the VM and mounted the VB Guest Additions. The ran them via the autorun. Installing Guest Editions is a critical part of making a useful VM in VirtualBox. Don't leave home without it.
  5. Shut down the VM and opened the VirtualBox Manager Settings for my new VM; Changed the following:
  6. General->Advanced:
    Shared Clipboard=bidirectional
    Drag'n'Drop=Bidirectional
  7. System->Processor:
    4 CPUs
  8. Display->Video: 128MB
  9. OK to save all that, then start the VM again.
B. General VM Stuff, and Dropbox...
  1. The default gnome desktop has a bunch of stuff I don't use (word processing and so on),  so I removed and uninstalled them using the Ubuntu Software Center.
  2. I like to be able to do things in root, so I changed the root password. Saves having to sudo all the time!
    sudo passwd root
  3. Next, opened a terminal (and pinned it to the launcher) and started in on the stack. and I switched to root user (su root).
  4. Dropbox: I run Dropbox on the Windows machine and I don't see the point of running it in the guest Ubuntu VM as well. But I like having those folders and files available. So I create a shared folder and mount that in the Ubuntu VM.

    1. in Devices->Shared Folders Settings, create a new "Machine Folder" that points at the Dropbox folder on the Host.
    2. Create a directory of the same name in Ubuntu (Dropbox, in my case).
    3. Mount that:
       sudo mount -t vboxsf Dropbox /home/cup/Dropbox
C. Java, JEdit, Git, Maven...
  1. Java: If this is a new, clean Ubuntu install then there is no pre-installed Java. If you are trying to upgrade, you should check for and remove any extant Java installation.

    I installed Java via a PPA (http://askubuntu.com/questions/4983/what-are-ppas-and-how-do-i-use-them) by webupd8team (http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html). I ran these commands to add the PPA to the apt-get repo and update that repo, install Java7, and set up the various java 7 environment variables.
    
    add-apt-repository ppa:webupd8team/java
    apt-get update
    apt-get install oracle-java7-installerapt-get install oracle-java7-set-default
    
    
  2. JEdit: Installed this via the software center. This installed version 5.which is good enough for my purposes. 
  3. Git: simple - sudo apt-get install git
  4. Maven -- also simple sudo apt-get install maven
  5. Tomcat7 -- Installed directly from the Ubuntu Software Center.
D. Chrome Browser...
  1. Chrome Browser: Via PPA:

    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
    sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
    apt-get update
    apt-get install google-chrome-stable
E. Eclipse...
  1. Eclipse: A bit of a pain in the neck, I followed this guide: http://blog.thismagpie.com/2012/07/installing-eclipse-juno-42-on-lubuntu.html. Downloaded the Eclipse Linux 64 tar.gz distribution and saved that file. Then ran these commands as root:
    
    tar -zxvf eclipse-...
    sudo cp -r eclipse /opt
    cd /usr/local/bin
    cp -r /opt/eclipse/eclipse eclipse
    
    After that, I ran eclipse from the command line and then pinned it to the launcher.
  2. One issue I had with Eclipse was that the command menus didn't work. I had to edit the eclipse.desktop file in ~/.local/share/applications to get it to work by commenting out the Exec and adding this one:
    
    
    Exec=env UBUNTU_MENUPROXY= /usr/local/bin/eclipse
F. Marklogic...
  1. Downloaded Marklogic7 for 64Bit RedHat Linix and ran these commands
    apt-get install alien
    alien --to-deb --verbose MarkLogic-4.1-6.x86_64.rpm
    dpkg -i marklogic_4.1-6_amd64.deb
    /etc/init.d/MarkLogic start
    
    The one issue I had with the ML install is that the Marklogic script in /etc/init.d runs under /bin/sh and Ubuntu's default shell is bash. So I changed the first line of that script to #!/bin/bash
And that's it. I now have a reasonable development stack to create Web based Java code using Marklogic.


Thursday, February 13, 2014

Accessing a Web Server on a Virtual Box Ubuntu Guest from the Host Server

I do a lot of development of web applications in VirtualBox virtual machines running Ubuntu. Although I could (and sometimes do) set up the virtual machine to have multiple monitors, I usually don't, instead leaving one monitor for the host OS (Win7) and another for the VM.  So it's handy for me to be able to run a browser on the host OS and access a web application on the VM. In VirtualBox, I accomplish this with Port Forwarding.

Go into settings for the VM and select Network->Advanced and click Port Forwarding.

Then enter the IP address of your host machine, the port to forward, the IP address of the guest and the port the web application runs on.The example below sets up forwarding from http://localhost:8080 to a web application running on port 8080 (Tomcat in this case) on the VM: