Fixing a Windows/Linux Dual Boot Laptop

More days in the life of Curt…

Last week my elbow knocked a full cup of coffee off a coffee table in the living room. Fitting I guess… No big deal, clean up the table and the rug. Except… I happened to have a laptop leaning up against a chair charging. And it’s bottom was facing outward. And it’s bottom has ventilation holes… Not good…

I saw coffee running down it’s bottom… It was off so I quickly grabbed it, pulled the power, removed the battery and wiped it off. Fearing some coffee might have got inside I place it on a cast iron radiator to dry out. Those things come in handy…

Let it sit drying out till the next day, then the ordeal started. It was a dual boot system Windows 7 and Linux and both were acting flaky. Decided to preserve the data on the hard disk. It’s got two Windows partitions and ten Linux partitions. Copied each partition off as an ISO using dd_rescue. During the process 3 partitions had sector errors. Not good…

Not sure if the disk errors were cause and effect of the coffee or not, but ordered a new hard disk. Bigger. Recreated the data on the new disk exactly as it was. That left ~350GB unused. I’ll deal with that later, lets get the thing working again first… Boot Windows… Sorry. Nope. Boot Linux… Sorry. Nope…

Tackled Windows first. Through what recovery/diagnostics I could do and Windows obscure way of logging and reporting things I found something that seemed to indicate Wdf01000.sys might be corrupt. OK. Fired up a Desktop Windows 7 Desktop box and grabbed Wdf01000.sys. But how to get it on an laptop that won’t boot… Pulled the disk out again, connected it to another computer, put Wdf01000.sys on it.

Wallah! Windows booted. Did a full scan/comparison of all Windows files, found another one that might be corrupt, System.Design.dll, replaced it. OK. Windows seems to be fix. Now for Linux. Linux hangs on boot. OK. But first let’s re-partition the disk to use the additional new space. Get that out of the way. Some for Windows, some for Linux. Copy the now working Windows partition off to an ISO and start re-partitioning.

Not as easy as it sounds. The new disk uses WD’s Advanced Formatting, which for one this changes the sector size from 512 to 4096. It still reports the sectors as 512 in size but they’re really 4096 which makes keeping the partitions on physical sector boundaries for alignment challenging. Especially since I don’t want to muck up the working Windows partition but I want to be able to expand it.

fdisk, due the 4096 verses 512 sectors wasted about ~64M between partitions, with all the partitions that’s almost 1GB of unused wasted space. Using parted to partition the disk had the same results. Using gparted, the graphical interface to parted seemed to get around that issue but still left 1MB of space between partitions. That I can live with.

OK done re-partitioning. Found out that in order you expand a Windows file system you can’t make the partition bigger then put the existing file system on it and expand it to use the new space, nope, you have to keep the partition the same size and leave un-partitioned space after it.

OK. Got all the partitions enlarged and the filesystem rolled back onto them. Linux still won’t boot and now Windows which did boot won’t boot. Ah geeze… Let’s tackle Linux first.

Took a while. Most of Thursday and part of Friday morning. Found the problem. For a while there Linux changed how they referenced the disk drive partitions on boot and for mounting. They got away from the simple /dev/sda1, /dev/sda2, /dev/sda3, etc for each partition and went to a new format that used a unique identifier. Which I always thought was stupid and is what turned out to bite me in the ass here…

The disk device partition names the Linux world went to, and I don’t know if they’re still doing it as this install is old, looks like this:

/dev/disk/by-id/ata-WDC_WD6400BPVT-80HXZT1_WD-WX21A61X1609-part1

Which has the disk model number in the name so with the new disk the name is:

/dev/disk/by-id/ata-WDC_WD10SPZX-80Z10T1_WD-WX61A590ZX7K-part1

Thus Linux could not find any of it’s partitions because the names changed!

That’s why I thought it was stupid from the get go. And it is. You replace a disk and you’re screwed. And to top it off those long names are just symbolic links i.e. pointers to /dev/sda1!! So I changed all the references from those stupid names to the real block device names i.e. /dev/sda1 and guess what? Linux now boots and works just fine…

Now back to Windows. Windows itself, the Recovery Boot off the hard disk, the Recovery Boot off a DVD, none of them would find the Windows OS installed on partition 2, where it’s always been. Knew for some reason it just wasn’t finding it but it did early Thursday before I enlarged the partitions. How could enlarging the partitions cause this? Perseverance and being tenacious I was not about to give up…

One thing started to stick in my mind. Was it something to do with the partitions. That Windows OS partition was exactly the same size it had been, in exactly the same spot on the disk… What could it be? So I decided to take another look at the disk partitioning. SOB. The Windows OS partition type was set to 82, not 7, Linux not HPFS/NTFS/exFAT. That’ll do it.

With all my re-partitioning trying to align the partitions on boundaries I redid that partition and it took the default Linux type. Changed it to what Windows expects and Windows booted fine once again. No Surprise there.

After a week… All done. Till next time…