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.

User Guide: How to Theme Gnome 3

If you’re running Ubuntu, you’re probably running Unity. Stop now and install a real distribution. Candidates include OpenSuSE and Fedora.

Alright now that we’re done that part, how do we fix the crap they shipped Fedora with? I know there’s potential in here somewhere, but it’s hard to find under the absolutely giant title bars on the windows. In fact, once you get used to pressing “logo” and typing something, it’s pretty cool. I still haven’t figured out how to unpin the favorites bar from the right hand side, but I’m sure it will come along. What I want to cover is how to install and use themes.

Step 1: Install gnome-tweak-tool. If you’re using fedora, it’s in yum.

Step 2: Find a theme you like. Places to check – Webupd8 or DeviantArt or More DeviantArt or Gnome Look. You’re looking for Gnome Shell themes (which change the notification bar and Activities pull out) and GTK 3 themes (which change the look and feel of apps).

Step 3: Grab and install ThemeSelector. Note that this is all beta, but it’s also the nicest version of a theme selector I have seen.

Step 4: GTK themes go in /usr/share/themes and gnome shell themes go in .themes (or also /usr/share themes). Pick one. I suggest /usr/share/themes since this is where legacy themes look for their resources. After adding a theme, restart gnome shell (ALT+F2, r).

My gnome shell is Ubuntu Ambiance Dark. My GTK theme is Hope. If you use gnome-tweak-tool, the window title bar is governed by the Windows tab’s current theme entry. The Interface tab will let you set the GTK+ theme. The Shell tab will let you set a Gnome Shell theme, but it seems to be less capable than the Theme Manager. The Theme Manager appears when you mouse top-left and select the themes tab. I know it’s more compatible than gnome-tweak since gnome-tweak throws out anything it doesn’t think is a theme, leading to much frustration.

HOWTO: Update You HP BIOS From Linux

Linux users consistently get the short end of the stick when it comes to BIOS updates. Oftentimes dmesg will show us that something is wrong in the BIOS and we have no way to fix it. This is especially infuriating when you have a laptop with no CDROM drive and it doesn’t like to boot off usb because of… a bug in the BIOS. This is the HP 6730b laptop with the 00D BIOS. It’s a disaster of a monumental scale. It’s a nice laptop when it works, but oftentimes with fedora or suse (or any other distro which uses the intel driver rather than vesa) the screen “flickers” and the laptop runs like junk until you CTRL+ALT+F2 it and back again a few times. The dmesg log will be filled with errors about intel_iommu and the kernel will report a crash.

Officially the problem is a buggy BIOS, what’s actually happening is the iommu register is being mapped to ‘0’ rather than any actual address. This means the CPU has it, the BIOS maps it incorrectly and then tells the OS to use ‘0’ as the address in memory. If the kernel didn’t do sanity checking your box would crash. As it stands it simply causes an interrupt (the screen flashing) and then it’s caught.

HP’s site is amazingly bad and offers up three options – Bootable CD, USB and floppy. The laptop won’t USB boot, because of the 00D BIOS. The laptop doesn’t have a floppy drive, and who does anymore? The laptop will boot off a CD, but this requires you to actually find a CD. I tried a DVD and booktyped it as a CD just for grins and it didn’t work. How are we supposed to update this crap? Install windows?

The workaround: If you don’t want to do this, the cheap workaround is to turn off “virtualization technology” in the BIOS and set intel_iommu=0 in the grub.conf. You will lose access to virtualization accelleration. It will still cause kernel problems, but it will happen much less frequently. This also fixes the problem with sleeping unless the box had the problem when it started up.

The fix: Ready to take the plunge? Get yourself an HP account first. Registration is free.

Install syslinux. In fedora, this is yum install syslinux and it puts in in /usr/share/syslinux. I would also install the perl stuff if you plan on doing a lot of servers with this. If HP continues this sort of crap for servers that they did with laptops, plan on doing this – a lot.

Grab sp50750. There’s actually an F17 BIOS, but it only affects Windows 7 and appears to have driver updates also.  If you want that one instead, use sp51317. As of right now the sp51317 download link doesn’t work, I believe they pulled it.

At this point I used wine to unpack the executable and I used rar to dump out ROM.CAB. Grab the ROM.BIN file and tuck it somewhere safe.

Grab sp50751. This is the F16 BIOS but this is for a different laptop. Do not apply this BIOS to your laptop. You have been warned. I didn’t try to apply the BIOS from that link to this laptop.

When you unpack that one, you will notice an ISO directory. You want to go in to that directory and mount the ROM.ISO – mount -o loop rom.iso tmp will mount the iso to a tmp directory. Create tmp first if it doesn’t exist.

Inside of your tmp directory (which is really the iso), you will see a /boot directory. Inside of that directory is a release.img file. Now we’re getting somewhere! You can run file release.img and see that it’s actually a floppy disk. Sweet! Copy this floppy image out of the ISO.

Mount up the floppy image. mount -o loop release.img tmp will do it, just like the CD. The difference is we can read and write to the floppy image while we can’t do that to a CD image. Doing an ls into our floppy image shows a 68PDD.BIN file, which is the BIOS. How am I so sure? It’s the only BIN file in there. Copy your ROM.BIN file we extracted earlier over the 68PDD.BIN file. Hit yes to overwrite it and then unmount the image.


We can boot from it!

Copy release.img and /usr/share/syslinux/memdisk to /boot.

Edit /boot/grub/menu.lst and add the following:

title Floppy Disk Image
root (hd0,0)
kernel /memdisk
initrd /release.img

Reboot and select “Floppy Disk Image” from the grub menu, and it will boot into freeDOS and flash F16 to your laptop! Next time you boot you’ll have the new BIOS after it does some tests.


[    0.000000] WARNING: at drivers/pci/dmar.c:633 warn_invalid_dmar+0x7d/0x8d()
[    0.000000] Hardware name: HP Compaq 6730b (SERIAL NUMBER)
[    0.000000] Your BIOS is broken; DMAR reported at address 0!
[    0.000000] BIOS vendor: Hewlett-Packard; Ver: 68PDD Ver. F.16; Product Version: F.16

New F16 bugs! Good thing HP fixes them all!

Game Review: Brink

The quick and dirty review for the impatient – If you play bad company for the objectives, you will enjoy this game. If you play bad company to have cool vehicles and mostly play TDM, you won’t enjoy this game. It’s basically bad company sans vehicles where only the right class can capture the objective at any given time.

First, a story about amazon. I ordered this when it first came out when Amazon was doing double points trade ins. I sent in three games, one of which was previously purchased used. The used game was in good condition. Amazon said the disk was damaged in shipping, which was strange since I shipped it back in a box I got from amazon in the first place to ship me a game. I told their customer service if it’s damaged, I want it back so I can sell it on ebay. They declined, but they did credit me the game as though they spent it. (They eventually sent it back, so I used it as trade at EB Games). I ordered brink and not only did they not ship it in time to get it today, but they shipped me the wrong version. They sent the PS3 version, not the XBOX version. Something happened when they moved the release date up which made them lose the original order, so they just fulfilled it with the PS3 one.

When I asked them to return it, they said that I couldn’t get a refund, I had to accept delivery, relabel it, send it back, then I would be given a credit. I hung up on them. I called them back and got another rep, who I explained my kids ordered the game and it was an unauthorized purchase, and they were happy to give me a full refund. Alright! That’s sweet since walmart has it for $5 cheaper.

Now, the game has a points system for doing stupid crap like watching all the videos. I couldn’t care less. Thankfully they’re about as much as playing a match well so it doesn’t matter. Scoring isn’t an issue, if you like to shoot dudes play assault. If you like to heal the dudes shooting play medic. If you like to uparmor people and buff the guns, possibly placing turrets and generally being a real indirect pain in the ass, be an engineer. If you like to sneak around, be the spy.

Just a note on the medic, you can revive people who are DBNO similar to gears. It works really well since you toss them a syringe and they decide when to use it. The “medic problem” which bad company has where the medic gets you up at the worst time is gone.

And the spy, what does he do? When you’re doing an objective, you undisguise so what good is he? Everyone and everything he sees (friendly, opfor) is shown as an outline on your view. It’s really very useful, it’s like the UAV in bad company. It’s also hilarious to mele people and then dispatch them, but until you unlock the silencers you should avoid that.

Weapons attachments let you go nuts in the game, and there’s a guilty sense of dressup which works out really well. Unlocking a flash hider is sort of like the accessories in Army of Two but they actually do something. Silencers hide you from the map, grenade launchers ruin your day and taped mags are actually taped together. It lets you take a very nice looking gun and stick the worst looking crap on it. It’s very Army of Two without making you feel gay playing it.

Objectives work out well, I don’t have much to complain about except that three people working in a squad tend to dominate. Then again this is what Bad Company has happen also, the public players tend to play the game as team deathmatch while your buddies will actually do the objectives. There’s always one or two main objectives leading to the next mission. While not as broad as Left for Dead in how you get things done and the objective flow, the secondary objectives tend to really give your team an edge. Capturing a supply point moves your spawn or lets you refill ammo or change class. This works well until you realize you’re wasting mission time doing that. Also it’s a great way to get shot which is another thing I object to – if you’re trying to change class, you’re probably doing it for a reason. The fact that you can get grenade stuck while doing it is annoying. At least each starting depot has a set of turrets, but it’s a design annoyance that the first station doesn’t give you invincibility. You can change your class in the pregame menu, but not in a menu after the game starts.

Classes have style, there’s really no hiding in the game as there’s no real outdoor maps. Maps can be so dark it’s hard to get around. It’s OK to be wearing a giant british flag on your body with bracers made from tires and your face painted hunter safety orange – the game is so fast and close there’s no sniping or hiding. Sometimes this gets stupidly tight with accidentally running into the enemy spawn and immediately being sliced to ribbons. Otherwise the players and levels look unique and fresh.

Abilities – cool stuff here. Engineers buff guns, and eventually armor. Some abilities are class specific like that, others are simply neat tricks such as the ability to toss a grenade and lock onto it with the autoaim on the sights to detonate it in mid air. These are fairly high cost though and I haven’t dug into it too much.

Finally the downside – the game lags like it’s cool. I haven’t figured out how the game chooses host but I have a very nice router here and it’s usually not me. Other problems are the interface – you have to accept the invitation and then select “join on invitation” in the menu, it’s just awkward. And the worst – if you don’t install it to your hard drive, expect Left 4 Dead problems with load times and texture pop in. The manual doesn’t stay install it or else, but it helps. A lot. The last niggle is a balance concern – you get more points for shooting people than “moving the chains” on objectives. Case in point, me and a buddy were playing and we were both engineers. I cracked the safe and stole the intel almost single-handedly, but he got the best player award for having a huge kill count. Sometimes it just doesn’t seem like doing the objective is rewarding enough.

Verdict – Just like it says at the top. If you like games like Team Fortress or Bad Company or Left 4 Dead, this is a great game. If you’re more into deathmatch mayhem, this may not scratch the item. Personally for me, being a huge Rush player in Bad Company, this stuff is great.