Adventures in Hard Disk Geometry Translation

Wow. Ok, while my DSL was out, I decided to play with Knoppix. Well, the short of it all is I completely hosed my partition table, and nearly lost all my data. That sucked. I asked for help as I was getting errors from Partition Magic and PARTINFO that I couldn’t decipher. I found a whole new range of computer problems I’d never experienced, and was dying to figure it out. I was 10 again for a while, learning something so basic, yet new to me. Looking back, it’s been a blast fixing it, and I’m glad it happened and I didn’t lose too much data (nothing important). For those technically inclined, below is a more detailed account of what happened and how I fixed it. I posted this to the newsgroup too, to let the few folks who chimed in how things went. I post it here for a different and wider audience. Please feel free to comment. 🙂

I found and fixed the problems, and in the process, learned a lot more about geometry translation and partition tables than I ever knew before (which wasn’t a small amount, or so I thought). Turns out there WAS an issue with the partition tables, I just wasn’t understanding geometry translation differences enough to see it.

First, I shrank the last logical partition on my 80GB drive, and the end of the extended partition containing it so I’d have some space at the end to play with Knoppix (swap space). Partition Magic 8 did this fine. It turns out PartEd was my problem causer. Due to how I managed my upgrade a year ago from a 30GB primary disk to this 80B primary disk, was that the large extended partition was created first, that data copied over, then _outside_ of Windows, the primary partition was created and copied (so XP wouldn’t bitch about being moved), so the partition table was “out of order”. The EXT was in slot 1, the PRI was in slot 2. This didn’t cause any issues to anything, ever. But when I created a swap partition at the end, PartEd decided to rewrite the partition table, and didn’t do it right. It recorded the disk data in terms of 158,811 cylinders and 15 heads, when the BIOS (and DOS and Windows based Partition Magics, also) looked at it as a disk of 9,964 cylinders with 255 heads. Thus, when the system rebooted, the BIOS couldn’t find the boot sector with the information given.

Now, DOS and Windows and Linux all could read the disk fine, which is how I was able to save the data, but booting was impossible. Had I realized this earlier, I could have saved the effort of data copying/moving etc.

I fixed this boot problem by moving all my data (backed up into a ghost image) into a partition at the end of the disk, and carefully recorded it’s starting and ending locations in absolute sectors. Then I wiped sectors 0-63 to erase all partition data and MBRs and backups. I booted from my XP CD (splistreamed with SP2 a while ago, handy to have) and used it’s recovery console to DISKPART a 30GB partition at the front of the disk, and formatted it with FAT32, and installed XP to it.

When that worked, I rebooted into DOS (via a Win98 install on a second small 4GB disk I had laying around), and used Ranish Partition Manager to translate the absolute sector values of my backed up data into terms of 9,964/255/63 CHS values. Now, strictly speaking, these new values were “invalid” because the backup partition no longer began on cylinder/head boundaries (0 or 255), but in the middle, 5120/81/1 CHS. But, that’s ok because I just needed to now copy my 28GB of backup data from that partition to my new primary, correct partition. I did this, and deleted the old partition, and then I fixed up the partitions on my disk in Win98 with PM8 as needed, and reconfirmed WinXP still booted from the disk. Now everything is fine again.

Lesson learned: Always check CHS values of your large disks before repartitioning, and maybe even keep backups. 🙂