Forever Learning

Forever learning and helping machines do the same.

Copying Bits in the Fastlane

with 5 comments

I’ve finally gotten ’round to rooting my ‘old’ G1 phone and installing the Cyanogen firmware. I will not bore you with the technical details of flashing firmware, but I would like to share an observation. To illustrate my point, I will need to cite some of the steps involved.

The technicalities of the following citations do not matter all that much, so if you want, you can skip right to the short translation. There will be no pop-quiz at the end, I promise.

Rooting the G1 is not as complicated as you might expect from the enormous amount of steps involved. The biggest obstacle for me proved to be the fact that I do not have a copy of Windows installed on any of my computers, so the following steps in the “the unlockr” guide (referred to by none other than Cyanogen himself) were practically impossible for me (underlining is mine; and as promised, there is a short translation below).

9. Now, goto http://download.cnet.com/HxD-Hex-Editor/3000-2352-10891068.html?part=dl-HxDHexEdi&subj=uo&tag=button to download the HxD Hex Editor. Save it and install it to your computer.

10. Take your SD card out of your phone and put it into the SD adapter it came with. Then put that into your computer so it shows up on your computer as Removable Disk.

11. Open the Hex Editor (Run as Administrator if one Vista or Windows 7) and click on the Extra tab, then click on Open Disk. Under Physical Disk select Removable Disk (your SD card you just put into the computer). Make sure to UNcheck “Open as ReadOnly”. Click OK.

12. Goto the Extra tab again and click Open Disk Image. Open up the goldcard.img that you saved from your email. You should now have two tabs, one is the SD card (Removable Disk) and the other is the goldcard.img. Press OK when prompted for Sector Size 512 (Hard Disks/Floppy Disks).

13. Click on the Goldcard.img tab and click on the Edit tab and click Select All. Then click on the Edit tab again and click Copy.

14. Click on the Removable Disk tab (Your SD Card) and select offset 00000000 to 00000170 then click on the Edit tab and click Paste Write.

15. Click on File then click Save.

Translation: download software of dubious origin, run software as Administrator, open disk, click a few things, copy/paste a few bits, save. Apparently all we want to do here is copy some bits from a file to (the beginning of) a disk. Copying a few bits can’t be this hard, right?

I mean, this is a computer; it copies bits all the time!

Luckily I was not the only Android enthusiast stumped by these Windows-only (and frankly, rather convoluted, manual  and error-prone) steps. Someone else had already solved the problem for me (thanks, Sven). The steps in his guide (for Mac or Linux) seems a lot simpler to me (again, underlining mine and translation below).

1 .Open your Mac’s Terminal under Applications -> Utilities ->Terminal (Or your Linux-Terminal)

2. Enter diskutil list and confirm

3. You should be able to see your SD-Card now. You can recognize it from its size (mine is 2GB) and that its type is DOS_FAT_32. As IDENTIFIER it says disk2s1.Remember this identifier.

4. Now unmount the card the folowing way: If your identifier was disk2s1 enter diskutil unmountDisk /dev/disk2 and confirm. If not, you have to replace the 2 with your value (the value that is written right after the word disk).

5. Now create your goldcard with sudo dd bs=512 if=~/goldcard.img of=/dev/disk2. If you need to, replace the 2 again. Confirm, wait, enter your users password (or under linux your roots password) and confirm again.

Translation: figure out which disk you need, copy bits to disk. The dd command used here is available in every flavor of *nix I’ve ever encountered. Let me break that crucial fifth step down for you.

sudo I am the Administrator, do the following as I say! (normal users are not allowed copy bits this way, that would be a Very Bad Idea)

dd Copy bits

bs=512 in chunks of 512 bits (“bs” stands for “block size”, in this case, not cow manure)

if=~/goldcard.img from this file (“if” for “in file” and “~/” just means the file is in my home folder)

of=/dev/disk2 to this disk (“of” for “out file” and “/dev” is the Device File folder, where *nix pretends devices attached are just files e.g. disk2 for my SD-Card).

It could be me, but that looks a lot simpler (and faster and less error-prone) to me than the Windows instructions.

The problem seems to be that, although Windows is perceived to be easy to use (and it probably is, up to some point), the lack of real and raw power under-the-hood can make anything as trivial as copying a few bits impossible without resorting to downloading dubious applications. It’s like having a car that is pretty and easy to drive, as long as you stay out of the fastlane.

And that, my friends, is one of the reasons why people like me do not like Windows very much. We nerds, we like living life in the fastlane.

Advertisements

Written by Lukas Vermeer

July 3, 2010 at 17:44

Posted in Android, Bash, Linux

5 Responses

Subscribe to comments with RSS.

  1. What Microsoft has done sinds Windows 95 is protecting the user from itself.
    Each new version of Windows is more pebkac immune than the previous version.
    Although it may be annoying for “us nerds”, it keeps the majority of the users safe of destroying their own system.

    Mac OSx is more user friendly and it still allows users to easily perform Admin tasks (huray for sudo) but the downside is that it wil only run on a Mac (I know there are ways to get it on a PC, but that’s not a very user friendly operation) and the big downside of Apple hardware is that it’s expensive.

    Linux may be more stable and gaining in user friendlyness, but it’s still got a long way to go. The other downside of linux is that until it will be used on consumer PC’s, large software companies will not make consumer software for Linux. Thus adding to the argument for Windows that it has more software to go with it (and would be the logical choice over Linux).

    But all that aside, the problem with the Windows guide is laziness. In .NET it would be easy to create a small program that will do all that for you. But aperantly Android users are seen as nerds, so no one took the time to develop one.

    Not picking a side here, just observing and concluding.

    Thanks for your insights 🙂

    geertjansmulders

    July 3, 2010 at 19:16

    • it keeps the majority of the users safe of destroying their own system

      Good comment, especially since Wikipedia notes the following concerning the dd command.

      It is jokingly said to stand for “disk destroyer”, “data destroyer”, or “delete data”, since, being used for low-level operations on hard disks, a small mistake, such as reversing the if and of parameters, can possibly result in the loss of all or some data on a disk.

      So, yeah, it makes sense to protect the user from the Destroyer of Disks. Leaving it out of your system all together is one way of protecting users, sure, but personally I prefer sudo.

      it would be easy to create a small program that will do all that for you

      My whole point was that I don’t think I should need a special program just to move some bits around. It’s a computer for crying out loud, moving bits around is all it does, all the time.

      Thanks for your insights

      And thank you very much for yours! 🙂

      (You put the Apple part in there as flamebait, didn’t you? ;p)

      lukasvermeer

      July 3, 2010 at 19:29

      • It’s a computer for crying out loud, moving bits around is all it does, all the time.

        And it’s Windows for crying out loud. If it wouldn’t protect users from themselves, I’t be at my parents a lot more often to fix everything they’ve broken.

        (You put the Apple part in there as flamebait, didn’t you? ;p)

        Actualy no, I didn’t. Personally I prefer Mac OSx over Windows. But Apple computers are expensive and we Dutch like to get things cheap. It’s just a fact 😉

        geertjansmulders

        July 3, 2010 at 20:20

  2. It could be me, but that looks a lot simpler (and faster and less error-prone) to me than the Windows instructions.

    I don’t think I really agree on this. The windows instructions look like this to me:

    1. Download a hexeditor that capable of editing physical devices. (I also don’t think cnet really has software of a dubious origin).
    2. Open your SD-card with Administrator rights (just like under Unix you can’t access a physical device without Administrator rights) with the Hexeditor.
    3. Write some shit to the beginning of the device.

    I doesn’t look that hard. On the other hand, as you wrote yourself, the dd command isn’t user friendly at all and I also believe it is more dangerous than using an editor that shows a nice dialog that visually shows you your devices with distinct icons for hard drives and removable flash devices. In case someone uses a Linux-distribution that has chosen to have their disk1/disk2/disk3 inodes pointing to physical harddisks, an average user can end up with destroying the partition table of their second harddrive. In such a case, the average user will not be happy. Also if you have a distribution that doesn’t have the disk1/disk2/disk3 inodes (because they are named differently), you will have a problem.

    Because of this I do believe the Windows instructions are a lot more system independent than the Mac ones. I also think the Windows Instruction explain a lot better what you are doing, while the Mac ones only tell you what you should do while praying it works.

    Don’t get me wrong: I like the dd tool a lot and I think it is very powerful, but I am conviced that making a mistake with it is a lot easier than making a mistake inside a very clear visual environment, at least when it comes to picking the right device, which is the crucial step here.

    Besides this, dd is also avaible for Windows (both inside the cygwin framework and as a standalone application and even as a system specific spinoff in the form of rawrite).
    And if you think that Windows should be able to do this without additional software: Windows 7 has “Windows Powershell” by default, which can probably do stuff like this out of the box.

    Paul

    July 3, 2010 at 23:42

    • 1. Download a hexeditor that capable of editing physical devices. (I also don’t think cnet really has software of a dubious origin).

      You don’t think. I simply don’t know. Fact is, I do not like to download new software from cnet.

      2. Open your SD-card with Administrator rights (just like under Unix you can’t access a physical device without Administrator rights) with the Hexeditor.

      True, but how do you know what this program will do with it’s newly acquired Administrator rights? It might do all kinds of stuff I do not want it to do. The dd command, on the other hand, does one thing, and one thing only. If it does the wrong thing, it’s because I screwed up.

      3. Write some shit to the beginning of the device

      We do not want just ‘some shit’ written, we want the exact ‘shit’ that was in the file. Copy/paste will probably work, but I do not like probably. I like to reread a statement, make sure it is correct, and press return; none of that ‘ctrl-c, ctrl-v’-stuff.

      I doesn’t look that hard

      That’s because you’re a Windows nerd. 🙂

      On the other hand, as you wrote yourself, the dd command isn’t user friendly at all and I also believe it is more dangerous than using an editor that shows a nice dialog that visually shows you your devices with distinct icons for hard drives and removable flash devices.

      It also shows you a lot of other buttons that you do not want to press, but who knows what’s what? Is there a manual?

      To be fair, the guide does describe how to list all the devices mounted; just not in a fancy drop-down list.

      Because of this I do believe the Windows instructions are a lot more system independent than the Mac ones.

      As long as the system you are using is Windows and the person who wrote the software considered your particular hardware-setup a possibility.

      I also think the Windows Instruction explain a lot better what you are doing, while the Mac ones only tell you what you should do while praying it works.

      I not only disagree on the assessment of the two guides, I also think there is more information online about what dd does than some random Hex editor (although I haven’t tried, so I could be wrong).

      Don’t get me wrong: I like the dd tool a lot and I think it is very powerful, but I am conviced that making a mistake with it is a lot easier than making a mistake inside a very clear visual environment, at least when it comes to picking the right device, which is the crucial step here.

      That I can understand. Which is why I like to be able to review the whole process (or command) once, before I press return; not click very carefully, twenty times.

      In this particular case, if you’re a user who cannot correctly identify a device name, you probably should not be rooting your phone.

      Besides this, dd is also avaible for Windows (both inside the cygwin framework and as a standalone application and even as a system specific spinoff in the form of rawrite).
      And if you think that Windows should be able to do this without additional software: Windows 7 has “Windows Powershell” by default, which can probably do stuff like this out of the box.

      Nice to know! Good to see Windows is finally catching up … ;p

      Like I said, Windows probably is easier to use up to some point, but I think this stuff is way beyond that. The reason I think the dd method is less error-prone, is because it has fewer manual steps and a clear audit trail. I had not considered the average user at all. I’m not sure an average user could (or should) manage with either method…

      lukasvermeer

      July 4, 2010 at 00:51


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: