I'm one of the people coffeecat contacted.
Before you attempt anything, be sure to read this whole message, including my caveats at the end.
Anyhow, repair of the partition table
is possible, but the end result will be a bit weird. Your goal state is to have an extended partition at the
start of the disk with your two Linux partitions (currently /dev/sdb1 and /dev/sdb6) within it as logical partitions. There will also be a gap within the extended partition between the two Linux partitions. You'll then have room for three primary partitions, each of which will be one of your NTFS partitions (currently /dev/sdb3, /dev/sdb4, and /dev/sdb5). It's weird, but legal, to have an extended partition at the start of the disk. That's the only way I can see that these partitions could have been created, though.
You can do this with sfdisk, using a procedure similar to the one described
on this Web page of mine; however, you'll need to do a lot of juggling to get it right. You must also have a good conceptual understanding of the difference between primary, extended, and logical partitions. (Googling on "primary extended logical partition" turned up
this page, which seems to do a decent job of explaining the concepts, although I've only skimmed it and so can't vouch for it being 100% accurate.) If you attempt this approach, I recommend you first cut-and-paste the fdisk output you've posted, remove /dev/sdb2 (since it's useless as-is), and rearrange the partitions in order of their start sectors. This will show you how things should be grouped. Then get the sfdisk output, as described on my Web page, and re-order and re-number the partitions to match the re-ordered fdisk output. (You'll have to renumber at least /dev/sda1 and /dev/sda5; in fact, swapping those two numbers is one simple way to go. This would result in partition numbers that don't match the storage-space positions, which is legal but potentially a bit confusing. Whatever you do, remember that primary and extended partitions are numbered 1 to 4, while logical partitions are numbered 5 and up.) Once you've re-ordered the sfdisk output, tackle the extended partition: You'll need to give it a start sector that's at least one sector earlier than the first partition (in other words, 2047 or earlier) and a length to precisely cover all the logical partitions (234373121 if you use a start sector of 2047 and if I've done the arithmetic correctly -- please double- and triple-check that detail!). Once this is done, feed the result back into sfdisk, as described on my Web page, and hope for the best!
A somewhat simpler way to do this would be to use my
GPT fdisk (gdisk) program, which is intended to edit GUID Partition Table (GPT) disks rather than the Master Boot Record (MBR) disks that yours is. GPT fdisk can convert back and forth, though, and GPT lacks the concept of a logical partition, so it should be able to load the MBR data (converting automatically to GPT format) and then save it out as MBR, which will cause gdisk to automatically create a legal extended partition. The procedure would be:
- Download and install GPT fdisk from its Sourceforge download page. Do not use the version in the Ubuntu repositories; it's hopelessly out of date and will not work for this procedure. Alternatively, you can use the latest version (2.0.0) of System Rescue CD, which has a recent enough version of GPT fdisk to work.
- Type "sudo gdisk /dev/sdb" to launch it on your disk.
- Type "p" to display your partition table and verify that it's correct. If it's not, type "q" to exit without saving your changes.
- Type "r" to get into the recovery & transformation menu.
- Type "g" to transform from the in-memory GPT version of your partitions back to MBR form. You'll see a summary of what the program intends to do. It will probably have all the primary/logical assignments right (it won't mention the extended partition), but if not, you can change them here. You will need to change the type code of your Linux data partition (currently /dev/sdb1; it'll still be identified as such at this point) to "83". (In GPT form, Linux and Windows use one partition type code, so the distinction between MBR's 0x07 and 0x83 is lost, and you must re-create it manually.) See the "Converting from GPT to MBR" section of this page for details of how to use the GPT-to-MBR conversion feature of gdisk.
- When you're satisfied, type "0" to save your changes. You'll have to type "y" to verify this.
If you've got GRUB installed in the MBR of your disk, you may have to re-install it with either procedure, and especially with the gdisk method. Since this is /dev/sdb, though, this may be necessary; GRUB might be installed on /dev/sda.
Now, the caveats I mentioned: Either of these procedures will repair the
partition table damage. Your problem as a whole seems to involve much more than this. You've probably got damage to at least one NTFS filesystem, there may be Windows boot loader issues, and you seem to have one missing partition that this procedure will not recover. It's conceivable that juggling partitions around in this way will make Windows even more unhappy and unwilling to boot. Nonetheless, IMHO fixing the corrupt partition table must be your first priority; if you don't do that, you run the risk of causing more damage when you attempt to fix the NTFS or Windows boot problems.
If possible, I recommend you back up your important data before doing anything else. If necessary, go out and buy an external hard disk for this purpose. It's conceivable that attempting to repair the corrupt partition table will make matters worse, so having a backup is very very prudent.
As to your lost partition(s), your best bet at recovery is
TestDisk, which can scan a disk for filesystem "signatures" and create new partitions to match any that it finds. I recommend you run TestDisk
after repairing the damage in the way I've identified; however, I also recommend that you back up your partition table by typing "sudo sfdisk -d > sdb-parts.txt" and saving the resulting sdb-parts.txt file on a USB flash drive or some other medium other than /dev/sdb before you run TestDisk. That way, if TestDisk makes things worse (as it sometimes does), you'll be able to use sfdisk to restore your partition table as it will be prior to running TestDisk, even if there's a missing partition.
Good luck!
Bookmarks