Rough Book

random musings of just another computer nerd

Category: Hardware

My data-recovery story

I was looking through wayback machine at snapshots of my website, when I came across one from 2005. It reminded me of something I had almost forgotten. At some point in 2005, the network card in my FreeBSD server started to die. I got myself a new card and set about replacing the dying one. I can’t recall why anymore, but I guess I had needed to disconnect the hard-drive at some point. I remember that after I plugged it back in and booted up, I was greeted by a screenful of terrifying error-messages. Something horrible had happened to the drive that held my home directory, my website source-code, and my database. I had lost about 6 years worth of posts and images on my website. My first instinct was to power down the machine to prevent anything more being written to the drive, which I immediately did. After that I think I tried a bunch of disk-recovery tools to try and recover my data. But this was difficult because the filesystem was UFS. I can’t remember if there were any UFS recovery tools at the time, or if I tried them, but I remember having tried almost everything I could think of.

Out of desperation, I think I finally decided to use dd. I started dumping the data from the drive using the lowest size-setting possible in dd (I want to say it is a byte, but I don’t really remember). I then piped this into a perl script that would examine each byte, looking for magic numbers. The drive had been corrupted so badly that there wasn’t even any trace of a coherent filesystem anymore. I knew that the data I was getting were most-probably fragmented, but I didn’t care at this point. I would guess the file-type by looking for magic numbers, and then I would start dumping that data into a file until I found an ending marker, or if the file-type didn’t have one, until the start of another magic number. I remember having various settings in the script so that I could tune its behavior, especially when dealing with false positives. My priority was to retrieve my pictures, website, programming projects, and database. For my source-code I only had to look for ASCII data. For pictures I looked for file markers for JPG, PNG, and GIFs. The database was difficult though, because I was using MySQL. By sheer chance, I had decided to take a SQL dump of my website’s database the day before for backup purposes (ironically, on the very drive that would die the next day). This was ASCII data, and so it was one of the first things my script found.

I ran this script over a couple of hours I think, and then for most of the next day for good measure. Then I began the tedious process of sifting through these files, weeding out false positives. All said and done, I retrieved a good chunk of my data. I think I got back around 80% of my pictures, and almost all of my code and website source. It was a scary few days, but I’m glad that my desperation drove me to try something like this!

Explanation of the dialup sound

Ran into this awesome explanation of the dialup protocol, i.e., the sound you hear from a modem when it dials up. is back… mostly

So I’m sure you’ve noticed that this website was down for a while. It went down about three weeks ago when one of the (two) hard-drives on my server died due to bad sectors; it was eight years old. I didn’t panic (too much), because my WordPress database was on the main drive, which is still alive. However, my home directory was on the bad drive and I hadn’t backed up in a while (sigh), and so I lost some images that I had uploaded. What baffled me were my WordPress uploads. I was sure that I had installed WordPress on my main drive, but when I went to search for it, I couldn’t find any trace of the install. Due to this, I’ve lost a few images and I’m not sure if I’ll be able to replace them unfortunately. Oh well.

Also, I must bid farewell to a dear and old friend: my webserver enterprise. I set up my webserver almost 10 years ago (running FreeBSD of course), and she has been serving me faithfully for all this time. Over the years I’ve dealt with all kinds of disasters and I’ve been able to keep her running. However, after this latest disaster I’ve realized that I just don’t have the time to maintain and administer a server anymore; it’s hard to do with a full-time job and with a full-load at school (did I mention that I am doing my Masters?). Therefore, I’ve moved my site over to dreamhost. The cool thing is that they also offer shell access too, which in my opinion is absolutely indispensable. It took me a little while to migrate my WordPress installation over (I had to work out a few kinks), but now it looks like everything is running smoothly.

On that note, I’m looking forward to less server-administration and more blogging!

Rooting the G2

As some of you may already be aware, it appears that the G2 has some sort of “magic restore” (it’s not a rootkit) function that causes all changes to /system to be reverted. This means that you cannot remove any bundled bloatware. Even more troubling, it looks like the phone will perform the restore while it is running (i.e, you don’t need a reset). I haven’t turned on my G2, so this is what I’ve heard from people at XDA Developers. You can get temporary root on the devices, but after a little while (some people say minutes, others say hours; experiences seem to vary) root is lost. So it is possible that something is performing the restore while the phone is running.

Helpful folks on XDA Developers have posted the datasheet to the eMMC and another kind soul (damnoregonian) was able to get the value of the CSD register (the register that seems to control the behavior of the MMC): d00f00320f5903fffffffdff924040c8.

WP_GRP_SIZE[36:32] and WP_GRP_ENABLE[31:31] seem to be the bits that control the write-protect (per the datasheet). Currently these seem to be set to the default values per the data sheet (11111b and 1b). Clearing the bits should (theoretically) turn off the write protection. The value to do that would be d00f00320f5903fffffffde0124040c8. The CSD node is R/O and so you cannot echo to it directly. The only way to do it would be to write a kernel module/driver that writes to the register. Apparently the kernel exports a function called mmc_send_csd, and so one should be able to write to this register.

I’m tempted to write a kernel module that does just that. But since working at Intel I haven’t written any kernel drivers. Also while I did write drivers at Intel, I pretty much made modifications to what others before me had written, and so I never wrote one from scratch. I’m going to see if I can start on something this weekend… wish I was still in college… I had a lot more time then!

If this works (and that’s a big if), there’s still the issue of restores being done while the phone is in operation. That could cause a lot of inconsistency. So this might be a partial solution.

Either way, I’m sure someone will come up with a way to root the phone. But if there’s nothing by next Friday, I’m going to return the phone.


Someone posted updated specs. It looks like those bits are read-only. Bummer. Also, this from T-Mobile’s website:

Bellevue, Wash. — Oct. 7, 2010

As pioneers in Android-powered mobile devices, T-Mobile and HTC strive to support innovation. The T-Mobile G2 is a powerful and highly customizable Android-powered smartphone, which customers can personalize and make their own, from the look of their home screen to adding their favorite applications and more.

The HTC software implementation on the G2 stores some components in read-only memory as a security measure to prevent key operating system software from becoming corrupted and rendering the device inoperable. There is a small subset of highly technical users who may want to modify and re-engineer their devices at the code level, known as “rooting,” but a side effect of HTC’s security measure is that these modifications are temporary and cannot be saved to permanent memory. As a result the original code is restored.

Well, T-Mobile. How about you provide us technical users a way to root our devices? What you’re doing is stupid. You’re going against everything Android stands for. If I can’t root it, I think I will return my phone and get a Vibrant instead. I would have expected this from Apple or Verizon. But not from you. Very disappointing.

Unboxing my new T-Mobile G2 Android Phone

My wife called me at work today and told me that my new phone just came in the mail :). It’s the new G2 by HTC, which is supposed to be the successor to the G1. The specs on this phone are:

  • 3.7 inch WVGA capacitive touch screen
  • 5 megapixel camera with auto-focus and flash
  • Qualcomm MSM7230 800MHz processor
  • 4GB ROM
  • 512MB RAM
  • GPS/aGPS
  • WiFi
  • Bluetooth
  • Android 2.2
  • Runs on T-Mobile’s 4G/HSPA+ network
  • Slide-out keyboard

Read the rest of this entry »

Downtime and System Upgrade

Sorry for the downtime. My webserver had a failing hard-drive and I figured that while I was replacing the hard-drive, I would upgrade the entire machine as well. The box was a Pentium 4 1.4Ghz with 512MB of RAM that I hadn’t upgraded since I first built it in 2002. Now it’s been upgraded to a Pentium 4 2.4Ghz (hyper-threaded) with 1GB of RAM. Building from source will be a lot faster now! The whole upgrade process took a while because I was also in the process of upgrading another one of my machines and that took for EVER (some issues with shorting). Finally I had to install FreeBSD (version 8.0) on the new hard-drive as well as Apache, PHP, MySQL, WordPress etc. After I have everything set up, I’m going to make sure that I image the hard-drive so that I can restore it from backup easily.

How to replace the internal hard-drive in an Imation Apollo 500GB 2.5″ portable hard-drive

A few months ago I got an Apollo 500GB 2.5″ portable hard-drive from Imation. It’s nice and compact and I used it to store movies, music and other random crap. About a month ago I was trying to copy a few files onto the device when I noticed that operation was extremely slow. It was so slow that it was pretty much unusable. I wanted to test it out and see what the problem was, but I got busy with work and also my parents were visiting and so I was flying to California almost every weekend. When I finally got around to testing it out, I found that I couldn’t even mount the drive properly now. I could neither do it in Windows 7 nor in Ubuntu 9.04. Ubuntu would recognize the drive and it also saw that there was a partition on there, but other than that it wouldn’t do anything. I tried to use gparted to format it, but it wouldn’t even show up there. In Windows 7, I used Computer Management and when to Drive Manager. Intially the drive wouldn’t show up, but after unmounting and remounting it a few times, it finally showed up. I deleted the existing partition, made a new one, and then tried to format it. The format never finished; it was taking far too long. I then tried to format it in Ubuntu and this time gparted saw the drive, but it was unable to format it as well. I suspected that it might have some hardware issues (which is strange, because it’s not like I used it in a rough manner. Imation should probably make their drives tougher!) and so I tried to run some SMART tests on it. Ubuntu’s smartmontools doesn’t support USB drives. But on Windows, I used a trial version of ArgusMonitor to test the drive. As I suspected, there were a whole bunch of errors. Many sectors were unreadable and Argus suggested that I back-up all data immediately. I didn’t have much data on there anyway and so I figured the drive was pretty much toast. Then for kicks I wondered if I could replace the internal hard-drive. It’s basically a 2.5″ SATA hard-drive and I had an extra one lying around, and so I decided to see if I could replace the hard-drive.
Read the rest of this entry »

Ubuntu and Win7 problems

Yesterday I decided to reformat my Alienware m7700 Area-51 machine. It’s supposedly a laptop, but it’s actually a beast and it has a power supply that emits as much power as a small nuclear plant. Anyway, I put in a 500Gb and a 120Gb drive, with the 120Gb as a slave. The machine comes with a RAID controller (Promise SATA 378 TX2), but I have it turned off and in ATA mode. Win7 installed fine; the only problem I have is with the sound. My front speakers in my quadraphonic setup refuse to work. It’s strange. I even have the latest drivers from Creative for my Audigy2 ZS Notebook. It used to work fine before.

I figured I’d solve that problem later and decided to install Ubuntu 9.04 (Jaunty) on the 500Gb drive. The LiveCD boots up fine, but when I try to actually try out the LiveCD or even try to install Ubuntu, it fails. Everything hangs after this message:

ata3: COMRESET failed (errno=-16)

After searching on the internets, it seems to be a RAID controller issue and a fix exists in the kernel. So I don’t know why I still have the problem. If anyone knows of a solution, please let me know! I’m going to keep working on the problem and see if I can solve it.

My new T-Mobile G1 Android Phone

So I got my T-Mobile G1 Android phone yesterday, and boy am I excited! I had mixed feelings about it initially because I wasn’t so sure of the form factor. I remember thinking that it looked a little clunky, but now that I have it here, in my hand, I have to say that it feels well-made and rather solid. The exterior is made of plastic, and it feels smooth to the touch and not cheap at all. The keyboard slides out smoothly and I’ve had no problem typing on it. The interface is pretty snappy. I was actually surprised at how smooth and responsive it was. As far as the interface is concerned, the only issue I have is with the zooming. It may just be that I haven’t figured out to activate it reliably. I guess they had to go with this method because Apple is trying to patent the “pinch” motion for zooming. I think that is completely stupid, of course, and the patent office should throw it out.

Anyway, so once I picked up the phone I opened up the package and carefully laid everything out. T-Mobile sent me another SIM card with it, which didn’t work; I guess you have to activate it. But that really wasn’t a problem since I have my old SIM card. Once I put it in the phone and hooked up the new battery, I started up the phone. When it firsts starts up, it asks you for your Google account information so that you can sync everything with your phone. As soon as it synced up (which happened within a matter of seconds), I was good to go. I started off by trying to import my contacts from the SIM card. This is where I came across a problem. Apparently (I could be wrong, I was too impatient to explore more options) you can’t import all your SIM contacts in one go. You have to do it one by one. I found that a little annoying. You can either import your contacts one-by-one, or import them all in one go by hitting the Menu button and then choosing the Import all option. As soon as I had my contacts imported, I started exploring the other options. The home screen is pretty sweet. You can drag and drop icons on there, and swipe left and right to either add more icons or run google search. In addition to GMail, you can add other POP3/IMAP accounts and you can also use other IM networks in addition to GTalk. The G1 also has a music player and a bunch of sample tracks (including Flight of the Conchord’s “The Most Beautiful Girl in the Room”). The phone doesn’t have a headphone jack, so you have to get a USB to 3.5mm converter. The Bluetooth works fine and synced up to the Hands-free Link in my Acura without any problem. Although, like the iPhone, you can’t transfer files via bluetooth. I imagine that they will fix this eventually. The phone also has a feature where you can set up a “pattern” to unlock it. You have to “draw” a pattern on the screen connecting nine dots (laid in a 3×3 grid pattern) to unlock the phone. The other cool thing was the “Compass Mode” in the Google Maps street view. The phone adjusts the street view based on where you’re pointing it, and so the scene on the phone actually moves when you move the phone. It’s pretty neat!

So, my opinion? As far as a phone (or PDA) goes, I think that the G1 is pretty solid. I know that some reviewers claimed that they didn’t think it would really appeal to most people. However, I think that it will. It has a pretty slick interface and a lot of neat features. Additionally, I think the demographic it will appeal to most, is people like me – developers and people who like to play with neat gadgets. I know that once I get some more time on my hands, I’m going to try and develop stuff on it. iPhone killer? I don’t know. But I think the G1’s strength is that it is completely open. In effect, it is the antithesis to the iPhone, or the anti-iPhone. Google doesn’t control the G1 (or Android) as strictly as Apple controls the iPhone, and especially with regard to the SDK. Google seems to want to encourage developers whereas Apple seems to want to encourage them only as long as they play by Apple’s rules. Consider also the fact that if you do want to develop for the iPhone, you can only do it on a Mac. Whereas you can develop apps that will run on Android on Windows, Mac, or Linux. I guess we’ll have to wait and see. But for now, I’m just happy to have a cool new toy er… I mean, phone!


I’ve noticed a lot of queries to this blog post regarding the importing of SIM contacts into the G1. The process is quite simple:

  • Swipe the dock at the bottom of the screen upwards to access the G1’s menu.
  • Select Contacts from the menu.
  • Hit the Menu button and then select Settings
  • You should now see “Sync Groups” and “SIM contacts importer”
  • Select SIM contacts importer. You should now be able to import your contacts.
  • If you want to import them all in one go, hit Menu and then select Import all

As a general rule, if you’re having trouble finding (extra) options, hit the Menu button. It should show you a few more options.

The G1's outer box
The G1’s outer box

The G1's inner box
The G1’s inner box

The G1 inside the box
The G1 inside the box

The G1's accessories and manuals
The G1’s accessories and manuals. The accessories you get are a carrying case, battery, headphones, USB cable, and charger. Oh, and you get a SIM card too (if you ordered through T-Mobile’s website)

The G1 inside the box
The G1 inside the box

The T-Mobile Android G1
The T-Mobile Android G1

G1 side view
G1 side view

G1 keyboard flipped out
G1 keyboard flipped out

G1 home screen
G1 keyboard flipped out

G1 menu
G1 menu

G1 dialer
G1 dialer

G1 displaying Google Maps
G1 displaying Google Maps

G1 displaying Google Maps (side view)
G1 displaying Google Maps (side view)

G1 displaying Google Maps Satellite View (side view)
G1 displaying Google Maps Phoenix Satellite View (side view)

G1 displaying Google Maps Street View
G1 displaying Google Maps Street View

G1 displaying

The G1 in its case
The G1 in its case

My new laptop

I recently bought myself a new laptop – the Dell XPS M1530. I was originally considering a Macbook, but that was a little too pricey for me. I started to fancy OS X ever since I found out that it is basically FreeBSD at the core. Also, there is the eye-candy. Other than the price-tag, I also realized that the only reason I would want the Macbook was because it looks so good. That didn’t seem entirely practical. I could still get the eye-candy and the productivity on another OS. The last laptop I bought was an Alienware beast. It was ridiculously heavy and I got sick of lugging it around. It basically a desktop masquerading as a laptop. In addition to being really heavy, it generates quite a lot of heat. Enough to burn your lap. But it plays games really, really well. Anyway, I decided that I would look for a nice non-Apple laptop. After scouring the Internets and reading a bunch of reviews, I settled on the XPS. It’s sleek, stylish, fast, portable, and it got a bunch of good reviews. I went to the Dell site and configured my XPS:

  • Intel Core 2 Duo Processor T7700 (2.4GHz/800Mhz FSB, 4MB Cache)
  • 3GB Shared Dual Channel DDR2 SDRAM at 667MHz (2 Dimms)
  • 256MB NVIDIA GeForce 8600M GT
  • 250GB 5400rpm SATA Hard Drive
  • High Resolution glossy widescreen 15.4 inch LCD(1680×1050) 2MP Camera
  • Slot Load DVD+/-RW (DVD/CD read/write)
  • Integrated Sound Blaster Audigy HD Software Edition
  • Intel Next-Gen Wireless-N Mini-card (4965AGN)

It’s got some punch. I’m mainly going to use it as a development machine so the RAM and speed definitely help as far as compile-times go. They estimated about two weeks to build the laptop, but actually I got a pleasant surprise when the laptop arrived a little over a week after I ordered it. I wasn’t disappointed in the least when I opened up the package. The first thing I did was blast Vista off the hard-drive and install PC-BSD. This is where I learnt a hard lesson. Stability in the BSD world comes at a price. You don’t have very good hardware support (for no fault of FreeBSD; I’ll rant about this later) for the latest hardware. Drivers are not included until they are reliable and stable. As a result, my Marvell Yukon 88E8040 Gigabit Ethernet card, and my Intel 4965AGN Wireless-N card were unrecognized. Marvell (surprisingly) had a FreeBSD 6 driver on their website that is supposed to work with the 88E80XX series, but I was unable to get it to work on my system. I tried using ndiswrapper to get the Intel card working, but I only succeeded in crashing my system very nicely. I was pretty bummed. I really didn’t want to go back to using The Evil (Vista), and so I decided to play around with kubuntu for a while. It was nice, and I may get back to it. But for the hell of it, I wiped it off and tried to install OS X on it. I was able to get a “patched” Leopard ISO and I actually got it to install on the XPS. However, I wasn’t able to get it to recognize any of my network devices. So after playing around with that for a while, I went back to The Evil. I am hoping that by the time PC-BSD 2.0 or FreeBSD 7.0 rolls around, there will be more support for the network cards. If that’s the case, I’ll definitely be wiping out Vista and installing PC-BSD (or install FreeBSD 7.0 and build KDE). I’ve been using Vista for a little while, and I guess it’s not so bad. It’ll stay out of your way if you ask it to. But it really doesn’t compare to either PC-BSD, Kubuntu, or Leopard. As far as the XPS, I like it a whole lot. I think Dell has done a pretty good job with it.

All original content on these pages is fingerprinted and certified by Digiprove
%d bloggers like this: