Published: 2012-Jun-06 12:11

Fighting with computers

Summary: { "Lost your partitions": "Use finnix to testdisk then boot-repair if you have to." }

I have spent many years fighting with computers and though I still don't admit to myself that I'm a techie I flatter myself that I'm rather good at it. I don't want to have to fight with computers any more.

Last week I replaced the CPU fan in a Latitude D420 laptop. This isn't like changing one in a desktop, (two screws, two clips and one connector on the motherboard) oh no. Dell, rather helpfully have a step-by-step guide on their website, (which I was rather impressed with) that not only outlines and then lists the exact steps and in which order, it also has pictures, (which rather saps me of my glory, but does mean that I was less likely to kill the computer.) So what are the steps?

Power down; Remove the battery; remove the RAM, the LAN card, WAN card; remove the hard disk, (done this one once before when the first one died); remove the strip between the keyboard and the screen; remove the keyboard; remove the screen; remove the "palm rest" (which is actually everything on the top side of the computer that has not already been removed.

Then you just flip it over, remove the broken fan, drop in the new one, (second hand from, thank you guys.)

Then reconstruct. There is a strange 'breath-holding' like stasis during the whole process where by I was aware that I may end up with a paperweight but was also hoping to have a working laptop again, (and as I'm writing this blog entry on said laptop it would not seem to be tempting fait too much to suggest that it was a success.)

Yesterday I powered up my desktop and got nothing after the BIOS screens. I built it from scrap, (literally - a friend liberated the case and fan and under-car-neon from a recycling facility that is happy for you to take and use the bits that they have already picked over.) The motherboard, CPU+fan, RAM and hard-disk are all new... ish it turns out. I bought the hard-disk from a local shop, (trying to do my part to support local commerce). I checked the SMART data and the disk had already been powered up 15 times and Power-On Time: 198. hmmm that seems fishy. I had already blown linux onto the disk without checking for residual data, but there had been no obvious clues like partitions, (though now that I see the low Power Cycle Count and the large Power-On Time I feels like the disk had been used for one thing, (maybe porting data from one machine to another, or saveing data from a dying machine) and then when the job was done it was left overnight with a dd blowing zero all over the disk - but this is speculation.)

So what had happened? It was working 12 hours before and no one had touched it since. I had shut it down myself and as far as I know it cleanly shutdown.

I booted into finnix 102 and took a look at the disk while I torrented finnix 104.
My go-to program is cfdisk; which has a nice ncurses interface but for that it sacrifices some of the power of fdisk. cfdisk told me that there were no partitions on my disk, (not the best news), so I went to fdisk for a second opinion. fdisk told me that there were a few partitions, but that the main Linux one "did not terminate on a cylinder boundary". This was a new error to me - so after searching the blogs and forums it seems that this is nothing to worry about, (pretty scary error for "nothing to worry about"). It felt like doing open-heart surgery to find that the person had two aortas and to be told by the head of surgery, "don't worry about it."

So I ran

gpart /dev/sda

and waited.... and waited (must remember to add -vv, though that still gives no good indication of progress.)

It found partitions and even let me make a note of them, but my midichlorians told me not to write that back to the disk.

By now I had added testdisk, (wow! just wow this is amazing!) to my new Finnix 104 on my pico USB flash-drive. testdisk seems to do what gpart does, but that is like comparing a Bugatti Veyron with an

Austin Maxi.  Same thing, but different.  

After testdisk did its thing I tried:

mount /dev/sda1 /mnt

and was rather surprised to see my old filesystem. So surprised, even, that I did not believe that it was real. I checked the UUID of the partition:

blkid /dev/sda1 2>/dev/null || tune2fs -l /dev/sda1 | grep UUID

 matched the --fs-uuid /mnt/boot/grub/grub.cfg, (which it did!)

I felt elated. I felt "I.AM.INVINCIBLE" and then the liquid nitrogen of a reboot hit me. I rebooted and same nothing. I booted back into Finnix and yes the partition was still there and I could still mount it.

Reboot. Cold Reboot. Time to go make a hot beveradge, to 'span' my thinking time.

I downloaded and booted into that... played about. Tried a few things. realised that finnix 104 seems to do all of that and for my monkey, does it better.

Then I tried booting from the original CD and installed Boot-Repair. Boot-Repair looked like a gui only, but a few of the steps, (and this surprised me in this-day-n-age) asked me to copy-n-paste lines into a terminal, (why not just run as gksu -u root boot-repair #and do all of the heavy lifting?)

Boot-repair asked me, "do you want to write GRUB to ALL of the hard-disks?" This was not something that I had thought of. The BIOS knew which hard disk to boot from, (because I had told it) but there was an old disk from a previous machine that did have the boot flag set on one of its partitions.  In the end I opted to just write to my main disk.. and  lived happily ever after, (or so I hope.)

The niggling thing? I now have 1.5 meg of blank disk space between my main partition and my swap space that was not there before.

The other thing that I thought of: I installed Ubuntu 12.04 on this desktop and just let it chose how to partition the disk... Then the partitions vanished, (I still don't know why.) Surely Ubuntu should be able to "just put the partitions back in the same defaults"? Enquiring minds would like to know... or they could just use testdisk + boot-repair.