Thursday Jul 30, 2009

Using Cygwin to manage script Virtual Box tasks

The Virtual Box GUI doesn't do everything one needs and so I have been experimenting with using cygwin, a free to use bash shell library. Having installed CYGWIN the first thing to do is add the Virtual Box program folder to the PATH, in my case,

    export PATH=/cygdrive/c/Program\\ Files/Sun/xVM\\ VirtualBox:${PATH}

I want this placed in the .bashrc so its always invoked, and thus need to test if is already in the path. I use this code,

    type -p VBoxManage.exe > /dev/null
    case $? in
    0)   # Its already there
         : ;;
    1)   # Add Path
         export PATH=/cygdrive/c/Program\\ Files/Sun/xVM\\ VirtualBox:${PATH} ;;

Now I need to associate a script file type with an execution program. I have tried to use the distributed batch file and binary and neiter of these work, so I have copied cygwin.bat to bash.bat and amended it so that it reads as follows

    @echo off

    :: Dave Levy (c) 2009         Is this GPL?
    :: bash.bat                   Version 1.0

    :: Wrapper to run \*sh scripts from windows explorer/desktop

    c:\\ksh\\bin\\bash --login %\*

I have deleted the -i flag from the bash line, I have made the bash program call absolute, %\* is the DOS batch command file syntax equivilant to $\* i.e. all the command line arguments, so the command line invokes bash.exe in login mode to force the execution of .bash_profile and .bashrc and appends all the other command line parameters including the script file name. :: is a neater comment delimiter than REM. I have associated my batch file with the file type .ksh as the open method using explorer.

Much of CYGWIN is distributed under the GPL and I am unclear if the batch file is included, If so, its GPL since I created the file by copying it.

keywords: howto invoke cygwin scripts from the windows desktop, write a dos batch file to invoke shell


Thursday Jul 16, 2009

And Google's Android

In case you havn't heard, Google have ported their mobile phone OS, android to x86, and made a live- cd version and so it can run inside Virtual Box. It looks like this..

Android in VB Screenshot

Since the hardware to make calls isn't available the functionality's a bit limited :)


Another Virtual Box screenshot, this time Windows 7

This is what Windows 7 beta looks like running inside a Virtual Box.

W7 in VB Screenshot

I have downloaded objectdock and opened a sticky window. Its not very quick, but my first suspicion is that its a bit short of memory. That's the problem with using a 32 bit host.


Thursday Jul 02, 2009

And now I have a Centos VM

The reson for upgrading my Virtual BOx config is to install a Red Hat Centos image. I chose 4.7 because this seems jolly popular within the hosting community and I need a new host for my web servers. Two pieces of advice

  1. Download the x86 DVD image, I couldn't see how to use the multiple disk images with Virtual Box.
  2. It installs an SMP and uniprocessor version and grub is configured to start the SMP version as default. This thread, entitled CentOS 4.7 guest won't start, suggests that one should configure PAE/NX=on for the SMP image. This is not the default. Anyway works for me.

Now I need a manual to help through all those little differences between it and Ubuntu. Is been a couple of years since I played with Red Hat's Linux.


Virtual Box 2.2.4 & Windows XP

And with one might bound he was free..................

I downloaded Virtual Box 2.2.4 a couple of days ago, but when I tried to install it on my XP SP/3, the install process failed and rolled back. This trouble ticket, #3701 details how to fix the windows registry which was damaged at v2.2.0.

Thanks to those who helped me find it.

tags: ""

Tuesday Feb 17, 2009

How to set up a USB Flash Drive from Windows to Windows in Virtual Box

Read the User Manual, available on and think "all that stuff you need to know that's a bit poor". Then,

  1. Make sure the windows guest is dormant
  2. Plug the Flash Drive into the Computer
  3. Edit the VM Settings
    1. Enable USB
    2. Enable USB 2.0
    3. Create a Filter
      • move the mouse over the add filter button and the USB devices will appear in the display box. This box is active. Select the one you want. If this is not obvious, then you can test this by removing the USB In the example above I have also taken Sasquatch's advice and created an empty filter which will assign all USB devices to the guest operating system. This is however disabled.
  4. Start the VM and wait for Windows to do its plug and play magic.
Virtual Box USB Settings Editor

This process was developed using a Windows Vista 32 bit guest and a Windows Vista 64 bit host, and a patched version of Virtual Vox 2.1.3

I have left the "All Devices" filter disabled. It will do all devices and thus some system devices will become visible to the guest such as the fingerprint reader, and whatever Chicony Electronics provide.

Sasquatch is a regular correspondent at virtual box forums and offered his advice in a thread called "USB on Windows host and Windows guest".


Tuesday Feb 03, 2009

Do we need private community microblogging?

Is twitter or microblogging a service that would benefit from more active community management? It would seem that the people at friendfeed seem to thinks so but the people at Laconica have produced a package that allows for the hosting of a microblogging community, which was pointed out to me by Peter Reiser and Scott Matoon.

Despite Peter Reiser’s statement (on his twitter feed at 1.41 am GMT 3rd Feb) that it installs on Solaris like a dream, I chose to install on Ubuntu Linux and there is a specific install page for Ubuntu at the Laconica site. It’s also useful to look at the >>README as it documents the pre-requisities and discusses the location of the site within the webserver's root namespace in more adult fashion than the Ubuntu install page.


I have written up my install notes on my snipsnap, and must try and get them adopted at the Laconica site. I have also repeated them in the [Read More] section below, but once its properly installed I made a post, changed my avatar and checked the RSS, and I did it all in a Virtual Box image.


[Read More]

Monday Jan 26, 2009

Laptop Diaries, 64 bitness & VPN

Over the last couple of days I have been struggling to get my new laptop build up to the minimal level of functionality I require, using Vista 64 as the host operating system. I calculated that I installed 19 applications on the previous minimal build, of which only Scmapp could be considered unnecessary. My colleague, Kar Yang Ho recommended Windows Vista 64 bit as the host and after some experimentation, we chose Virtual Box as the VM manager, primarily because its much cuter about how it takes and reserves disk space.

We use CISCO's VPN solution to access certain services and have been struggling to get this to work from behind my Linksys Wireless-N ADSL2+ Gateway; the connection was failing. Firstly, we discovered on purchase, that one has to use a TCP carrier without NAT. I am seeking to install the VPN client inside a 32 bit virtual machine; CISCO don't have a Vista 64 implementation. Ho says that no one else with this router has the problems I had with it, although we have now fixed the connection by specifying the guest network interface as a “Host Interface” and not the default “NAT”. It seems that the Linksys only wants one NAT function in the configuration.

I am pleased that we have fixed it, as I can now use Virtual Box to boot up Linux and Opensolaris images for experimental work and demonstrations. I also use them as X Server's for remote systems work and I have a Windows 32 bit image for that software that can only run in 32 bit windows such as the CISCO client.

I installed the AMD64 version of Virtual Box on my Toshiba Tecra M10, with 4Gb of RAM on Vista Business SP1.


[Read More]

Wednesday Jan 07, 2009

+1 to virtual box

I installed a planet instance inside an Ubuntu Guest Virtual Box VM, and it failed the install tests. I was gratified to discover that a native instance of planet/ubuntu 8 failed in the same way. +1 to Virtual Box. Now onto fixing it.


Tuesday Oct 28, 2008

Using Virtual Box's shared folders

I have taken advantage of Virtual Box's shared folder feature. I used the GUI to define one of the windows host folders as readable and then issue a mount command

mkdir /public
mount -t vboxsf ${vbox_folder_name} /public

proving this works, I then insert a line into /etc/fstab,

import    /public    vboxsf

issue the mount -a command. There are no errors reported and df shows the file system as mounted. I have rebooted the VM and the filesystem mounts fine.


Virtual Box 2.0.4

I have taken the opportunity to upgrade to Virtual Box 2.0.4. The upgrade for Ubuntu 8 goes fine, although EZ-Web is barfing on the upgrade; I have forgotten some password I need. (Hmm, I wonder if I should try the command line, or closing the postgres service first.)

I have amended my proxy set up script. I had not read the documentation carefully enough and tried to set up the proxied ports while the VM was running. This is bad. The new script now displays the parameters set,

case $2 in
make)   echo $0 make proxy
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/${key}/Protocol" TCP
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/${key}/GuestPort" ${port}
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/${key}/HostPort" ${port}
show|list|display) echo $0 list parameters for $key
        for property in Protocol GuestPort HostPort
           ./VBoxManage.exe getextradata "Ubuntu 8" \\
rm|remove) echo $0 remove proxy
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
        ./VBoxManage.exe setextradata "Ubuntu 8" \\

I set the key variable earlier in the program. As you can see I have used two idioms now, i.e. iteration and sequence and I am sure a horrendous function could make the code much more economic. However it would have a non real name like act or do which is a clue to a design error. I wonder what it would look like in Python. Mind you, another reason this code is so repetitive is that the shell interpreter doesn't do associative arrays. Boo!

The program now takes two arguments one to define the service and one to define the action. This is why the example above uses $2 as the case argument. The previous version of the code was published earlier this month here on this blog.


Wednesday Oct 15, 2008

Using a Virtual Box service

I want to run a web service inside a Virtual Box container and consume it from initially the host OS, but later from other systems. This article describes how I accessed an apache served page from and Ubuntu 8 VM.

Using Virtual Box 2.0.2, I read the manual version 2.0.2 chapter 6.4 which talks about allowing the host to utilise port services on a guest. I have a windows host, and a Ubuntu Linux guest.

Despite the problems I have with the IT provided build, fortunately I have cygwin on the machine and so have an easy to use scripting language. Most importantly I have a rigourius 'cd' command with directory completion, my tcl and python shells are a lot fussier about the windows xp 16/32 bit name translation. So in the folder containing the program VBoxManage.exe, I create a script containing the following code,

# need to force the shell, wonder how you do that

USAGE="$0 [make | [rm|remove] | help ]"

case $1 in
make)   echo $0 make proxy
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache2/Protocol" TCP
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache2/GuestPort" 80
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache2/HostPort" 80
rm|remove) echo $0 remove proxy
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
help)   echo $USAGE ;;


I run the script with the argument 'make'. The token "Ubuntu 8" agrees with the VM name, and the token apache2 is afaik, anything I want so long as it agrees. Having run the script, I can boot Firefox in the host OS instance and see the guests default web page, using the URL Oddly, http://localhost is resolved as something else, but I expect its the apache configuration file that does this.

What next, snipsnap?


Monday Oct 13, 2008

Sound and shares with Virtual Box

I have just upgraded from Virtual Box 1.64 to 2.0.2 and decided the time has come to turn the sound on and install shared folders.

These are both simple configuration changes since the manual is simple, well written and correct. [ User Manual 2.0.2 ]. Just to remind you, I have a windows host and in this case an Ubuntu 8.0 Linux guest.

In the settings panel for the VM, there is a sound tab, and there is a check box, which is defaulted to off. For a windows host, there is a choice of sound drivers. Since one of these is a null driver, its best to choose the other which is "Windows Direct" sound.

virtual box sound tab

There is a another tab for shared folders, with a file system browser. The purpose is to designate a host file system to act as the target for a guest mount and so act as one route to allow data to exit the VM.

This is what I did,

  1. Create a folder to act as the shared folder.
  2. Use the Virtual Box control panel to specify the shared folder and its device name. I used a folder in 'My Documents' folder and called it hostfs, for host file system.
  3. Boot the VM
  4. Make a mount point, if you want, otherwise use one already there.
  5. Issue a mount -t vboxsf share mount_point. The share is the device name declared in the control panel, in my example 'hostfs'. N.B. The fs type is suffixed with 'sf', presumably for shared folder and not fs for file system like many other file system types.

I then unmounted the shared folder, edited /etc/fstab and issued a mount -a command to test that my syntax works.


Thursday Oct 09, 2008

Laptop Diaries, about video drivers

Recently I have written about problems I have had with pidgin xmpp chat rooms, however, I have also come across a problem where I can't switch between the Firefox 3 control panel and rendered page, so I looked to see if anyone else had a similar problem. I found this article, called Can't Click Inside Firefox 3 Window Without Losing Focus 1st at, where yesterday, someone posted that new nvidia drivers had helped him solve the problem. So a quick visit to Toshiba UK's support portal and I discover that the most recent driver is over 6 months old, so I grab that an install it. I suppose its one of the problems in taking someone else's build. I now obviously need to wait and see if the problem re-occurs but so far so good.

Given I have new display driver, I have decided to re-install Pidgin 2.5.1 and its associated GTK library. This also seems to be working OK and I have not yet had a problem with the XMPP rooms. I also documented the problems here..., on my Bliki.

I am running a Toshiba Tecra M5 with Windows XP as the OS. I have Sun xVM Virtual Box to let me run Open Solaris and Ubuntu Linux. I take the windows build from our IT department.

tags: ""

Tuesday Sep 23, 2008

More about Pidgin and XMPP

I've spent the day struggling with Pidgin, XMPP and Google Talk. I am still using Pidgin V2.0.1 on Windows XP, with GTK+ 2.10.11. Today I tested Pidgin 2.5.1 and GTK+ 2.10.11 and discovered that I couldn't get it to work with Google Talk. I also discovered that the reliability of XMPP service was dreadful, although I discovered later that this may have been a server issue. I'll have to try again later in the week.

I have documented the state of my findings at Pidgin and Google Talk, at my bliki.

tags: ""




« April 2014