How to clone / duplicate VirtualBox disks

I’ve totally moved from using VMware to VirtualBox for my desktop virtualization needs. I like it because it’s opensource software and is available for all major platforms with features are growing fast.

When I install Windows or Linux on a VirtualBox virtual disk I like to backup it up in order to “freeze” it or have an “snapshot” with the basic install I can use as the basis for other VMs. The problem is just copying the disks and renaming them won’t do the trick because the UUIDs get duplicated and the program complaints about it.

So the proper way to do this is not just copy the disk but use the VBoxManage command that comes with VirtualBox for this task like this:

VBoxManage clonehd origin.vdi destination.vdi

The output of the command goes like this:

VirtualBox Command Line Management Interface Version 3.0.10
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: ae7ff94b-a7e6-402f-82c7-5d3d7f38a
020

If you have trouble with this command try removing the disk from the Virtual Media Manager and then cloning. Look for the cloned disk image in the ~/.Virtualbox/HardDisks/ directory.

Now If you’ve already copied the disk from some other computer and you can’t clone from the original this other command can save your day:

VBoxManage internalcommands sethduuid copied.vdi

So at this point the derived VDI file has it’s own UUID and VirtualBox won’t complaint. Just add it to the list in the Virtual Media Manager and use it with a VM.

Creating an Ubuntu LiveUSB from the ISO file in OS X

I’m going to install Ubuntu 9.10 in a couple of machines at home so I needed to create a LiveUSB for that since burning CDs is so old school and mostly wastes the disk. After doing a quick search for a graphic tool for that I ended up resorting to the good old Unix dd command for the task like this:


Click on the image for the full size view.

Steps go like this:

  1. Grab the desired ISO file from the Internet. Verifying integrity with MD5 is a good idea.
  2. Open a Terminal emulator window.
  3. Get the current list of devices by running “diskutil list”.
  4. Insert your USB key
  5. Determine the device node assigned to your USB drive by running “diskutil list” again (e.g. /dev/disk2)
  6. Run “diskutil unmountDisk /dev/diskN”. In my case the device was /dev/disk2.
  7. Use DD like this “dd if=/path/to/ubuntu-9.10-beta-desktop-i386.iso of=/dev/disk2 bs=1m
  8. Finally, eject the media by running “diskutil eject /dev/disk2″ and remove your USB drive when the command completes.
  9. And that’s it. If you have been following this steps, you should have a bootable Live USB with Ubuntu by now.

Installing Apache Tomcat on OS X via MacPorts

Apache Tomcat is the very popular opensource reference implementation of the servlet and JSP specifications put together by the members of the Apache Foundation from an initial codebase donated by Sun Microsystems.

I’ve been playing a bit lately with running Django web apps in Tomcat by deploying them with all of needed python-dependencies as a single WAR file. I plan to write a detailed post on this stuff in the near future.

In this post I just want to show you how easy is to have Tomcat 6 running on Mac OS X using MacPorts:

1) You must have MacPorts installed on your Mac. This guide will help you with that.

2) Install Tomcat 6 using the port command of MacPorts

sudo port install tomcat6

This step will take a few minutes depending on the speed of your Internet connection and how fast is you CPU. MacPorts will download the sources and compile Tomcat as well of all of it’s dependencies which include kaffe, ant, xercesj, junit and some other 19 additional ports.

3) Start up Apache Tomcat

sudo tomcatctl start

At this stage you can point your web browser to localhost:8080 and you’ll see the default Apache Tomcat web page like this:

In future posts I’ll be playing with Tomcat integrating it with Django and Rails through jython and jruby respectively.

Renaming downloaded MP3 files with Ruby

Hi there. This post is just an excuse for doing this 3 things:

  • Creating a new post. I haven’t really posted to this blog in a while
  • Try out the Pastie embedding functionality here
  • Provide a place to look for this script later when I’ll need it

Once that has been disclaimed I just want you to know that I’m a big podcast fan and I generally and up selectively downloading MP3 files for many podcast episodes using wget. Problem is sometimes the links I copy & paste to the shell or some Bash script include query strings with many aditional parameters and the resulting filenames end up including these long query strings in them.

So, in order to rename this files I just wrote this Ruby script which I’ve just copied to /usr/bin/mp3qsrm on my Leopard partition:

I don’t do Ruby on an everyday basis like I do Python nor I have a ton of years of experience like I have with PHP so whenever I’m coding Ruby reference like this tutorial is very useful. I’ve you are a coder I think you should take Ruby for a spin. Both Ruby and Python come installed by default under OS X and it’s very easy to install on a Linux distro.

Running Mercurial on OSX with MacPorts

I just needed to check out some code from a Mercurial repo and had to have Hg installed on my MacBook so I went to easy and straight way and executed this command:

sudo port install mercurial

Everything worked as expected and Mercurial got installed. MacPorts had to download and build Python 2.5 which I didn’t have because I’m currently using Python 2.6 in order to test some Django apps with it but it wasn’t an issue because this doesn’t interfere with my current Python setup. The problem was I started getting this errors while attempting to use hg:

Traceback (most recent call last):
  File "/opt/local/bin/hg", line 25, in 
    mercurial.util.set_binary(fp)
  File “/opt/local/lib/python2.5/site-packages/mercurial/demandimport.py”, line 75, in __getattribute__
    self._load()
  File “/opt/local/lib/python2.5/site-packages/mercurial/demandimport.py”, line 47, in _load
    mod = _origimport(head, globals, locals)
  File “/opt/local/lib/python2.5/site-packages/mercurial/util.py”, line 93, in 
    _encoding = locale.getlocale()[1]
  File “/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py”, line 462, in getlocale
    return _parse_localename(localename)
  File “/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py”, line 375, in _parse_localename
    raise ValueError, ‘unknown locale: %s’ % localename
ValueError: unknown locale: UTF-8

So, after a bit of googling I realized I hadn’t properly set my locale information since I reinstalled Leopard. So adding this two lines to my $HOME/.bashrc which is also called by my $HOME/.bash_profile solved the issue:

export LC_ALL=es_ES.UTF-8
export LANG=es_ES.UTF-8

I’m posting this here for my own reference and for helping someone out there having this same issue.

This is how I spent the second 1234567890 of the UNIX epoch

I almost miss it! It had scheduled a twit using twixer and the at command earlier this week as a reminder but I didn’t see it. Lucky me I was still at the office with a few nerdy co-workers who also we expecting the glorious 1234567890th second since the beginning of the UNIX epoch :)

I got alerted by @Yonsy about massive amounts of people joining channels like #1234567890 on Freenode so I jumped in. For warming up I posted a quick twitter update around 1234567747, that was only 143 seconds or 1′23″ before 1234567890 :)

So I needed to see it right? So my first thought was firing up yet another terminal emulator window and then started typing this tiny shell script:

#!/bin/sh
while [ 1 ]; do
  date +%s
  sleep 1
  clear
done

I finished writing and running the script some 15 or 20 seconds before the big moment so it was just a matter of waiting and hyping up my friends about it since I actually got to see the output of date +%s by myself on my Ubuntu box :)

Then, I simply took this screenshot you see here so you can see what my view was like at the very cosmical moment. I wish I had programmed my box to take a shot at the very right moment but this shot 235 seconds late is not such a bad substitute.

This whole post is a huge testament of how nerdy some of us are, hehe.

Using twitter from your IRC client with tircd

Today many friends are celebrating the Twestival at the local party here in Lima, Peru but i’m currently at the office catching up with tons of work and academic stuff. So I decided to try my hand at something twitter-related today as a very geeky way of celebrating the already geeky Twestival so I took tircd for a spin around the block and this is what I found:


Autogenerated IRC channel with all my twitter contacts with X-Chat

Yes! It’s a nice concept: the way tircd works is by running an IRC server on localhost, by default using the standard IRC port of 6667. You have to connect to this server setting your nickname to match your twitter username and then authenticate to the IRC server using your twitter password. Once that’s done you can join the #twitter channel and you’ll see all of your contacts as if they were people hanging around. When you wanna twit, simply post a message to the channel.

I use X-Chat for IRC on Linux and Mac OS X. It has a handy way to set the password to use when connecting to a given server from the server list. Your favorite IRC client (mIRC probably) must have something like that but in general you can type the following IRC command to connect to the tircd server:

/server 127.0.0.1 6667 your_twitter_password

This perl script is not a simple IRC bot like, say, twitterircbot. It’s the whole twitter experience mapped nicely into the IRC world: You can start following users with /invite and stop following them by kicking’em with /kick. Direct messagging also work: simple send an IRC private message to the user and tircd will dm it. So far, so good.

One tiny bit of the IRC experience that didn’t got correctly mapped to the twittosphere practices was a reply. On IRC you most probably start your message with the nickname of the person you’re talking to followed by a colon or a comma like in dude:. That could have been turned into some @dude perhaps but well, it’s a little quirk I’ll see if I get some time to correctly patch since, for example, you could check that the nickname exists as a twitter username before prepending the at sign. My status numbered 1205023434 is a little testament to that :)

Other details work correctly. A few of my direct messages appeared as private messages as you can see in the upper left corner. I had some direct messages from people like @breno, @Slayer_X or @lauvmg. My general impression is quite good which is congruent with a 0.6 release.

I was able to install the dependencies of tircd on my Ubuntu box simply by running:

sudo cpan -i POE POE::Filter::IRCD Net::Twitter

After many times hitting the return key in order to accept the defaults, the ancient gods the mightly CPAN did the magic and a bunch of perl modules got installed.

After that, I grabbed the tircd from Google Code like this:

wget -c http://tircd.googlecode.com/files/tircd_v0.6.zip

The last step was unzipping the file and running tircd with:

screen ./tircd.pl tircd.cfg

Finally, I hit CTRL+A and the D and had the perl process deattached from my terminal which is handy if you plan to run the process for a while. You can skip using GNU Screen if you’re only trying tircd out.

Wow! It’s been a long long time since my last post all the way back to Halloween 2008. Yeah, I’ve been mostly busy but yes, I’ve neglected a bit this little blog of mine but hopefully that’ll be changing from now.

Halloween 2008

When I was a kid here in Peru we didn’t celebrate Halloween at all. October 31th is for the day of peruvian folk music and tomorrow is also a holiday but today Halloween time got us inspired at work and got some pumpkins to carve some cool designs on them.

Since we are a Django shop at Aureal we got this Django pumpkin carved:

This is how my desktop looked today for a while at work. I’ve posted this pic to Deskograpy too.

Installing Cherokee 0.9.x on Ubuntu Hardy

The Chrerokee Web Server is an extremely fast modular opensource HTTP daemon written by my good friend Alvaro Lopez Ortega from Spain. The project has recently been making great progress towards the 1.0 release. The product has been very stable for years and since version 0.6 includes a web-based administration interface so you can avoid tweaking text files manually like you still have to do with Apache, Lighttpd or nginx.

Installing the latest Cherokee package in Ubuntu Hardy can be a little tricky. The version that’s included with the distribution is mantained by the MOTU team and based on the Debian version mantained by another good friend Gunnar Wolf from Mexico.

The packages for the latest version of Cherokee are mantained by Leonel Nuñez, also from Mexico, and are found in his PPA apt repo so in order to install them on Hardy you have to follow these steps:

STEP 1) Add the PPA repo to /etc/apt/sources.list

Simple adding this two lines to the files does the trick:

deb http://ppa.launchpad.net/leonelnunez/ubuntu/ hardy main

deb-src http://ppa.launchpad.net/leonelnunez/ubuntu/ hardy main

STEP 2) Configure the prefered version of the packages at /etc/apt/preferences

This is the most tricky part, simply add these lines in this file. If you don’t have it just create it.

Package: cherokee

Pin: version 0.9.4-1*

Pin-Priority: 999
Package: cget

Pin: version 0.9.4-1*

Pin-Priority: 999
Package: libcherokee-base0

Pin: version 0.9.4-1*

Pin-Priority: 999
Package: libcherokee-base0-dev

Pin: version 0.9.4-1*

Pin-Priority: 999
Package: libcherokee-config0

Pin: version 0.9.4-1*

Pin-Priority: 999
Package: libcherokee-config0-dev

Pin: version 0.9.4-1*

Pin-Priority: 999
Package: libcherokee-server0

Pin: version 0.9.4-1*

Pin-Priority: 999
Package: libcherokee-server0-dev

Pin: version 0.9.4-1*

Pin-Priority: 999

When a newer package appears in the PPA repo it will be installed or upgraded. Version 0.9.4-1 is there simple because it was the current packaged version at the time of writing this blog post. The important bit is having Cherokee 0.9.x and not Cherokee 0.5.6 installed in your box.

STEP 3) Update your APT sources and install Cherokee

$ sudo apt-get update

$ sudo apt-get install cherokee

That’s it. Give it a try! I’ll be using it for serving static content here on my blog.

Podcast recommendations

Today it’s a national holliday here in Peru and I just came to the office to catch up with some bit of work and all the way here from home I’ve been enjoying a very interesting interview with Anders Hejlsberg, the creator of C# and Chief Language Strategist for Visual Studio at Microsoft. He talks about many topics but the most interesting bits were about the advantages of dynamically-generated static code like they do with LINQ and ASP.Net as opposed to using dynamic languages.

This podcast is part of a great show I’m now a fan of: Software Engineering Radio. They have been interviewing some big names recently and I’ve been enjoying the episodes with Erlang’s Joe Armstrong or CORBA’s Steve Vinoski. A great show, the interviewer knows very well the software developing field and suggest really nice topics. I have many of this SE Radio podcasts waiting in the pipeline including topics like relational databases, SOA, functional programming, aspect-oriented programming, REST, transactions and many other currently relevant subjects. Free Software fans can find an episode on GNU GCC and UML fans can find one with Grady Booch as the guest.

Other podcast i’m a big fan of are the always great programs at IT Conversations, DotNetRocks and of course FLOSS Weekly and Security Now among others shows from the Leo Laporte’s  TWiT network. Leo is a great radio commentator and the guy who helped podcast become popular.


Leo Laporte

For Linux I used to enjoy The Linux Action Show a lot but haven’t listened to the show in the past few months. Before I tried listening a bit to Jono Bacon’s LUG Radio.

There are certainly a few other podcast I listen to or used to listen in the past. Last year I used to catch up with the major Rails news by listening the Rails Envy podcast and this year I’m complementing my following of Django listening to This Week in Django. If you’re interested in a PHP podcasts you could try PHP Abstract.

So this blog post is all about saying thanks you to the people behind the many podcasts I’m listening again since I got a portable MP3 player again since the one I previously had got the earphone jack broken somehow.

Some guys from these shows tell you to spread the word about their podcasts and it’s something I definitely feel good to do since I really enjoy their work.