Mounting a USB Drive in a Consistent Location on Ubuntu 9.10 (Karmic)

November 18th, 2009

This is an obtuse and unabashedly geeky post, but I spent several hours trying to solve this irritating problem, so I’m posting my results here in an attempt to shortcut this issue for others.

The Problem: I have an external USB drive on which I store Virtual Machines which I run with the very excellent VirtualBox. I like to keep it mounted at /media/VirtualMachines. My VirtualBox configuration (stored in ~/.VirtualBox/) points to this location, so it’s vital that it remains consistent between reboots, remounts, updates, and the like. Prior to Ubuntu 9.10, one used to be able  to specify a consistent mount point using the GNOME userspace tools by simply right-clicking on the volume on the desktop, navigating to “Volume”, and choosing a location by typing it in. This was possible, because prior to version 9.10, Ubuntu relied upon hal to provide an abstraction layer between hardware devices and the kernel. There’s a fair amount of code in GNOME which allows for quick configuration of functionality provided by hal. hal is now deprecated in favor of DeviceKit, so some of those tools are gone, and this is one.

The Solution: I spent a fair amount of time googling about trying to come up with an equivalent. Many of the tutorials that I found were either outdated, or involved diving into the internals of udev/DeviceKit. This seemed like it was a problem best-suited to something simpler. It turns out that you can use plain old /etc/fstab to mount a device in a specific place, using the partition’s UUID instead of a block device path. This is handy, because if it’s a removable device, you won’t know what block device it’ll be assigned when you plug it in, or when the system boots. Because it will mount after boot time, you’ll also have to set the user option to allow gnome to mount the device after you log in — otherwise the action will be restricted to the root user. Be sure also to set auto, so that the OS will automatically mount the drive for you without you having to issue the commands yourself.

The relevant line in /etc/fstab looks like this, for me:

UUID=0e408c42-233a-4d0c-a7be-dac2379092d5 /media/VirtualMachines ext3 rw,auto,user,exec 0 0

You can get the UUID of the relevant partition of your drive by using devicekit-drives:

$ devkit-disks --show-info /dev/sdb1 | grep uuid
 by-id:                     /dev/disk/by-uuid/0e408c42-233a-4d0c-a7be-dac238a1a3e8
 uuid:                        0e408c42-233a-4d0c-a7be-dac238a1a3e8
 uuid:

Of course, substitute /dev/sdb1 for the partition you’re trying to mount.

On Nearly Losing a Phone in New York

October 27th, 2009

Tonight had all the makings of a disastrous evening. It came arse-clenchingly close, but it did not come to pass.

I left work at 7:00 or so, and decided to take a longer route home, mostly to make a change from the West Side Greenway, which, while fast and convenient, can get a bit tedious after hammering back and forth for days on end. I headed up 8th Avenue, after dodging gaggles of pedestrians who had meandered off the sidewalk, and food vendors dragging hot-dog carts up the street. My plan was to follow the Central Park Drive counter-clockwise from Columbus Circle up to 110th Street.

I hit my stride somewhere around 89th street, near the Guggenheim Museum, cruising along just above 20mph. I had my iPhone in the pocket of my sweater, with the headphones stuffed in on top. Those headphones must have unraveled themselves, because I saw them get wrapped around my handlebars for a split second, before my right leg turned another revolution of the pedals, yanking the iPhone out of my pocket and down to the street.

Shit.

I slammed on the brakes, and flipped the bike around as quickly as I could without rolling it over. I expected to see the phone on the street, fifty yards back, with the white headphones sprawled out across the asphalt. Maybe with a cracked screen or case. Instead, I found nothing. Not even any fragments of shattered glass or a torn-off earbud.

Double Shit.

OK, I thought. The phone must have bounced to the edge of the street. I zigzagged my bike up and down the street for a hundred yards in either direction, kicking up piles of leaves hoping that my phone was hiding under one of them. Still nothing. I began to think that one of the runners who had passed me had snapped up the phone in the few seconds it took me to stop and turn around.

It had been fifteen or twenty minutes at this point, and, at very least, I knew I would be home much later than antipated. As the ever-prepared computer nerd, I broke out my laptop and Sprint card, fired up Skype, and called Alex to tell her what was going on.

“Should I call your phone?” she asked.

“I don’t think there’s much point. One of the joggers could easily have picked it up and walked off with it. I’m going to keep looking for it here for a while.”

“OK”, she said. We hung up.

I un-clipped the headlamp from my bike and started walking up and down the same bit of roadway, looking for the phone. I was more or less resigned to the fact that my phone was long gone, and tomorrow I’d have to own up to my employer that I’d carelessly thrown their phone on the ground in Central Park and, worse, managed to let someone pinch it, too. I gave myself another ten minutes. If I hadn’t found it by then, I’d give up, then slink off home and begin the tedious process of changing the credentials for all the accounts that had anything stored on that iPhone.

I was in the middle of peering down into a storm drain with my headlight when someone called out to me:

“Are you Guy?”

A woman walked up to me, holding my phone. In perfect condition. I nearly passed out with relief.

It turns out that she was, indeed, one of the joggers, and had seen the phone on the ground. She had lost something in the park recently, too, and thought that she had better take the phone to the Central Park police precinct to turn in. On her way there, the phone rang. It was Alex, calling my phone anyway, just in case. Alex had described me to her (”He’s riding a bike, wears glasses, and speaks with a British accent. If someone says its their phone and doesn’t have an accent, it’s not him”), and the woman had gone back to where she found my phone, and caught up with me. Her name was Claire. I shook her hand, thanked her profusely, and she went on her way.

Anyone could have found that phone, walked off with it, and nobody would be any the wiser. Worse, they could have wreaked a little bit of havoc on my life with my stored data. If New York mythology is to be believed, the city is full of villains and miscreants, none of whom would even think twice about pocketing a valuable find. Rather, Claire bothered to pick it up and send it back to its owner. Whatever it was that she lost in Central Park, she deserves to find it. And I deserve a swift kick in the pants for being so bloody careless.

In Search of A Proper Old Fashioned

October 17th, 2009

My good friend Pat and I have a longstanding disagreement, which bubbles to the surface every time we get together for cocktails. It concerns the correct way to make an Old Fashioned. I contend that an Old Fashioned should be merely sugar, water, bourbon, bitters, and some lemon peel, while Pat believes that an Old Fashioned should be bourbon, muddled fruit, bitters, and soda water.

Wikipedia refuses to take a side on the issue, saying:

Most modern recipes top off an Old Fashioned cocktail with soda water. Purists decry this practice, and insist that soda water is never permitted in a true Old Fashioned cocktail.

Many bartenders add fruit, typically an orange slice, and muddle it with the sugar before adding the whiskey…

My boss, Jane, knower of all things cocktail, shares my view that muddled fruit has no place in an Old Fashioned, which, frankly, was more than enough for me. Naturally, this was not enough to convince Pat, and so of course, there was only one way to settle the score for sure, which was to go and sample some Old Fashioneds at several bars across Manhattan. And so last night, that’s what we did, meandering our way across the downtown Manhattan, happily buzzed, stopping in at four establishments.

The rules of the contest:

  • Each participant chooses two bars
  • At least one person must order an Old Fashioned at each bar, without specifying a method of preparation to the bartender.
  • One point to be awarded to Guy for an Old Fashioned served without fruit
  • One point to be awarded to Pat for an Old Fashioned served with fruit

And so, the results:

Round One – Guy’s Choice
The Raines Law Room

48 West 17th Street
[Yelp]

Named after legislation which forbade the selling of liquor on Sundays, except in hotels, drinking at The Raines Law Room feels like sipping cocktails in a living room. The bar is furnished with vintage velvet couches, and period pieces like a vintage gramophone. The cocktails are pretty outstanding. My colleague Chris joined us for the first round. I had one of their signature cocktails, the Suffering Bastard, involving Bulleit bourbon, Plymouth gin, lemon, sugar, and ginger, which was simultaneously strong, sweet, and spicy; generally kickass. Chris tried a Champs-Élysées, involving brandy and chartreuse, which was tasty but not really my type of drink. Pat was on Old Fashioned duty, and Raines scored one for me, bringing a simple mix of sugar, water, bourbon and bitters with a single giant cube of ice.

Score after Round One:
Guy 1, Pat 0

Round Two – Guy’s Choice
Little Branch

22 7th Avenue South
[Yelp]

Little Branch remains one of my favourite bars in the city. They take their drinks seriously, it’s definitely got the speakeasy feel but the gimmick isn’t overplayed, and the atmosphere is always relaxed. Their bartenders are clearly experts at their craft, and to that end, will choose a drink on your behalf based on rough specifications you provide. Since Pat had never been here before, he took the “Bartenders Choice”, while I ordered up the Old Fashioned. Pat’s specs of a ‘rye-based, fruity’ drink landed him a tasty concoction with fresh squeezed juice and mint, while my Old Fashioned, appropriately, was devoid of both muddled fruit and soda water.

Score after Round Two:
Guy 2, Pat 0

Round Three – Pat’s Choice
Blue Owl

196 2nd Avenue
[Yelp]

We strolled over to the East Village to visit Blue Owl, which is hidden just below street level on Second Avenue, underneath one of those shady-looking massage parlours with a video of someone getting a shiatsu on permaloop and about fifty neon signs. It was about nine o’clock when we arrived, and it was still fairly quiet, with just a handful of people at the bar. I had one of their house cocktails, the Jules Winnfield–bourbon, apricot liqueur, and fresh lemon and orange. I’m unsure what made whoever came up with the drink name it after the cinematic hitman with the best sideburns ever, but it was more or less a whisky sour made with fresh ingredients instead of bottled ones. Pat scored his first point of the evening with an Old Fashioned made with muddled lemon, orange, and, for some reason, dried sour cherries, which yielded a drink which tasted, in Pat’s words, “like a Jolly Rancher”.

Score after Round Three:
Guy 2, Pat 1

Round Four – Pat’s Choice
The Dove Parlour

228 Thompson Street
[Yelp]

By the time we arrived at The Dove Parlour, it was past ten o’clock and the place was starting to become full. Somehow we managed to find two seats at the bar next to a greasy looking hipster sitting alone and knocking back beer. The house cocktail menu is short, and Pat ordered an Olympia, listed as “Bourbon, bitters, fresh lime juice and a splash of ginger soda”. The resulting greenish drink was incredibly tart, probably from being a bit too heavy on the lime juice. The bartender served me the final Old Fashioned of the evening with orange, cherry, lemon, and sugar, the product being syrupy enough that the sugar refused to dissolve at the bottom of the glass. Nonetheless, it evened up the score for Pat.

Final score after Round Four:
Guy 2, Pat 2

We briefly considered a tiebreaking round, but at four bourbon-based drinks apiece, we felt that a final, tied score was appropriate. Our adventure does seem to suggest that we could both be right — the modern interpretation of an Old Fashioned generally involves some sort of fruity garnish along with the bourbon. The classic version, on the other hand, sticks to the base ingredients. So, we’re back to where we started, I suppose, and Pat and I will just have to continue to regularly needle each other about our taste in cocktails, which I think I can handle, as long as there’s enough bourbon.

Subway Math and Geekery

August 31st, 2009

This afternoon, while riding the subway, I noticed an ad that the MTA has been running for some time now as part of its self-promoting “SubTalk” campaign. It reads:

In 1986, the subway and bus fare was $1. That’s $1.89 in 2008 dollars. Today, 30-day Unlimited Ride MetroCard brings the fare down to $1.17. Believe it.

Maybe I’m a crotchety windbag, or maybe the afternoon’s chatter with friends about the GRE mathematics section sparked something off, but I didn’t, as the ad implored me to, believe it. Assuming that the ad campaign was started before the subway fare increase earlier this year that raised the base fare to $2.25 from its previous $2, it seemed like the MTA was taking a pretty liberal view of how many times one would have to ride the subway or bus with their monthly MetroCard to bring their effective fare down by 30%.

(In case you’re not familiar with how the 30-day MetroCard works, you can pay a flat fee per month for unlimited use of the New York subway and local buses instead of the pay-per-ride fare)

Partly to prove that I could still actually do arithmetic and basic algebra (and render it in TeX), I scribbled out this calculation:

MTA Fare Math

I’m sure this broke all sorts of mathematical conventions, but p_m is the price of a 30-day card, p_r is the effective per-ride cost according to the MTA, and r, r_d, and r_w are rides per month, day, and week, respectively you’d need to make to get that price.

This assumes the 2008 30-day fare of $81. To get the purported $1.17 fare, you’d have to ride the subway or bus (not including free transfers) about 2.3 times per day, every day, or just over 16 times per week, for the entire 30-day period. I have no idea where the MTA got their data from, but I don’t know anyone who rides the subway that much.

Long Beach Island, or: How a zipcar trip can end in a tow truck ride

August 23rd, 2009

The cast: Guy Dickinson and Patrick Stahl, two engineer-types from New York City.

The set-up: Their girlfriends are out of town at Disneyworld. What else to do but take a drive down the Jersey Shore to Long Beach Island, Pat’s erstwhile summer home and source of copious family memories? There’s a hurricane a few hundred miles off the East Coast which promises to produce impressive surf and maybe a storm or two. They book a zipcar rental for 3:30PM on Saturday, August 22nd.

The timeline:

3:30PM, 1090 Amsterdam Avenue, NYC: Pat and Guy arrive at the appointed parking garage to pick up the vehicle, a 2007 Volkswagen Jetta with about 45,000 miles on the clock. Pat’s zipcard lets them into the car without a hitch, and they hit the road.

3:35PM, West 107th Street: While Guy makes a quick stop for a bottle of water and his camera, Pat checks out the rest of the car. The trunk contains three umbrellas and a bed-sheet, all from previous renters. The car is otherwise in fine condition.

3:40PM, West Side Highway: Some ominous clouds over the George Washington Bridge suggest that this might be a spectacular trip indeed.

4:10PM, Garden State Parkway Southbound: Guy discovers a CD left in the car from a previous occupant. It is labelled “Rap/Spliff”. Alas, it refuses to play in the car’s CD player. Pat and Guy are stuck listening to classic rock.

4:21PM, Middlesex County, New Jersey: Pat and Guy stop at Cheesequake Rest Area, an intriguingly-named place. Later, Guy will be disappointed to discover that “Cheesequake” is merely a bad Anglicization of a Native American name, and not a reference to a giant, rumbling block of milk curd.

5:50PM, Long Beach Island, New Jersey: Pat and Guy arrive at their destination. Guy is nervous that the scene is too idyllic for hurricane-induced surf, however, after stepping onto the beach, it’s clear that there are at least six-foot waves. Despite frantic warnings from the local authorities, many surfers are trying to take advantage of the situation.

There really was a hurricane offshore.

There really was a hurricane offshore.

6:15PM: Watching the ocean from the sand is insufficient for Pat. He decides he must enter the ocean, again, despite frantic warnings from the authorities. Guy declines, citing his will to live.

6:17PM: Pat enters the ocean, abandoning his clothing and the contents of his pockets on the beach. Guy stays to stand watch.

6:30PM: Pat is struck by a giant wave, which knocks him off his feet. He decides to return to shore.

Pat is dwarfed by a wave, prompting his emergence shortly after

Pat is dwarfed by a wave, prompting his emergence shortly after

Pat emerges.

Pat emerges.

6:31PM: Pat gathers up his belongings, including the zipcard, a critical access token which allows his and Guy’s access to the vehicle. He attempts to hand Guy the card to keep it safe. Guy doesn’t realize he’s being handed anything. The card is dropped to the sand, unnoticed.

The bloody zipcard.

The bloody zipcard.

6:39PM: Pat and Guy return to the car. “Open the car, will you?”, says Pat. “I don’t have the card, you do!” replies Guy. “But I gave you the card”, said Pat. “No, you didn’t.” Pat and Guy discover that neither of them has the card. Pat returns to the beach to attempt to locate it.

6:44PM: Pat declares defeat. A final, exhaustive search of pockets, shirts, and shoes reveals nothing. The zipcard is nowhere to be found.

6:45PM: The first call is placed to zipcar. Because the cars are all connected to zipcar’s central office, it should be feasible to unlock the car remotely. Pat explains the scenario, and the representative cheerily tells him that the car should now be unlocked. The car is not, in fact, unlocked. The zipcar representative cites “cellular reception issues” and puts Pat on hold while she figures out what to do next.

7:00PM: The zipcar representative informs Pat that they will need to send roadside assistance to let us back into the car. Some telephone shuffling occurs, and we are told to expect assistance to arrive in 30 minutes. Pat declares that he will eat his hat if the tow truck arrives in 30 minutes. Pat and Guy decide to wander over to the bay side of the island, where a sign informs them that they are not to disrobe, by order of the police department. Disappointed, they change their plans and head off in search of food, stopping at the first place they come to, Pinky Shrimp’s Seafood Company. They place an order for some shrimp and a crabcake sandwich and are told that there will be a one-hour wait for their food.

This sign was the only thing which prevented us from dropping our trousers.

This sign was the only thing which prevented us from dropping our trousers.

7:15PM: Pat heads back towards the car, while Guy purchases a six-pack of New Jersey Lager from the liquor store. It is brewed in Wilkes-Barre, Pennsylvania. Strangely, this seems apropos. Guy returns to the car.

7:20PM: It is nearly dark. The only corrective lenses Pat has are his sunglasses, with his normal glasses locked in the car. Guy is appointed lookout for the tow truck. Beers are opened and surreptitiously drunk near the car.

It was getting dark.

It was getting dark.

7:40PM: The tow truck arrives. Pat is relieved not to have to eat his hat. Pat and Guy introduce themselves to Ray, of Stohrer’s towing. Ray is the most talkative person either of them have ever met. Pat explains the situation to Ray, who gets his tools ready to break into the car.

7:45PM: Ray successfully opens the car, which has the physical, non-zipcard car key in it.

7:45:30PM: Pat attempts to start the zipcar, which refuses to turn over.

7:45:31PM: Guy recalls a previous incident during a zipcar trip to Rhode Island, wherein the car failed to start because he’d forgotten to use the zipcard to unlock the doors. Apparently, the zipcard locking mechanism requires that the car be unlocked with the card before it will start. Guy explains this to Pat.

7:50PM: Pat places another call to zipcar to figure out what to do next. While he does this, Guy returns to Pinky Shrimp to retrieve their food.

8:00PM: Guy arrives back at the car with shrimp and crabcakes. Pat has been informed that the only way to get back to New York is to tow the car, since apparently there’s something wrong with the zipcard locking system. Distance to New York: 115 miles. A last-ditch attempt to salvage the situation by transferring the reservation to Guy’s name fails. Some logistical discussions between Ray, Ray’s dispatcher, Zipcar, and some agency named Road America ensue. All apparently agree that towing the car is the only option we have left. During this, Guy eats a dozen fried shrimp and feels much better.

8:20PM: The car is loaded onto the tow truck, and Guy and Pat jump into the truck cab. They are on the way home.

8:30PM: Ray, who had not been expecting to drive to 115 miles to Manhattan and back, decides to stop at his house for water. Pat and Guy take the opportunity to take stupid pictures of the car atop the tow truck.

8:45-11:00PM: Pat and Guy ride all the way back to the garage at 1090 Amsterdam Avenue where they picked up the car. Ray does not stop talking for a moment, regaling them with tales of his previous jobs, one of which he describes as a “shit engineer”, having something to do with cleaning effluent from sewer pipes. Ray shares his opinions on popular culture, television, news, coffee, and the economy. The trip passes quickly.

11:20PM: Pat and Guy and Ray arrive back at the garage. Ray calls the attendant to explain the situation. The attendant, clearly confused, simply replies, “OK, come in”, and rolls up the gate, not understanding that a full-size tow truck will not fit into the garage. Pat and Guy are nervous that attempting to explain to the attendant the state of the zipcar will become their problem.

11:20:30PM: The garage attendant opens the door to the front office, looks nervously out, then closes it again. Pat and Guy’s nervousness increases.

11:21PM: Pat and Guy retrieve their belongings from the car, and Ray tells them that he’ll handle the garage attendant. Relieved, Pat and Guy shake hands with Ray and run away before they can cause any more trouble.

11:40PM: Pat and Guy finish the remaining four New Jersey Lagers in the safety and comfort of Pat’s living room.