Archive for the ‘Sofware’ Category

How to shrink a VirtualBox vdi disk image size?

Monday, July 26th, 2010

Virtual disk images (.vdi files) tend to grow over time, especially with windows guest systems, and may quickly consume all your disk space on the host system.

This post shows the required steps to free up the unused space. It worked for me with Sun/Oracle VirtualBox versions of 3.1.6 and above.

For a Windows guest system

  • Start a Defragmentation (right-click disk icon, select properties->Tools tab-> Defragment now…)
  • Download Sdelete (about 47kb) into your guest.
    Wait for the defragmentation to complete.
  • Fill the free space of your vdi disk image with zeros executing

    sdelete -c

    from a DOS command line.
    This may take a lot of time (30min for a 20GB disk on my system).

    Don’t use the guest system during the process

  • Shut down your windows guest system.
  • Make a backup of your .vdi file.
  • On your HOST system, execute the following command in a DOS/terminal window:
    VBoxManage modifyhd diskname.vdi> --compact

    The VBoxManage tool is part of the VirtualBox standard distribution.

While I tried this only for .vdi files, it should work the same way for .vdmk files. The point is that the –compact option sorts out all sectors that are filled with zeros.

Enjoy!

Install VirtualBox Guest Additions in CentOS (RedHat) Linux Guest

Tuesday, September 22nd, 2009

When you try to install the VirtualBox Guest Additions for a Linux guest system, this will fail due to some weired ‘features’ in the installation. This post is based on my experience with VirtualBox 3.0.6.

To perform the installation do the following:
Choose Install Guest Additions... from the VirtualBox menu. Open a terminal window in your guest system. Do a

cd /media/VBOXADDITIONS_3.0.6_52128/
(the foldername will change depending on the VBox version). Proceed as described below.
(more…)

Add Undo/Redo functionality to a Java app

Tuesday, August 4th, 2009

Recently I had to figure out a way to add undo/redo functionality to an existing Java application. Searching the web for some guidance I got a bit scared by finding posts that gave the impression that undo in Java is an overly complex thing that requires 10+ mysterious classes, best combined with reflection and modified GoF patterns.

I write this post to show you how simple undo in Java is and how it can be easily added to an existing application. You do not need to study Command patterns or rebuild half of your app, just follow the pragmatic approach described below and add a few simple classes to your application!

In our concrete case the requirement was to add undo functionality to an existing Excel-like spreadsheet application that had a horrible menu management and no patterns in it at all. (more…)

Export from Displaytag inside a Portlet

Sunday, December 14th, 2008

The Problem:
When using Displaytag inside a Prortlet, the export functionality will not work because the portlet has no way to produce other than it’s portlet content for display (see http://jira.codehaus.org/browse/DISPL-344).
Since Displaytag export functionality produces downloadable content that the portlet container will interpret as a portlet render result, you will see the Displaytag output as HTML-rubbish.

The Solution:
When we came over this problem, a promising solution seemed to be the one described in this post:  http://www.jroller.com/hakan/entry/liferay_portal_4_1_2,  but nobody was able to get it running.
Based on the concept in this post I came up with the following simple idea: If the problem is, that the output is produced by something inside the portlet, than the solution is to produce the export result outside of the portlet. And it works.

It works like this:

  1. Disable the standard Displaytag export functionality
  2. Create a copy of your page and place it somewhere outside the portlet
  3. Add manually links to the copied page, providing the parameters required by Displaytag

Let’s look at this in detail on a concrete example:

(more…)