Tuesday, September 29, 2009

It Hit the Fan. Again.

My wife's laptop is busted.

Again.

This time it just died. No lights, no sounds, no nothing. It's still covered by extended warranty. Which expires next month. Timing is everything.

Down time for my wife was less than 20 minutes, and that's only because I wanted to finish going through my RSS feeds for the day, before handing over my laptop to her hands.

Thank you Bacula.

Thank you VirtualBox.

Again.

Customer service was horrible this time, but they finally obliged and the laptop was sent to the lab. I'm pissed as hell.

If you're looking for a used laptop DO NOT buy this model: HP Pavilion dv6000. It's a piece of crap. And quite heavy at that (2.7KG).

If you're buying a new laptop - DO invest in extended warranty. You'll thank me later.

And now we wait.

Again.

Friday, September 25, 2009

Boot PC from Floppy Image w/ GRUB2 and MEMDISK

[The stuff below is outdated - see the updated howto]

I've already described how I installed GRUB2 on my Live HDD, under the false impression that it would allow me to chainload and boot from a WinPE ISO image.

While I searched for more info about this subject I hit upon MEMDISK, which is part of SYSLINUX - a boot loader for the Linux operating system which operates off an MS-DOS/Windows FAT file-system. MEMDISK is an auxiliary module of SYSLINUX that simulates a disk whose contents resides in a disk image file. This allows the bootloader to boot from that disk image.

MEMDISK can be used to boot from floppy disk images and (I haven't tried this myself) from hard disk images. It seems that the next major release (v4.0) will allow it to actually boot from ISO images, but at the moment Debian has v3.82 available.

Some popular utilities (like MHDD) are distributed as floppy disk images, and it seemed like a useful tool to have. It took some time to put the pieces of the puzzle together, but I finally managed to get it working on my Live HDD:
  1. install syslinux:
    aptitude install syslinux
  2. copy (as root) /usr/lib/syslinux/memdisk to /boot
  3. create a directory /boot/images to hold all the floppy disk images
  4. get some floppy disk images, e.g. like this:
    • download SystemRescueCD
    • loop mount the downloaded ISO image:
      mount -o loop systemrescuecd-x86-1.3.0.iso /mnt/iso
    • copy any disk images that you need from /mnt/iso/bootdisk/*.img (which include MHDD and a few others) to /boot/images
  5. replace the contents of /etc/grub.d/40_custom with the script below
  6. run update-grub - if all goes well, it should create an entry in the GRUB2 boot menu for each floppy image that you copied over to /boot/images
Note that on some machines, and with some floppy images, the MEMDISK hack won't work (hint: you may want to replace bigraw in the script with another command line option). YMMV.

And here's the script:

#!/bin/sh
set -e

IMAGES=/boot/images
. /usr/lib/grub/grub-mkconfig_lib
if test -e /boot/memdisk ; then
MEMDISKPATH=$( make_system_path_relative_to_its_root "/boot/memdisk" )
echo "Found memdisk: $MEMDISKPATH" >&2
find $IMAGES -name "*.img" | sort | 
while read image ; do
IMAGEPATH=$( make_system_path_relative_to_its_root "$image" )
echo "Found floppy image: $IMAGEPATH" >&2
cat << EOF
menuentry "Bootable floppy: $(basename $IMAGEPATH | sed s/.img//)" {
EOF
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
cat << EOF
linux16 $MEMDISKPATH bigraw
initrd16 $IMAGEPATH
}
EOF
done
fi

Friday, September 18, 2009

Movie Trailers on apple.com

Watching movie trailers is one of my favorite passtimes when I'm online. I usually point Iceweasel to apple.com/trailers, and enjoy a few minutes of condensed cinematic bliss.

It was one of my first good impressions of Linux, when I found out that I could watch movie trailers in fullscreen with mplayerplug-in (the mplayer plug-in for Mozilla) - a feature that, at the time, was blatantly missing from the QuickTime browser plug-in on Window$.

A few months ago something has changed at the trailers site and mplayerplug-in started crashing Iceweasel whenever I tried to watch any movie trailer (see Debian bug #527293). I searched for a fix and learned that mplayerplug-in has been superseded by gecko-mediaplayer (from the same author). So, after verifying that it worked on apple.com/trailers, I made the switch and never looked back.

A few weeks ago gecko-mediaplayer started acting up too, due to another change by Apple. This time the browser would not crash but I could no longer watch video clips either (see Issue #34 on the gecko-mediaplayer issue tracker).

It seems that the trailers site requires that the media player, which is used to play the video clips, identify itself as QuickTime. A fix for this issue has already been implemented upstream, but it'll take some time before it trickles downstream to Debian.

In the meantime, I use the User Agent Switcher Firefox add-on to masquerade both browser and plug-in as QuickTime, when visiting apple.com/trailers:
  1. select Tools->Default User Agent->Edit User Agents...
  2. select New->New User Agent...
  3. type "QuickTime (apple.com)" in the Description edit box
  4. copy the following string to the User Agent edit box:
    QuickTime/7.6.2 (qtver=7.6.2;os=Windows NT 5.1Service Pack 3)
    (got this from a message on the mplayerplug-in mailing list)
  5. remove any text from all the other edit boxes
  6. press OK until you get back to the browser
Just remember to switch to the QuickTime user agent before you click on video clip links.

Saturday, September 12, 2009

Bluetooth Dongle Trouble

Cellular Phones and Kids

Cellular phones and kids under 3 don't mix. My wife and I have had each of our phones either fixed or replaced after being thrown without being caught, chewed upon and drowned in the toilet.

In at least two of these happy occasions the contents on the phone, namely photos, address book, calendar and messages, were wiped clean by the oh-so-competent cellular phone service provider. Well, I did sign a paper allowing these guys to do just that, either deliberately or by mistake.

Every time I hand over a phone to be serviced, I get the same response when I ask for a backup: "I can't backup your phone without USB". True enough, both our phones (low end Nokia 2600c) have no USB interface and can only be interfaced with over Bluetooth. But why should this make backups impossible? it shouldn't.

Our First Dongle: Window$

I was at the local Office Depot a few days ago, and while waiting in line to pay, I noticed that they had several Bluetooth to USB adapters on display. I made a decision that I lived to regret, and purchased one of these dongles.

I got the one that was mid-priced, simply because it had the Tux logo on it, along side the Window$ and Mac logos. "Any vendor who claims compatibility with Linux is likely to be technically superior than his competitors," I thought to myself, "their products are likely to be better engineered and better tested."

The dongle is marketed under a local brand name, so I have no idea what make it really is, otherwise I would strongly suggest you stay away from it. It came with an installation CD, and a leaflet that instructed me to install the software prior to connecting the dongle.

Being a sucker for manuals, I did as I was told and installed the software on my wife's Window$ XP laptop. The installation went along nicely, and then I was asked to connect the dongle. I did just that, and after a bunch of ballooned notifications appeared and disappeared near the system tray area, a little Bluetooth icon appeared there, and Window$ assured me, with yet another balloon, that the device was ready to use. Goody.

The dongle software, however, rewarded me with an error message:
Bluetooth Software license file not found.[2]

I hit the OK button and a standard file selection dialog appeared, allowing me to search for and open a file named license.dat. I found it on the installation CD, selected it and hit OK. The error message appeared again, and the process repeated itself, only that this time I hit Cancel when asked to find the file, disconnected the dongle in disgust, and uninstalled the software.

I sat there, weighing my options, and decided to attempt to return the dongle and purchase a different one.

Our First Dongle: Linux

But before returning the dongle, I decided I'd try to connect it to my Debian GNU/Linux laptop. I did not expect much.

At first I used lsusb to list the USB devices connected, and the dongle was there as Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode).

So far, so good.

I searched for packages whose names contain the word "bluetooth":
aptitude search bluetooth
and decided to install two packages:
aptitude install bluetooth gnome-bluetooth
Afterwards, I launched the GNOME control center and clicked the newly installed Bluetooth icon. This opened the Bluetooth Preferences, I clicked "Setup new device...", and a wizard appeared, prompting me to press "Forward" in order to scan for Bluetooth enabled devices. It didn't find any device, and I was somewhat disappointed, but not too surprised.

Well, after I enabled Bluetooth connectivity on the phone (ARGHH!), it was discovered by the wizard just fine.

The next step was to pair the phone with the computer: I was shown a set of digits and was asked to type them in on the phone.

After some more tinkering I found that with the gnome-bluetooth package came bluetooth-applet which showed a nice little Bluetooth tray icon after being launched. I right-clicked the icon and a menu appeared. I clicked "Browse files on device...", which launched the Nautilus file manager. I navigated through the directories, found the photos I made with the phone, and was able to copy them over to a directory on my hard disk.

Amazing!

I never expected to have a piece of hardware run (perfectly) only on Linux and be completely broken on Window$.

Our Second Dongle: Window$

The guy at Office Depot was very nice. He let me replace the dongle with a different one. I picked a more expensive dongle (made by Dynamode), paid the difference and went home.

There was no leaflet this time. The installation instructions were printed on the back of the package: load the enclosed CD-ROM into the computer's optical drive, install the software and connect the dongle.

I tried doing this on my wife's PC. It didn't work. There was no Bluetooth tray icon, like I had with the first dongle, and I could not start the Bluetooth software (Bluesoleil) after it was supposedly installed. I clicked and double clicked all the icons that seemed relevant, but nothing happened.

It took almost half an hour of futzing around before I decided to restart the computer. And guess what? it helped. In hindsight, it did seem odd that neither the instructions on the back of the package, nor the Bluesoleil installer, didn't even hint that a restart is advisable.

I was then able to use the overly animated Bluesoleil user interface in order to pair my phone to the computer, and browse the files on the phone.

Thank you very much.

Our Second Dongle: Linux

I had to try it on my box, and, basically, it just worked.

I did find out that frequent removals and insertions of the dongle sometimes required me to restart Bluetooth support:
invoke-rc.d bluetooth restart
But other than that, it just worked.

I also found out about hcitool - a command line utility that's part of BlueZ (the official Linux Bluetooth stack, that's installed automatically when you install the bluetooth package). It can be used, for example, to scan for Bluetooth enabled devices:
hcitool scan


Bad Dongle

All seemed fine, until Bluesoleil started crashing.

At first I thought this had to do with my wife's laptop resuming from hibernation, but I did not have the energy to investigate it any further.

Instead, I downloaded a software update for Bluesoleil, in the hope that this would fix the issue. But the setup program that I downloaded managed to remove the version installed on the box, and nothing more. So lame.

Oh, and the plastic casing of the dongle fell apart after two days of use.

Unbelievable.

Our Third Dongle

The guy at Office Depot was very nice. Again.

This time I picked a no-name made-in-china thumbnail sized dongle - the smallest and cheapest yet. It came with no software, and Window$ would not recognize it, even after a reboot. I pretty much expected this to happen.

I then removed any trace of Bluetooth device drivers from the computer, by following the instructions in the article "Removing unused device drivers from Windows XP machines" (open the device manager with the environment variable devmgr_show_nonpresent_devices set to 1), restarted the machine and re-plugged the dongle.

Window$ managed to find and install the drivers for the dongle with no external assistance and no extra software. I right-clicked the Bluetooth tray icon, and was able to scan for and find my phone, and then pair it with the computer - very similar to my Linux experience.

I have a hunch that either of the previously mentioned dongles would've worked just fine without installing the software that was bundled with them.

More Fun with Dongles

If you have a Nokia phone, I recommend that you install Nokia's PC Suite - it's a pretty cool, free of charge, integrated suite of applications that lets you control and manage your phone from your PC.

Linux has Gnokii and Gammu for doing pretty much the same tasks, from the command line or your own scripts/programs. There are also graphical frontends (XGnokii and Wammu, respectively), which aren't as polished as Nokia's PC Suite, but they do provide support for non-Nokia devices.

There's all sorts of neat stuff that one can do with Bluetooth:
  1. access the Net via the cellular phone
  2. setup a personal-area-network - wireless networking
  3. connect a headset as an audio input/output device
  4. send SMS from the computer
  5. automatically lock/unlock the desktop when the cellular phone is far from/close to the computer
  6. ...and more
But I haven't tried any of these things. Yet.

Hopefully the (blue)toothache is over now.

[14 Sep 2009] UPDATE: The bluetooth wizard stopped working after I upgraded some packages. It's a known bug and a patch is already available (see Debian bug #545549).

Let's just say that I'm not as ecstatic about the state of Bluetooth on Linux as I was two days ago. What a pain.

Saturday, September 5, 2009

Wasting Time with Git on Windows

It's quite easy actually: use Git to clone a certain repository to a Window$ machine and then attempt to build it.

I did just that with an autoconf based project. The machine at hand has Cygwin installed on it, so all I needed to do, in theory, was
git clone <git://address/of/repository.git>
cd <repository>
./configure
make
and have a binary to test.

I used PortableGit from msysgit, which seemed like a good idea at the time (instead of installing Cygwin-based Git).

Git clone worked like a charm. Luckily, that repository contained no symlinks and/or files whose names differ only in case (e.g. File.txt and file.txt).

But I couldn't run ./configure - I got a bunch of weird syntax error messages, which made no sense. The script looked fine (well, apart from being ridiculously long...).

It took an embarrassing half an hour before I figured it out, and even that was by chance. I opened the configure script for editing with emacs and noticed the text (DOS) at the status bar. Oh, so this is a Newline problem!

I tried
dos2unix configure
and I now got syntax errors in other files. Definitely a Newline problem.

I cloned the same project to my Debian box, and it looked OK - none of the scripts seemed to have CRLF newlines. So it had to be Git auto-convetring those text files between platforms.

A quick Net search later and I had a fix:
git config --global core.autocrlf false
I cloned the repository again, and this time everything worked nicely.

To be fair, I've been hit by Window$ specific problems with other SCMs, both free and commercial, with or without implied warranty, whenever I needed interoperability of some sort between Window$ and Linux.

If anything, I should've seen it coming.