From the Canyon Edge -- :-Dustin

Thursday, July 29, 2010

TestDrive, then and now

Less than a year ago, I introduced TestDrive, a convenient way of incrementally syncing ISOs from, and running them in KVM, VirtualBox, or Parallels. It's a great way to do your ISO-testing, or just keep up with the Ubuntu release under development. I created the project for a couple of reasons:
  1. To make it even easier to run Ubuntu in a virtual machine
  2. To show off KVM (without the overhead of libvirt or virt-manager)
  3. To make the daily development releases of Ubuntu safely usable by non-technical Ubuntu enthusiasts (who inevitably show up the week before release saying that they just tried the Beta or RC for the first time, and "by golly -- stop the release -- it's not ready!!!"
Well, TestDrive has come a long way -- mostly thanks to Andres Rodriguez, my Google Summer of Code student who has put a nifty GTK front end on TestDrive!

If you haven't tried the TestDrive GUI yet, please check it out. You should be able to install it directly from Maverick, or using the backported packages for Lucid from the PPA. With one command (or, now, one graphical button click), you can have any Ubuntu ISO up and running in a virtual machine!

Please let us know what you think! You can leave opinions here in the blog comments, but please file bugs against the project in Launchpad.

Also, I'd like to add a "file handler" in Gnome, such that you can right-click on an ISO, and select "Open with TestDrive". Can anyone tell me how to do this?


Wednesday, July 28, 2010

Does the gild go on first, with the gouache applied afterward?

I get questions like this from time to time, so I figured I'd respond here...

Someone wrote:
> Hey Dustin,
> I'm a student trying to do some experiments with Byobu Japanese Screens. It's almost
> impossible to find anything on the web that tells me what the atavistic process is. Eg, does
> the Gild go on first, is the gouache applied after , if so what kind? etc.
> I don't know if I've completely mis-understood the essence of what I've read on the pages
> below, but does this link take me to a program that helps design BYOBU, or is it just the
> name you are using?
> Totally confused!...Look forward to hearing from you.


Thanks for the note. I am afraid that the Byobu program does not help design the beautiful Japanese folding screens, or anything like that. I chose the name because:
  • the old name was boring
  • there were not many search hits for the word "byobu" (as you found out!)
  • it rhymes with GNU, and Ubuntu
  • it is a thought-provoking analogy for what the program is
To understand that analogy, you need a bit of computer history.

GNU Screen is a revered UNIX/Linux program that's been around for ~25 years. It actually predates Microsoft Windows as many of us first knew it. GNU Screen is a text-based program that enables you to run multiple computer programs at the same time.

Today, with modern operating systems, such as Windows, Ubuntu, or Mac OS, you just open up each program in a new "window" (which is another analogy!). But before computers were graphical, GNU Screen provided an innovative way of running multiple programs at the same time.

Many UNIX/Linux users have continued to use the GNU Screen program over the years, but the very plain interface to it, and configuration of it hasn't changed much in that time, and the complexity blocks some new users from utilizing it.

In December of 2008, I wrote a new interface that uses the old GNU Screen program under the covers, but has a more useful interface and easier configuration, making it accessible to more users. The first name of the project was pretty boring -- Screen-profiles. But in May of 2009, it got its current name, Byobu.

And so the analogy...

In the same way that Japanese byobu are detailed, elegant, beautiful enhancements of ordinary folding screens, the Byobu program is a detailed refinement of the plain old GNU Screen program!



Monday, July 26, 2010

Cogito Errno Sum

Ah, POSIX error codes. When systems programming, do you ever find yourself with an unfamiliar error code, and then you're off Googling what the heck it actually means? Where's the command line utility to just do this for you, right where you're at, in a terminal? It's actually pretty easy, with a glorified grep...

Try this script, which I store in ~/bin/errno:

#!/bin/sh -e
if echo "$code" | grep -qs "[0-9]"; then
grep -hw "\W$code\W" $headers | sed 's/^#define\s*//'
grep -hi "$code" $headers | sed 's/^#define\s*//'

Now, you can run:

errno 36
ENAMETOOLONG 36 /* File name too long */


errno EEXIST
EEXIST 17 /* File exists */

Is this useful to you? It has been really useful to me any time I'm doing system level programming or debugging.

I have long wanted to drop this little script in /usr/bin/errno, but I haven't found the right package to own something like this. Maybe a kernel package, since it uses the kernel headers? Opinions? Let me hear them!


I think, an error number, I am :-)

Dear Bash, please ping me when you're done running $FOO

UPDATE: The "alert" alias has landed in Maverick's /etc/skel/.bashrc ... thanks for your support!!!

How often do you run a command line tool on your desktop that takes a really long time? Maybe something like make, debuild, rsync, or wget?

You probably kick off the long running job, and then alt-tab over to something more captivating than watching gcc fill your scroll back buffer -- maybe your web browser or news reader.

You occasionally pop back over to your shell to check on your job. Maybe it's still running. But maybe it finished a while ago. Dang.

No need to beat yourself up over wasted cycles. You can tell your shell to ping you when it's done. Just add this alias to your ~/.bashrc.

alias alert='notify-send --urgency=low -i "$([ $? = 0 ] \
&& echo terminal || echo error)" "$(history|tail -n1| \
sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

Install the notify-send utility, and source your new ~/.bashrc:

sudo apt-get install libnotify-bin
. ~/.bashrc

Now, run a long running job, and append "; alert" to the end of the command, like this:

sleep 20; alert

After running the target command, the alert alias will render a notify-osd pop-up on your desktop, telling you the command you just ran, and its exit code.

Nifty, huh?


Tuesday, July 13, 2010

Man your Browser!

I've been spending more and more time on smaller laptops and netbooks. I recently gave the Chromium web browser a try, and I must say that as of Ubuntu 10.04 LTS, Chromium has totally won my heart! It's quite efficient, snappy, and user-friendly.

It took me a little while to learn some of the ins and outs, but I think I've replaced all of the functionality I needed from Firefox.

The most useful feature I've found are Chromium's custom "search engines". Here, I'll demonstrate how to add a custom to Chromium's search engines, such that you can type something like "man kvm" in your browser's URL bar, and go straight to the HTML rendering of the kvm manpage!

  1. Click on the wrench in the upper right corner
  2. Select Options
  3. Click Manage near the Default Search option
  4. Click Add
  5. Name: Manpages
  6. Keyword: man
  7. URL:
  8. Click Add
  9. In the browser, ctrl-L to goto the URL bar
  10. Enter man kvm
And you win!

I actually use several of these every single day...
  • man
  • ls
  • bug
  • pkg


Wednesday, July 7, 2010

LinuxJournal 2010 Readers' Choice Survey

LinuxJournal has opened their 2010 Readers' Choice survey!

Ubuntu, and Ubuntu-based projects are prominently featured in quite a number of survey questions. Whether you like what we're doing or not, LJ's survey is an excellent year-over-year monitor of what's hot, and what's not in the Linux world.

There is a free-response question toward the very end of the survey asking for your favorite new open source project from 2009 or 2010. The Ubuntu community has generated a vast number of excellent new projects in 2009 and 2010. I certainly encourage you to help support one of your favorite projects in that question.

My favorite new project from 2009-2010? Byobu :-) Toss a vote our way, if you think we're doing some cool stuff, and you'd like to support our project!


Friday, July 2, 2010

Keeping Pictures from Multiple Cameras in Temporal Order

I use as many as 4 different cameras, each serving a slightly different purpose.

In order decreasing order of portability, and increasing order of photo quality:
  1. Pocket -- a low-quality, but always present camera phone (either my Palm Pre or my G1)
  2. Small -- Canon Powershot SD1000
  3. Medium -- Kodak z812 IS
  4. Large -- Canon EOS Digital Rebel XTi
When I'm traveling, I might take 2 or more of these cameras, and shoot pictures all day long on different cameras. Sometimes, I'm shooting with one camera, and Kim is shooting with the other. At the end of the day, I want to merge all of these pictures, and look at them in order.

To keep this straight, I take great care to ensure that the embedded clocks in all of these cameras are perfectly in sync.

And when I'm processing my pictures, I often use gthumb to rename my pictures, embedding the timestamp in the name.

Other times, I'll write a small script to do this for me.

Earlier today, as I was stitching my pictures together from 3 different cameras, I realized that one of the clocks was off by about a day. I used this little script to fix the timestamps:

$dh = opendir(".");
while (($file = readdir($dh)) !== false) {
if (preg_match("/^IMG_/", $file)) {
$s = stat($file);
touch($file, $s[9] - 86400);
After I did that, I also needed to update the EXIF data embedded in the JPG too. To do that, I used jhead.

jhead -dsft IMG_*

Of course, running jhead on these files modified them yet again, so the file's timestamps are screwed up again. Let's cover our tracks.

$dh = opendir(".");
while (($file = readdir($dh)) !== false) {
if (preg_match("/^IMG_/", $file)) {
$exif_data = exif_read_data($file);
touch($file, strtotime($exif_data['DateTime']));



Creating Ubuntu Server Disk Images using live-helper

I recently showed you how to create Ubuntu Server images using vmbuilder, but promised to also show how to use live-helper. Without further ado...

Start by installing live-helper.

sudo apt-get install live-helper

If you want a splash image for the boot loader, grab one. Here's an example


Next, we use lh_config with a lengthy set of options, to build:
  • disable apt recommends (keep the image small)
  • build 64 bit (for large memory instances)
  • enable main and universe
  • build a usb disk style image
  • append a few kernel options (like "toram" and "noprompt")
  • use the syslinux bootloader
  • build from ubuntu lucid
  • use the linux-image-server kernel
  • add a few packages (like "byobu" and "vim")
  • add your boot splash image
  • set the boot timeout to 2 seconds
  • use aufs
  • set the root disk size to 2GB

/usr/share/live-helper/helpers/lh_config \
--apt-recommends false \
--architecture amd64 \
--archive-areas "main universe" \
--binary-image usb-hdd \
--bootappend-live "toram persistent noprompt" \
--bootloader syslinux \
--distribution lucid \
--exposed-root true \
--initramfs casper \
--linux-flavours server \
--linux-packages linux-image \
--mode ubuntu \
--packages "byobu vim" \
--syslinux-timeout 2 \
--syslinux-splash ./byobu_192.png \
--union-filesystem aufs \
--virtual-root-size 2000

Configure any "local hooks". These are scripts of your design that can modify your image inside of the chroot.

cat >config/chroot_local-hooks/ <<EOF
ln -sf /usr/bin/byobu-launch /etc/profile.d/
chmod +x config/chroot_local-hooks/

Now, you can perform the build. This takes about 8 minutes for me on my laptop, with an SSD and local mirror.

sudo /usr/share/live-helper/helpers/lh_build
Finally, test your image. You can run it in KVM.

kvm -m 512 -hda binary.img
Alternatively, you could write this directly to a hard drive, as an install. Note that this will overwrite ALL data on that drive. Use with great care!!!

dd if=binary.img of=/dev/sda