LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-03-2015, 11:02 AM   #1
weebo
LQ Newbie
 
Registered: Feb 2006
Location: Staffordshire Moorlands UK
Distribution: Kubuntu and Ubuntu
Posts: 26

Rep: Reputation: 0
Wink Help to Repair Partition Table Overlaps


Hi Folks,

It's been a long time since I posted here and I guess that's a fine testament to just how incredibly stable my Linux desktop 'workhorse' has been

Sadly all that ended a couple of weeks ago when we experienced an unusually violent lightning storm (well at least by UK standards!) and the motherboard was zapped. The system was a dual boot Kubuntu 10.04 with winXP. When I rebuilt the machine with a new motherboard and after checking my disk still worked + had all its data by connecting it as a slave on another system I discovered that only XP would boot.

So, here's the steps so far:

Run bootable live CD and accept its invitation to repair boot. Stupidly I do not know what CD this was and cannot now find it - don't shout, such is my life !!!

Discover that Kubuntu will now boot but XP will not. Not overly concerned as don't need XP right at that time...

Am not worried until a couple of days later Kubuntu fails to boot and says there's something wrong with the disk - hit a key to repair - which I do. Kubuntu boots but I am now concerned.

I run gparted which is not happy, showing the entire disk as unallocated and when run in a terminal:
parted /dev/sda print
Error: Cannot have overlapping partitions.

I have run fdisk -l, here's the output:

omitting empty partition (5)

Disk /dev/sda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc8afc8af

Device Boot Start End Blocks Id System
/dev/sda1 * 1 6092 48933958+ 7 HPFS/NTFS
/dev/sda2 6093 24320 146416410 f W95 Ext'd (LBA)
/dev/sda3 24194 24320 1020096 e W95 FAT16 (LBA)
/dev/sda5 6093 23630 140873922 83 Linux
/dev/sda6 23631 24193 4522266 82 Linux swap / Solaris


I'm far from expert here but I can see that the partition table is not right but I lack the confidence to go further and need you folk to guide me through the next steps. I would like to recover some order to the Linux partitions and of course restore the XP to full functionality even though I only have one CAD program on there I will desperately need to use it soon...


Thanks all,

Steve.

Last edited by weebo; 08-03-2015 at 12:01 PM. Reason: title clarity
 
Old 08-03-2015, 12:34 PM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,534

Rep: Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495
If you are still using Kubuntu 10.4, support for it ended two years ago. You might try to upgrade or install something newer.
Have you tried just running: sudo update-grub to see if xp is added?
 
Old 08-03-2015, 12:46 PM   #3
weebo
LQ Newbie
 
Registered: Feb 2006
Location: Staffordshire Moorlands UK
Distribution: Kubuntu and Ubuntu
Posts: 26

Original Poster
Rep: Reputation: 0
Yes, XP is on grub's list - grub goes to XP and I see a splash screen briefly but it fails to boot. Please correct me if I am wrong but the partition table looks to have some illegal overlaps in it and I am almost certain that this is the problem.

I realise that 10.04 is old but it was extremely stable and did not bloat out my modest system. Presumably if I went for a re-install or upgrade, due to the broken partition table the re-install process would not recognise the existing XP installation or for that matter my 10.04. Due to the difficulty installing XP and running updates these days I would like to avoid doing that if I can.

I would simply like to get back to where I was by repairing the partition table if that is possible.

Steve.

Last edited by weebo; 08-03-2015 at 01:13 PM. Reason: typo
 
Old 08-03-2015, 01:57 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,781

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
It looks to me like the only problem is an incorrect ending location for the extended partition (partition 2). Please post the output from "fdisk -l -u /dev/sda". That will show sector units. Showing cylinder units is too imprecise. Also post the output from "sfdisk -d /dev/sda" and "file -s /dev/sda?"

Please wrap all that output in [CODE] ... [/CODE] tags to preserve formatting. Let's see what this looks like.
 
Old 08-03-2015, 02:36 PM   #5
weebo
LQ Newbie
 
Registered: Feb 2006
Location: Staffordshire Moorlands UK
Distribution: Kubuntu and Ubuntu
Posts: 26

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rknichols View Post
It looks to me like the only problem is an incorrect ending location for the extended partition (partition 2). Please post the output from "fdisk -l -u /dev/sda". That will show sector units. Showing cylinder units is too imprecise. Also post the output from "sfdisk -d /dev/sda" and "file -s /dev/sda?"

Please wrap all that output in [CODE] ... [/CODE] tags to preserve formatting. Let's see what this looks like.
Thanks for this.

As you request:


output from fdisk -l -u /dev/sda

Code:
~$ sudo fdisk -l -u /dev/sda
omitting empty partition (5)

Disk /dev/sda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders, total 390721968 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc8afc8af

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63    97867979    48933958+   7  HPFS/NTFS
/dev/sda2        97867980   390700799   146416410    f  W95 Ext'd (LBA)
/dev/sda3       388660608   390700799     1020096    e  W95 FAT16 (LBA)
/dev/sda5        97868106   379615949   140873922   83  Linux
/dev/sda6       379616013   388660544     4522266   82  Linux swap / Solaris

output from sfdisk -d /dev/sda

Code:
sudo sfdisk -d /dev/sda
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=       63, size= 97867917, Id= 7, bootable
/dev/sda2 : start= 97867980, size=292832820, Id= f
/dev/sda3 : start=388660608, size=  2040192, Id= e
/dev/sda4 : start=        0, size=        0, Id= 0
/dev/sda5 : start= 97868106, size=281747844, Id=83
/dev/sda6 : start=379616013, size=  9044532, Id=82

output from file -s /dev/sda?

Code:
~$ sudo file -s /dev/sda?
/dev/sda1: x86 boot sector, code offset 0x52, OEM-ID "NTFS    ", sectors/cluster 8, reserved sectors 0, Media descriptor 0xf8, heads 255, hidden sectors 63, dos < 4.0 BootSector (0x80)
/dev/sda2: x86 boot sector; partition 1: ID=0x5, starthead 0, startsector 1, 281747969 sectors, extended partition table (last)\011, code offset 0x0
/dev/sda3: data
/dev/sda5: Linux rev 1.0 ext4 filesystem data, UUID=f0198110-c934-4649-888b-0d7a742365fa (needs journal recovery) (extents) (large files) (huge files)
/dev/sda6: Linux/i386 swap file (new style), version 1 (4K pages), size 1130565 pages, no label, UUID=57c42272-6444-4b77-b2cc-b781d99f0589
Looking forward to your thoughts

Cheers,
Steve.

Last edited by weebo; 08-03-2015 at 05:11 PM. Reason: remove noparse!!!
 
Old 08-03-2015, 03:18 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,781

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Somehow your code tags got taken literally. What did you do, include the "noparse" tags that I used to make them show up as text? Oh well, no great loss.

I think I see what happened. That 1GB FAT16 partition that is currently showing up as primary partition 3 should be logical partition 7 at the end of the extended partition. Recovery is going to be a bit more risky than I like to advise without a full backup of the disk image to another device. What I would do is use fdisk to simply delete partition 3. That should leave you with a consistent partition table, but with one lost partition. You can then see if testdisk can find and recover the missing partition.

Of course, if that 1GB partition was just a recovery partition that came with the machine, then you probably don't want it anyway.
 
Old 08-03-2015, 05:07 PM   #7
weebo
LQ Newbie
 
Registered: Feb 2006
Location: Staffordshire Moorlands UK
Distribution: Kubuntu and Ubuntu
Posts: 26

Original Poster
Rep: Reputation: 0
I guess in my naivety I did take you literally and copied the noparse tags you used but, as you see, I have rectified that.

I cannot imagine what is on the 1GB FAT16 partition, it may be a recovery partition from the original machine's setup I don't know - I was given the machine by a friend who no longer used it, I seem to remember reformatting the disk when I got the machine but it was a good few years ago!

I have a 1Tb external usb drive which I shall make an image of the disk on, that seems like a very good thing to do anyway. . Do you know of any particularly good imaging software to use? I have just been reading about Clonezilla...

As one relatively unfamiliar with fdisk would you be kind enough to take me through the steps necessary to delete the 1GB FAT16 partition?

Thanks for your help here - much appreciated!
Steve.

Last edited by weebo; 08-03-2015 at 05:14 PM.
 
Old 08-03-2015, 05:38 PM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,781

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
I would not recommend clonezilla or any "smart" imaging tool to copy a drive with known structure errors. I would just make a partition at least 200GB in size and use dd to copy the source drive to it, byte-for-byte. Assuming your new partition is /dev/sdb1, that would be
Code:
dd if=/dev/sda of=/dev/sdb1 bs=1M
That should be done while booted from a rescue disk so that no partitions on the source drive are mounted. Be absolutely sure you get the source ("if=") and destination ("of=") parameters correct, since dd will be quite happy to copy the empty new drive back to the original. The "bs=1M" parameter is fairly arbitrary. You just want a blocksize a good deal larger than the default 512 bytes for efficiency.

BTW, that command is going to take a few hours to complete, quite a few if that new drive is on a USB 2.0 interface.

Using fdisk to delete partition 3 is straightforward. You just need the "d" command, then the partition number, then "w" to write out the result and exit. I've put the part you type in red.
Code:
# fdisk /dev/sda
.
.
.
Command (m for help): d
Partition number (1-4): 3

Command (m for help): w
Again, be sure you're working on the right disk, though a mistake there is fairly easy to recover from.

Last edited by rknichols; 08-03-2015 at 05:42 PM.
 
Old 08-03-2015, 06:15 PM   #9
weebo
LQ Newbie
 
Registered: Feb 2006
Location: Staffordshire Moorlands UK
Distribution: Kubuntu and Ubuntu
Posts: 26

Original Poster
Rep: Reputation: 0
Thanks for this, it'll likely take me a day or two to make the time to do this properly so, if you will bear with me I'll post back as soon as possible with some results.

Cheers for now,
Steve.
 
Old 08-03-2015, 07:41 PM   #10
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,996

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
I've used Ranish before to fix overlaps.

There is no real good way to be sure your data is correct at this point. It is has not been a common issue for a very long time to have overlapping partitions. Assume your data is damaged and consider clean installs.
 
Old 08-03-2015, 07:56 PM   #11
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,781

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
There are not actually any overlapping partitions. There is a primary partition that is using space that is within the container that is the extended partition, but there is no overlap of any actual data partitions.
 
Old 08-03-2015, 08:25 PM   #12
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,138

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
Ubuntu default partitioning back then would have been to have the swap as a logical by itself - and thus the root partition as a primary.
Also, I would not be surprised to see an old XP machine with the XP partition at the beginning of the disk (/dev/sda1), and a tools/recovery partition at the end of the disk (/dev/sda2). That might be a logical or not depending on the vendors setup - I've seen both.

If it were me, I'd delete the extended partition altogether just to get things going. If the swap caused a failure on boot (say "resume=..."), I'd delete that too, and fix up the boot parms and fstab. All after a decent backup of course.
The swap can be added back anytime, but this may be more fiddly than the OP is comfortable with.
 
Old 08-03-2015, 08:51 PM   #13
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,781

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by syg00 View Post
If it were me, I'd delete the extended partition altogether just to get things going. If the swap caused a failure on boot (say "resume=..."), I'd delete that too, and fix up the boot parms and fstab.
Note that Linux is on logical partition sda5 within the extended partition, so you'd be deleting that, too. Loss of the swap partition would be immaterial.

A recovery partition, if that's what was on what is now sda3, is not likely to be useful. It would probably restore Windows XP to a state so out of date that Windows Update would not work to bring the installation up to the final, EOL version. I ran into that on the only two occasions when I tried it. There's a list of a half dozen or so of updates you have to download and install manually to get Windows Update to work again. And, of course, you'll have to deal with all the bloatware that originally came on the machine. You'd have to be pretty desperate for a fresh XP install to go that route.
 
Old 08-03-2015, 09:05 PM   #14
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,138

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
Quote:
Originally Posted by rknichols View Post
Note that Linux is on logical partition sda5 within the extended partition, so you'd be deleting that, too.
No, that's the fun part.
Because of the initial install as a primary, it has an entry in the partition table, so will be found ok. fdisk shows it as a logical because of the existence of that extended. Bad assumption on the (fdisk and parted too I think) coders part.
It all works ok for this particular arrangement - if my assumption was right. I have done it, and it has worked.
After a backup.
 
Old 08-03-2015, 10:06 PM   #15
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,996

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
"I run gparted which is not happy, showing the entire disk as unallocated and when run in a terminal:
parted /dev/sda print
Error: Cannot have overlapping partitions."

I've had issues before like this. Yes, it may be possible to correct the barriers but you don't know what data may have had some reference to those spots.


It is possible that a very old program made the issue and has been like this for years.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] repairing a corrupted mysql table on a shared hosting server frieza Linux - Server 2 02-22-2011 12:23 PM
Need help repairing partition table with raid0 LVM configuration. Oakems Linux - Hardware 3 12-12-2009 01:46 PM
"No partition table or unknown signature on partition table" 10.1 install madcow007 Slackware 4 02-09-2009 11:04 AM
Slack 10: S-ATA = "No partition table or unknown signature on partition table"? dissolved soul Slackware - Installation 11 08-05-2004 02:12 PM
Repairing a broken partition Sonderblade Linux - Hardware 3 05-30-2004 11:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration