Disk Hack

One of the things I enjoy about Unix system administration is the McGyver aspect of it: when something goes pear-shaped, and your preferred tools aren’t available because they’re on the disk that just died, or on the other side of the pile of smoking ashes that used to be a router, you have to figure out how to recover with what you’ve got left. It’s a bit like that scene in Apollo 13 when they realize that the space capsule has a round hole for the air filter, but only square filters, and the engineer dumps all the equipment the astronauts have available onto the table, and says “We’ve got to find a way to make this fit into the hole for this, using nothing but that“.

So anyway, my mom’s Mac recently died. And, naturally, there are no available backups. But I said I’d do what I could, and took the machine home.

I’m glad we wrote off the old machine as a total loss, since it was (the tense should give you an idea of what’s coming) an iMac, one of those compact everyting-in-the-monitor models that tries oh-so-hard to fit everything into as small a space as possible. Of course, this compactness means that there’s no room to do anything: the disk is behind the LCD display, and wedged in a tight slot between the graphics card and the DVD drive. And the whole thing is wrapped in — I kid you not — foil, most likely to help control airflow. So basically I wound up ripping things out with little or no grace or elegance. If it wasn’t totaled then, it certainly is now.

At any rate, that left me with a disk that, thankfully, turned out to be unharmed. The next question was how to hook it up. I was pretty sure it had an HFS or HFS+ filesystem, which meant that the obvious thing to do would be to put it in a Mac to read. But I don’t have a Mac that I could put a second internal drive in. I toyed briefly with the idea of finding an enclosure and whatever conversion hardware would be necessary to turn an internal SATA drive into an external USB drive, but figured that was too hard for a one-shot. Then I found that my Linux box has hfs and hfsplus filesystem kernel modules, so hey.

(Of course, I don’t know how stable the Linux HFS driver is, so I figured it’d be best to write-protect the disk. At which point I discovered that this model only has one hardware jumper slot, and it doesn’t write-protect the disk. Fuck you very much, Maxtor/Apple.)

The Linux HFS driver turned out to be good enough for reading, and I could mount the disk and read files, so yay. The next question was how to get the files from there to a laptop that I could bring over to my parents’. Ths is complicated by the fact that on HFS, a file isn’t just a stream of bytes, the way it is in Unix; it has two “forks”: the data fork contains the actual data of the file (e.g., a JPEG image), and the resource fork contains metadata about the file, such as its icon, the application that should open the file by default, and so on. I didn’t want to lose that if I could help it.

The way the Linux HFS driver deals with resource forks is to create virtual or transient or whatever you want to call them files: if you open myfile, you’ll get the data fork, which looks just like any file. But if it has a resource fork, you can also open myfile/rsrc and read the contents of that. This meant that in the worst case, I 1) copy over the data forks to a directory on the Mac, then 2) find which files have resource forks (something like

find /mnt -type f |
sh -c 'while read filename; do
    if [ -s "$filename/rsrc" ]; then
        echo "$filename";
    fi;
done'

and 3) somehow re-graft the resource forks onto the files on the Mac end. But that seemed like a lot of work.

Apple software is often distributed on .dmg (disk image) files, which are mounted as virtual disks. I figured that’d be the obvious way to package up the contents of the disk. So I dded the raw disk device (/dev/sdb rather than /dev/sdb2 which was the mounted partition, in order to get the entire disk, including partition map and such), but when I tried to mount that, it didn’t work, so presumably there’s more to a .dmg file than just the raw disk data. I tried a couple of variations on that theme, but without success.

(In passing, I also noticed that rsync supports “extended attributes” on both my Mac and my Linux box, so I tried using that to copy files (with resource forks) over, only to find that the two implementations use different options to say “turn on extended attributes”, so the client couldn’t start the remote server correctly.)

Eventually, I realized that dd could be used not just to read a disk image, but to write one. Yes, I said above that reading from the disk and writing to a file didn’t produce a usable disk image. But I also said that .dmg files are mounted like disks, and that implies that there has to be a device to mount.

So on the Mac, I created a disk image file with hdiutil create, then opened it with the Disk Utility. Forcing “Verify disk” made the Disk Utility mount the image on /dev/disk2s9, just before telling me that there was no usable filesystem on the disk image. That was fine; all I wanted was for it to create a /dev/disk* device that I could write to. Then I was able to

ssh linuxbox 'dd if=/dev/sdb bs=2M' | dd bs=2048k of=/dev/disk2

to transfer the raw contents of the disk to the “disk data” portion of the disk image.

To my slight surprise, this actually worked. Yes, I had to repair the disk image, but from the log messages, that appears to be because some of the superblock copies were missing (the disk is 120Gb, but I only created a 32Gb image).

The final problem should be that of getting the disk image from my locked-down(-ish) laptop to my mom’s new vanilla Mac, but I don’t think I’ll bother. It’ll be a lot easier, and better in the long run, to put the old disk image onto an external drive that can then double as a backup disk, so I don’t have to do this again.

Because while it can be fun to solve a puzzle and figure out how to fix something with suboptimal tools, there’s also wisdom in avoiding getting into such situations in the first place.

Sect Fight!

From the AP:

BETHLEHEM, West Bank (AP) — The annual cleaning of one of Christianity’s holiest churches deteriorated into a brawl between rival clergy Wednesday, as dozens of monks feuding over sacred space at the Church of the Nativity battled each other with brooms until police intervened.

The ancient church, built over the traditional site of Jesus’ birth in Bethlehem, is shared by three Christian denominations – Roman Catholics, Armenians and Greek Orthodox. Wednesday’s fight erupted between Greek and Armenian clergy, with both sides accusing each other of encroaching on parts of the church to which they lay claim.

But Christianity is a Religion of Peace™, isn’t it?

Reuters also reports:

“It was a trivial problem that … occurs every year,” said police Lieutenant-Colonel Khaled al-Tamimi. “Everything is all right and things have returned to normal,” he said. “No one was arrested because all those involved were men of God.“

(emphasis added.)

I guess they were following Matthew 5:39, the What God Really Meant Version: “But I say unto you, That ye resist not evil: but whosoever shall smite thee on thy right cheek, turn to him the other also. Unless he attempteth to take thy broom, in which case punch the bastard.”

Weak Week
  1. The Boomtown Rats – I Don’t Like Mondays
  2. Yazoo – Tuesday
  3. Elvis Costello – Wednesday Week
  4. The Chameleons – Thursday’s Child
  5. The Cure – Friday I’m in Love
  6. The Dead Kennedys – Saturday Night Holocaust
    (it was either that or 10:15 Saturday Night, but that would be two Cure songs in a row)
  7. U2 – Sunday Bloody Sunday
Goodbye, Christopher Hitchens

Christopher Hitchens died today of pneumonia (itself caused by his esophageal cancer), at the age of 62. People more eloquent than I have attempted to sum up his character and the impact of his life, so I won’t attempt it.

Let me simply quote one of his simpler, more distilled adages:

What can be asserted without proof can be dismissed without proof.

and replay one of my favorite Hitch bits, from the Intelligence2 debate on whether the Catholic church is a force for good:

That “Adopt an Atheist” Campaign

By now, you’ve probably heard about BillDo’s “Adopt an Atheist” campaign:

Today we are launching our “Adopt An Atheist” campaign, the predicate of which is, “We want atheists to realize that there may be Christians in their community, even if those Christians don’t even know they are Christian.”

Here’s what our campaign entails. We are asking everyone to contact the American Atheist affiliate in his area […] Let them know of your sincere interest in working with them to uncover their inner self. They may be resistant at first, but eventually they may come to understand that they were Christian all along.

If we hurry, these closeted Christians can celebrate Christmas like the rest of us. As an added bonus, they will no longer be looked upon as people who “believe in nothing, stand for nothing and are good for nothing.”

(emphasis added)

Here’s what I just sent him:

Dear Mr. Donohue,

I have just heard about the Catholic League’s “Adopt an Atheist” campaign, and am intrigued.

I am an atheist, one of those people who, according to you, “believe in nothing, stand for nothing and are good for nothing.” But apparently, according to your press release, it is possible that I am actually a Christian without realizing it.

I don’t understand how this is possible, but perhaps one of the atheist-adopters with whom you are working can explain it. I am not a member of American Atheists, so sending mail to them will not reach me. Please ask one of your adopters to contact me.

You also write that “We want atheists to realize that there may be Christians in their community, even if those Christians don’t even know they are Christian”. Is this true? Is it possible that there might be Christians in my community? Could it be my neighbors, who attend church every Sunday? Or perhaps the pastor who lives two doors down? Who? Perhaps an atheist-adopter can help me figure it out.

I look forward to hearing back from you or your organization.

I’ll post if I hear back. It ought to be a lot of fun.

How Not to Report Science

One of the stories in the news today is about a study showing that no, US presidents don’t have their lifespans shortened by the rigors of office. The AP writes:

Using life expectancy data for men the same age as presidents on their inauguration days, the study found that 23 of 34 presidents who died of natural causes lived several years longer than expected.

This set off little skeptical alarm bells in my head. And indeed, a few paragraphs later, we find:

Given that most of the 43 men who have served as president have been college-educated, wealthy and had access to the best doctors, their long lives are actually not that surprising, [study author S. Jay Olshansky] said.

I haven’t found the text of the study in question, but LiveScience writes:

“To me, it’s a classic illustration of the benefits of socioeconomic status,” Olshansky told LiveScience. “All but 10 of the presidents were college-educated, they were all wealthy, and they all had access to medical care.”

So yeah, maybe I’m jumping to conclusions, but I suspect that being able to afford living in a neighborhood where you’re not going to get shot by a drug dealer, and getting regular checkups at Walter Reed may have a teensy bit to do with one’s life expectancy.

So really, what this story tells us is that the stress of the presidency, when combined with good lifestyle and health care, is not enough to lower a man’s life expectancy to the national average. What it doesn’t say is what effect the presidential lifestyle has on people’s health. For that, it would be necessary to compare presidents’ life spans to those of people of comparable wealth and access to health care. From the remarks above, I suspect that Olshansky understands this perfectly well, but I don’t know whether that study has been done.

Kitty Theodicy

One of the standard replies to the problem of evil is that evil and pain serve a greater purpose, such as when a mother allows her child to be painfully jabbed with a polio shot. It may suck to have your house robbed, but if God intervened by taking away free will (including the robber), that would be even worse.

I’m not buying it, and here’s why.

I have a cat with an infection, so I’m giving her antibiotics twice a day. For those without pets, this involves laying her on her back, putting an eyedropper between her teeth, and squirting in a bit of liquid (that smells and tastes like medicine, natch) in her mouth. She doesn’t want to swallow, but since she’s on her back, with the liquid pooling in her throat, eventually she has no choice but to swallow. I could have gone with pills, but those are even harder to administer.

In short, to my cat, I’m like the aforementioned god, doing bad things to her for no purpose that she can discern. But we humans, with our superior intelligence, recognize that the pain and suffering I inflict serve a greater purpose.

And that’s where the similarities between me and God end. Among the differences: when I inflict pain on my cat, at least I have the balls to show myself. My cat can see me, smell me, hear me, touch (and scratch) me. I don’t resort to manipulating natural forces to do the dirty work for me. And when I do use an intermediate (such as the vet), I at least try to let her know that I’m there, and that it’s okay.

There’s also a limit to how much pain I will inflict on my cat. If she needed an operation, I would make damn sure she was anesthetized for it. And if she were in constant pain from an incurable disease, I would prefer that she be put to sleep rather than have to suffer.

But it doesn’t work that way in the greater world. Even setting aside the mind-boggling amount of pain in the animal world (e.g., when an Ichneumon wasp larva eats its host from the inside, or when lions eat a still-living gazelle) and concentrating just on God’s favorite species, humans, why are there lingering diseases? Why do people bleed to death after being hit by a rock slide? Why do people’s limbs rot away from gangrene?

For that matter, why does torture work? I don’t mean in the sense of extracting useful intelligence. I mean in the sense of inflicting unbearable pain and suffering without even the release of death? You’d think that an all-powerful and merciful god could set things up so that when the pain gets too bad, a built-in anesthetic could kick in and make us oblivious. In extreme cases, sufferers could quickly and quietly slip away into death. But if there’s any such mechanism, it hasn’t been brought to my attention. Yes, there’s the way people freezing to death are said to die peacefully, feeling warm. Why doesn’t that work for drowning or or poison or stabbing?

In the Christian religion, in particular, there’s a strong emphasis on Jesus’ suffering, both before his crucifixion and on the cross. Mel Gibson’s Passion of the Christ hammered this point home repeatedly, and was quite popular at the box office.

But I don’t remember anyone suggesting that Jesus suffered more than normal, given the things that were done to him. Why did he die after a day on the cross, like crucifixion victim ever? Why not a week, a month, a year? Compare that to Prometheus, who gave humans fire; his punishment was to be chained to a mountain where every day vultures rip out his liver, and every night it grows back to be torn out again the next day. As far as I know, Prometheus is still tied to his rock, while Jesus got to be king of the universe after three days. Now that’s suffering. As has been pointed out, Jesus had a really bad weekend for our sins.

So the sheer amount of suffering is far beyond any reasonable measure, with no relief mechanisms other than the ones we humans have come up with, like morphine and appendectomies. The world looks exactly the way it would if there were no guiding intelligence taking an interest in our well-being.

And even if suffering were necessary for some master plan, you’d think God would be able to at least show up in person and say so, even if our minds are too puny to understand the plan itself. But no. God, if he/she/it exists, can’t even be bothered to show up and say it’s okay. So why worship a being like that?

Oh, the Irony!

In a post railing against the organization Catholics for Choice, BillDo writes:

Here’s another irony: there really is no organization called Catholics for Choice. It has no members, and is in fact nothing more than a well-funded letterhead, sponsored by the establishment.

I’ve been keeping a distracted eye on the Catholic League for years, and for all intents and purposes, it’s just Billy and his Electrified Rage-Powered Press Release Machine. So he might not be the best person to complain about one-man operations that look like large organizations.

This press release was written and approved by Americans for Transparency in Douchebaggery. For immediate release. All rights reserved. And your mother dresses you funny.

Fourth Thursday in November Playlist
Victim Card Fatigue

From yesterday’s WaPo:

BALTIMORE — The Penn State scandal over a former football coach accused of sexually abusing young boys “reopens a wound” for the U.S. Roman Catholic Church, a leading bishop said Monday.

Archbishop Timothy Dolan, president of the U.S. Conference of Catholic Bishops, said the crisis reminds the bishops of their own failures to protect children.

Well gee, maybe they shouldn’t have covered up chld rape, then. Was I supposed to feel sorry for Dolan? Hang on, let me find my World’s Smallest Violin™…