safecopy is the anydvd of linux

Before you try anything here – this guide does really bad things to the atapi bus. If your computer suddenly reboots and hasn’t written consistent files due to a bus crash, don’t blame me or the utilities mentioned in here. Just buy a computer that doesn’t suck or buy a USB drive.

I want to buy someone a beer.

I have had a hell of a time with my kid biting everything (including his tongue) and that includes DVDs. I know I’m not alone – DVDs which come from Netflix are great examples of CSI work. You know the previous guy has little kids about the same age because you can look on the DVD and get their dental records.

I’ve talked about this before, but kids trash media. Not only do they trash media but the media itself tends to have copy protection which is intentional trash already on the media before your kids got to it. Disney does this to an extreme. The way it looks is a bunch of chapters on the disk which might be the right size and time except they’re filled with garbage. You need the physical copy of the disk. Previously you could use dd on the disk and that’s how I used to do it. I happened to run across safecopy when reading up on disaster recovery stuff for work and wow.

Here’s how safecopy works – it’s very similar to dd where you set the block size to huge and no read retries. The problem with the dd method is that if you have two files spanning the block size (and remember that DVDs don’t really have blocks, so “yes”), you discard the start of the next file. I’ve been getting around it by setting the block size to low for DVDs with “copy protection”, but this gives me plenty of time to make a list of people to kill while I research who came up with this. If the disk is scratched, I set the block size to a larger value (10M) because you know you’re going to hit that same scratch for literally the entire 8.5GB or whatever disk. This generally worked well so long as you didn’t hit the transition of the files.

safecopy changes that entirely.

You run safecopy in passes. The first pass is no recovery past bad blocks, and it skips a lot of blocks. In fact it’s no different from running dd. dd hits a bad block and skips to the next. safecopy hits a bad block and skips to the next and it keeps track of which addresses have bad blocks in a file it’s written. The magic is in the options – safecopy lets you specify a size of blocks to skip in bytes (16 is the default) or percent of size. That second one is the magic one, because block size changes physically as you move closer to the edge of the disk, and the edge of the disk is the part that goes in your little biters mouth. The question is – how many blocks are destroyed under each tooth mark?

How did I use it?

safecopy –stage1 /dev/sr1 /home/knarrj/tmp/damaged.iso

That makes safecopy do a fast pass and write off 10% of the total disk size (8.7GB) to bad sectors when it hits a bad sector. It writes a stage1.badblocks file and makes a note of the addresses it skipped. The ISO there is padded. If you try playing this ISO in VLC or whatever you’ll probably play it a bit and then VLC will crash when it tries to jump to a sector with the content BaDBlOcK. Then follows the magic:

safecopy –stage2 -I stage1.badblocks /dev/sr1 /home/knarrj/tmp/damaged.iso

Cool huh? Now safecopy goes back and reads the disk backwards from the boundary of the amount of bytes that it skipped to find the last, best sector. If we ran stage 3, it would be like dd again and attempt to read every byte on the disk. The first pass is about 15 minutes or so and the second pass is about 45 minutes meaning you can beat teeth marks and structural copy protection in about 1 hour.

Meditations on Parenthood

I managed to get the MR2 all fixed up, the battery it’s been running with I used a few zipties as buffers for the battery terminal. Finally those went due to resistance, and the battery terminal was so worn out it didn’t make any contact with the car. Sears tried to sell me a Wiz Bang battery with a meter on the side and a four year warranty and maintenance free (minus labor, of course) for $200. I asked what the cheaper one was.

“Well, it’s a battery with a two year…”
OK GIVE ME THE CHEAPEST BATTERY.
“You don’t want that, it’s got a half year warranty and we’ve had terrible luck…”
HOW MUCH DOES IT COST?
“$50”
SOLD.

The MR2 runs fine. It vacuum stalls until it gets a few miles on the engine but once it warms up it’s totally happy. Now I just need to make use of my garage in my house to fix up the paint and do the cosmetics and OH WAIT I DON’T HAVE A HOUSE.

The house hunt goes well, there’s some incredibly shady deals out there however. Me and Kelly found a house we both really loved – only to find out they “forgot” to put down termites on the disclosure. This new house we’re going to look at tomorrow is in middling condition (I’m fine with it), another bank deal (tons of those), and located in Oaks. And it will probably have termites.

On parenting – Some of my friends have kids. DON’T LET THAT PREVENT YOU FROM COMING OUT AND SEEING PEOPLE.