Search This Blog

Friday, January 28, 2011

VirtualBox 4.0 Machine Cloner

I've written a simple application in Java for cloning Virtual Machines.
My environment includes Ubuntu 10.04 Server Edition with btrfs file system.
There is an option of reflinking files in that fs - which means a little like
'copying them without taking any space', just making references to source file
and creating a diff file instead. Only the changed-parts of the file are stored on HD :).

The application uses reflink option and it's main purpose is to clone VMs.
I will just describe its main functions - configuration and run of VBox Cloner will be added in
later posts.

- cloning machines of a specific user
- listing registered VMs
- changing source/destination clone directory
- source user check (which user should VBoxCloner user to register new VM)
- Issuing commands to VM - running in headless mode, restarting etc (which the main Virtual Box 4.0 GUI lacks btw.)
- Controlling VM snapshots - listing, restoring snapshots

VirtualBox Cloner is now open source :)!!!
project home page is located at:

Current release:
Previous one:

Documentation can be found here:

Monday, January 24, 2011

Generate C# (.NET) documentation easily

When I had to make documentation files to my last project in C# I had to use sandcastle which required creating a new project in my solution just for documentation. It was quite a complicated process and took me some time to understand why I had to all these steps in the first place. Back then I wondered if there exists an easier way - I just wanted to give a c# file and get a generated doc file.
Luckily there is an easier way thanks to SHFB (Sandcastle Help File Builder). You just point a solution and SHFB generates documentation for you.

Friday, January 21, 2011

MELD - diff tool for linux/gnome

Some time ago I was looking for a convenient tool for checking differences between text files. I couldn't install any additional library to the original gnome installation as it was a deployment server. I found MELD which is purely gnome-based.

Thursday, January 20, 2011

SDelete - nulling end of drive

To compact your virtual drive you have to:
1) defragment the guest operating system (usually WinXP defragmenter)
2) nulling the end of drive with sdelete:
3) compacting the vdi drive from host

VBoxManage modifyhd --compact  vdi_name.vdi

Nulling end of drive (writing zeros at the end) enables VBoxManage to compact the drive (cut out the nulled part) and make the vdi file smaller.

ICH9 bug on VirtualBox 4.0

CAUTION: This bug seems to be corrected from version 4.0.2 and above.
I noticed MUCH improvement after upgrading to newer version!!!
(like 100% bug repeatability to about 5% bug repeatability)


Seems there is a bug that will be fixed on upcoming builds of VBox 4 and it's the root cause of malfuncioning ICH9 on VBOX.

FROM vbox forum:

its a bug, you cannot reboot, you have to shut the vm down each time and start fresh


its fixed in latest code, but no build has been pushed as yet

VirtualBox 4.0 Installing Windows XP with SATA support

I already described the basic interface of VirtualBox 4.0 Command line here:

You can also stumble upon a problem while installing Windows XP with SATA controller VDI drive. There are two types of hardware controllers in "system" tab (VM settings) - ICH9 and PIIX3. I didn't manage to install WinXP on ICH9 yet but it is possible to install XP with SATA support.

All you need to do is add a "Floppy Controller" in storage tab and mount this image:

The when you install Windows XP press F6 during boot time and select:
"s" - load additional drivers
"Intel(R) 82801HEM/HBM SATA AHCI Controller (Mobile ICH8M-E/M)"
then continue with the setup process as usual.

Tuesday, January 18, 2011

Carrot - Search engine

There is a search engine called 'carrot' at the University of Technology in Poznań. Why don't you give it a try? It's not perfect but classifies results in graphs of classes of results.
e.g. carrot will give you:
carrot cake, wild carrot, art etc...

Sunday, January 16, 2011

Office 2010 - Web Licence Manager

I bought Office 2010 and installed it on 3 computers just as my licence allowed. Some time later I bought more RAM for my laptop so that I have 4 GB of RAM now. My Windows 7 says - 4GB RAM (2.90 usable). As I read on a few forums the only solution is to install Windows x64.
But how can I know that changing to x64 will come unnoticed by "the holy" licencing system of Microsoft - I don't. I paid for Office - I demand exact information on how my licences are STORED, MANAGED and what hardware, software information goes to Microsoft.

Enable TELNET on Windows 7

Today I noticed that there is no telnet on Windows 7 - actually it is just not enabled by default. It's probably a security issue as telnet is the most vulnerable to attacks protocol I can think of :) and Microsoft "is trying" to make Windows a safer place ;).

To enable telnet:

  1. Start
  2. Control Panel
  3. Programs And Features
  4. Turn Windows features on or off
  5. Check Telnet Client
  6. Hit OK

PYTHON - enable debugging

Writing a program in python is challenging when something goes extremely wrong. Fortunately, Python debugger is at hand.

Insert this line in your code where you suspect a bug to be hidden:

import pdb; pdb.set_trace() 
-> this causes the script to stop and a debug console pops out.

l -> to see a short listing of code of the place you're currently executing
dir(object_name) -> to display object's methods & fields

Saturday, January 15, 2011

CamStudio - FIX no audio BUG

Do you want to record your desktop (make a screencast) but you still struggle with  no sound in Camstudio?

Friday, January 14, 2011

Firebird - excellent manual

A handy manual to the Firebird database engine is located here:

Notepad++ - automatic parsing of malformatted XMLs

Notepad++ comes with a handy feature of formating XMLs. To format an XML go to:
TextFX -> HTML Tidy menu

If you don't have such a menu you need to add the following lines to your
C:\Program Files\Notepad++\plugins\NPPTextFX\tidycfg.ini file:

;sample config file for HTML tidy from
[Sample from Web Page]
indent: auto
indent-spaces: 2
wrap: 72
markup: yes
output-xml: yes

Oracle enable more processes, transactions and sessions

Execute this as sysdba:
alter system set PROCESSES=100 scope=SPFILE;
alter system set TRANSACTIONS=126 scope=SPFILE;
alter system set SESSIONS=115 scope=SPFILE;

Linux force fsck check on next system reboot

Just create a file in the main of your filesystem as root:
cd /
touch /forcefsck

Check what Ubuntu version you have

cat /etc/issue
lsb-release -a

Simple TAR usage (TAR for dummies :))

to compress:
tar cvzf allfiles.tar.gz  ./name/name_of_folder
tar cvzf allfiles.tar.gz  ./name/name_of_folder/*
tar cvzf allfiles.tar.gz  *.doc

to preserve permissions:
tar cvzpf allfiles.tar.gz  ./name/name_of_folder

to decompress to current directory:
tar xvzpf allfiles.tar.gz

x - extract
c - create
v - verbose
z - gz library compression
f - compressed file name
p - preserve permssions

Thursday, January 13, 2011

Xming Remote X11 server for Windows

If you want to connect to X11 to a linux-based system Xming is the way to go.
It creates a simple, lightweight X11 server on your Windows installation so that is extremely easy to connect.

Just install the newest version of:

Connect throgh ssh to a remote server and execute a script similar to this:

export DISPLAY=

Of course you can swap gnome-session with any of your favorite Graphical Desktop Managers (GDM).

SVN creating a branch

Creating a branch on SVN is extremely easy. All you need to do is use SVN COPY command.

svn copy svn+ssh://your/server/trunk svn+ssh://your/server/branches/MyBranch

Supposing that your 'trunk' is your head version and 'branches/MyBranch' is your branch folder.

In the above picture the left-hand line (9161 to 13905) is the main head line. I'd created two branches along the way from revision: 13515 and revision 13905.

One of the best things that SVN COPY does is that it DOES NOT COPY the files really - it justs links them. So that they do not take any extra space on your HD drive. If you commit to branch  only the changes are stored. It is very similar to  linux  BTRFS file system.

Monday, January 10, 2011

Disable Teredo on Windows Vista/7

Teredo was designed to deliver IPv6 connectivity to nodes that are located behind IPv6-unaware NAT devices. 
It is enabled by default and creates an encrypted tunnel to Microsoft which all your internet traffic will pass through after the global start of IPv6 which is bound to happen soon as IPv4 address pool is schrinking fast.  

To disable Teredo simply open a command line as an administrator and paste:

At the netsh interface teredo command prompt, type:
set state disabled

Sunday, January 9, 2011

WGET - downloading WEB page content

I needed to download all HTML content from wikipedia's american inventors category for later processing.

A few requirements:

  • don't leave the server stuck with too many requests at a time
  • retrieve all relevant info with as little irrelevant as possible

Tools:  Windows Powershell & wget

Remember that besides the normal "Powershell" there is something called "Powershell ISE" which stands for Integrated Scripting Environment. It offers highlighting of powershell scripts, running and displaying results. I liked the environment very much :)

inventors txt gotten from wiki and parsed in notepad++:



foreach ($webpage in Get-Content "inventors.txt")
    invoke-expression "wget --recursive -l 3 -U Mozilla --wait 1 ""$webpage"""

as simple as that :)

TIP: to enable execution of PowerShell scripts in Windows 7 run:
set-executionpolicy remotesigned

In wget:
-l 3 : means link depth, like searching the graph in DFS manner to the count of 3
--wait 1 : means wait 1 second before every request - for not to overflowing the server

Friday, January 7, 2011

Bayes BIF File Format (WEKA)

I've never heard before that there is a standarized format for representing Bayes Networks.
It's called BIF. It didn't fit my need 100% but I was able to import some basic information from BIF XML.

Some info:

Information I needed fom BIF was:
NETWORK[0].NAME - name of the graph
NETWORK[0].DEFINITION[7]  --> nodes

NETWORK[0].DEFINITION[x].FOR - names of nodes
NETWORK[0].DEFINITION[x].GIVEN - edge list (backward)  given in node names
NETWORK[0].DEFINITION[x].TABLE - CPT table for a single node - (Conditional Probability Table)

Basic tutorial on Virtual Box 4.0 command line

to start a virtual machine in GUI-less mode with Remote Desktop on:
VBoxManage startvm "WinXP" --type headless

to force poweroff:
VBoxManage controlvm "WinXP" poweroff

to register VM in VBox from predefined XML under certain user (active username):
VBoxManage registervm /root/.VirtualBox/Machines/WinXP/WinXP2.xml

to attach a VDI drive:
VBoxManage storageattach "WinXP2" --storagectl "IDE Controller" –type hdd --port 0 --device 0 --medium "/VMVirt/XP/2.vdi"

to clone a virtual drive (VDI) and change its UUID:
VBoxManage clonehd "full_path_in" "full_path_out"

convert drive to Fixed size (e.g. From growable type):
VBoxManage clonehd "full_path_in_vmdk" "full_path_out_vdi" --format VDI --variant Fixed

to change UUID of existing VDI drive:
VBoxManage internalcommands setvdiuuid somthing.vdi

to „hibernate” a virtual machine:
VBoxManage controlvm "VMTOMEK" savestate

to prevent machine from updating time/date from host:
VBoxManage setextradata "VMTOMEK" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1"

to run a command inside VM:
VBoxManage guestcontrol execute TC8 "C:\Windows\system32\notepad.exe" --username Administrator --password sys --verbose --wait-for stdout

to unmount current media:
VBoxManage storageattach <vmname> --device <number> --medium emptydrive
(or use --forceunmount if this does not work)
VBoxManage storageattach Debby --storagectl "IDE Controller" --device 0 --port 0 --type dvddrive --medium emptydrive

to mount media:
VBoxManage storageattach Debby --storagectl "IDE Controller" --device 0 --port 0 --type dvddrive --medium cd351a5b-a09b-4593-bf6f-e892def83aa9

to list dvd and get their uuids:
VBoxManage list dvds
VBoxManage list vms

Some self-explaining commands:
VBoxManage showvminfo "WinXP"
VBoxManage list vms
VBoxManage list runningvms
VBoxManage modifyvm "WinXP" --bioslogodisplaytime 10000
VBoxManage modifyvm "VM name" --vrdp on
VBoxManage snapshot "WinXP2" take "Snap1" –description "Initial snapshot"
VBoxManage snapshot "WinXP2" restore "Snap1"
VBoxmanage showhdinfo Ubuntu.vdi

Serializing/Deserializing XML files in C#

Suppose we start from a bare XML file we know nothing about. The easiest way to turn it to C# object is to use XSD executable from Microsoft SDK.

Mine xsd.exe was located in:
'c:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\xsd.exe'
There are 4 simple stept on how to use xsd and then Visual Studio to deserialize XML:

  1. Access Visual Studio command prompt from Start Menu > Program Files >Microsoft Visual Studio 2008 > Visual Studio Tools.
  2. From the current directory, type XSD.exe . This will list all the arguments and options for the said utility.
  3. To create a schema file from an existing *.xml file, type XSD.exe \path to your xml\filename.xml. The XSD file will be created on the current directory.
  4. To create a class file from the schema file, type XSD.exe \path to your schema\filename.xsd  /c . The class file will be created on the current directory.
In my case Config was the base class XSD tool has given me in output C# class:

            XmlSerializer s = new XmlSerializer(typeof(Config));
            Config newCfg;
            XmlReader r = XmlReader.Create("epuapcfg.xml");
            //TextReader r = new StreamReader("epuapcfg.xml");
            newCfg = (Config)s.Deserialize(r);

TIP1: Always remember that ALL classes must have parameterless constructors to be serialized!!!!

VirtualBox 4.0

Just a short note. 
There's a new version of VirtualBox - 4.0 
We'll be deploying it soon. Hope it's more stable than 3.x.

Bartosz Kosarzycki

Java SWING GUI update

Today I stumbled upon a problem updating GUI SWING controls in java from a single threaded appliaction. Adding a simple invokeLate method did not work for me. jTextArea was still not updating properly. The code for updating text area looked like this:
       final String MESSAGE = newLine;
       SwingUtilities.invokeLater(new Runnable() {
           public void run() {
               jTextArea1.setText( + ": " + MESSAGE + "\n" + jTextArea1.getText());
I added a second thread and some Thread.sleep(10);'s between actions to give time for GUI thread to do its job. Unfortunately this gave me nothing. You have to create a Thread class:
public class CloneThread implements Runnable{
  private int index;
  private VMCloneInfo vmClInfo;
  public CloneThread(int index, VMCloneInfo vmClInfo) {
      this.index = index;
      this.vmClInfo = vmClInfo;
  public void run() {
      VBoxClonerView.getVBoxClonerView().cloneVM(index, vmClInfo);
and use ExecutorService. This is the key element for all this to work.
ExecutorService myExecutor = Executors.newCachedThreadPool();
myExecutor.execute((Runnable) new CloneThread(jComboBox1.getSelectedIndex(), vmCloneInfo));