0

This odd but funny problem is rather urgent, so until I get an answer this is cross-posted here and here.

I have an extended partition containing three Linux systems, each in its own partition. Each of these systems display this in gparted:

enter image description here

Partition overlapping:

enter image description here

Gnome-disks sees this:

enter image description here

Initially, I thoughht this cannot be accurate, as I knew for sure that Mint partition was occupying in fact what appears here as the free space in the extended partition, while Win7 takes what here is shown as the empty space from the right. But I got answer & comments suggesting otherwise.

I also can confirm that the free space that I consider to be in fact the space were the Win 7 partition was is now smaller (66GB) then before (above 100GB). It's as if the 42GB Mint partition was moved from the extended partition (which now has 42 GB free space) onto the Win partition which was in this way deleted and left a difference of 66GB free.

enter image description here

Here how the partition table was some time ago when eOS and Ubuntu place was taken by other OSes:

enter image description here

How I got into this:

I use mainly Linux and the grub list to boot. I have shrunk the big NTFS partition from the left (labelled Depo) so as to install there Windows XP 32bit. I did that and of course lost the grub. I have restored it from a live eOS USB. That restored the grub and put as the first in the list my initial Linux (Mint Xfce) installation, which here is seen outside-right of the extended partition, when in fact it occupies what is displayed above as the empty space within the extended partition.

Other symptoms:

  • Windows 7 partition is completely inaccessible; the only one absent in grub list and invisible in all systems
  • All partitions except Win7 are accessible in the operating systems (except in XP of course which cannot see ext4).

(I have to reboot to report on the rest)

How can I fix this if not with gparted?

I would prefer a GUI.


Update to answer comments and answers:

~$ cat /proc/partitions
major minor  #blocks  name

   8        0  488386584 sda
   8        1  185841664 sda1
   8        2   50996224 sda2
   8        3          1 sda3
   8        4   41389648 sda4
   8        5   51796875 sda5
   8        6   52628906 sda6
  11        0    1048575 sr0

The command sudo smartctl -a /dev/sda had this result: http://pastebin.com/MLEXi8TF

The command sudo dd if=/dev/sda bs=512 count=1 | xxd | cat had this result: http://pastebin.com/z10QbqqQ


UPDATE AFTER ANSWER:

42 GB Mint partition is overlapping the 100 GB partition which was thus deleted. To fix this, should I just delete the 42 GB Mint partition?


In latest gparted live usb I get two error messages but then I see this:

enter image description here

8
  • 1
    Instead of a graphical view it would be good with numbers. What does fdisk -l say? Commented Feb 19, 2015 at 21:00
  • @HenrikCarlqvist - odd, but that gives nothing: cipricus@cipricus-PC ~ $ fdisk -l cipricus@cipricus-PC ~ $
    – user162573
    Commented Feb 19, 2015 at 21:36
  • Well, the GUI is obviously inadequate, so use fdisk at the command line. If sudo fdisk -l /dev/sda doesn’t output anything, your best bet is to run around your room screaming. ;)
    – Daniel B
    Commented Feb 19, 2015 at 21:39
  • @DanielB - well, as the only real victim is Win7 and I have 4 systems working I'm cool about it for the moment :)
    – user162573
    Commented Feb 19, 2015 at 21:41
  • If fdisk -l refuses to work, but you still have working Linux systems, what does cat /proc/partitions say? Commented Feb 19, 2015 at 21:44

3 Answers 3

0

Thanks for the xxd output. By converting it back to a binary file with xxd -r and studying that file with sfdisk I see the following:

   Device Boot Start     End   #cyls    #blocks   Id  System
 xxd.bin1   *     25+  23161-  23137- 185841664    7  HPFS/NTFS
 xxd.bin2      23161+  29510-   6349-  50996224    7  HPFS/NTFS
 xxd.bin3      29510+  47663-  18154- 145817169+   5  Extended
 xxd.bin4      42511+  47663-   5153-  41389648+  83  Linux

So your primary partition 4 is really overlapping with your extended partition 3. They both end at the same position. From the partition table in the MBR it is not possible to get information about your logical partitions. That data is in the beginning of /dev/sda3 and probably a little harder to study.

My guess is that you somehow pointed and clicked in gparted and made the logical partition for Mint a primary partition. Do you know if the Mint partition used to be a logical partition with a number of 5 or higher?

Somehow gparted now seems to be too confused. If you are lucky parted will still be usable from the command line. What does parted -l say?

To remove primary partition 4, do the following:

1) Start with your text file created with xxd from the first 512 bytes of your disk.

2) Edit the end of that file from:

`00001e0: ffff 05fe ffff feff 411c a3fc 6111 00fe  ........A...a...`
`00001f0: ffff 83fe ffff 00e0 b428 a11c ef04 55aa  .........(....U.`

to:

`00001e0: ffff 05fe ffff feff 411c a3fc 6111 0000  .......$....hQ..`
`00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa  ..............U.`

3) Create a binary file from your text file, something like this: xxd -r xxd2.txt > xxd2.bin The created binary file should have the size 512 bytes.

4) Copy the binary file to the beginning of your disk: dd if=xxd2.bin of=/dev/sda

5) Now you should no longer have any 4th primary partition and no overlapping partitions. If you are lucky, you will now be able to recover your logical Mint partition and primary Windows partition using parted. If you are unlucky things will become a bigger mess than before. Make sure that you have a backup and know how to use the backup!

10
  • 1
    My guess is that your Windows 7 partition is still there, but as you only can have 4 primary partitions that fifth primary partition is now not usable. Too bad parted doesn't work. I could try to manually edit your partition table and remove the 4th partition. Before writing such a modified partition table back to disk you should however make a backup of the entire disk. Are you able to make a complete disk image backup of the entire disk? If something goes wrong and things get worse, do you know how to restore such a backup image? Commented Feb 19, 2015 at 22:48
  • 1
    If your Win7 partition has become smaller it is not only because of primary partition 4, your extended partition occupies the same space. My guess then is that your Win7 data is lost as the beginning of the partition is gone. Commented Feb 19, 2015 at 23:12
  • 1
    As your linux installations are still working you don't need to use a live CD, you can edit the partition tables from within the booted Linux. For changes to come into place you might have to reboot Linux. But I fear that your Win7 data is lost. Before you had 226 GB sda2, 140 GB sda3 and 101 GB sda4. That is a sum of 226+140=366 GB before sda4 which contains your Win7 data. After changing the partition table you got 190 GB sda1, 52 GB sda2 and still about 140 GB sda3. That sums to ~282 GB. It seems as if you not only taken space from old sda2, but also moved sda3 to the right into old sda4. Commented Feb 20, 2015 at 6:30
  • A live CD might be useful to create a backup image of the entire disk to some big USB disk. Once backed up you can afford to experiment in an attempt to rescue data. Commented Feb 20, 2015 at 7:11
  • 1
    The command sudo dd if=/dev/zero of=/dev/sda bs=1M wiped the entire disk, not only the partition table. To only wipe the partition table and Master Boot Record it would have been enough to do sudo dd if=/dev/zero of=/dev/sda bs=512 count=1. With the entire disk wiped there is no longer any hope to restore data with tools like TestDisk or PhotoRec. I hope that you will be able to restore your installation from installation media and/or backups. Commented Feb 21, 2015 at 6:15
0

From /proc/partitions we can see the following:

1) You have 4 primary partitions (1-4). A DOS partition table can have up to 4 primary partitions which in Linux is numbered 1-4. One of those primary partitions can be an extended partition containing more partitions. Your partition number 3 is an extended partition.

2) You have 2 logical partitions in your extended partition. Those are sda5 and sda6.

So it really seems as if Gnome-disks is right, you only have two partitions in your extended partition and the primary partition 4 does not belong to your extended partition.

Unfortunately /proc/partitions does not show the size of the extended partition. For that we would need the output of fdisk -l or at least fdisk -l /dev/sda so I can't tell for sure if any of your primary partition 4 is overlapping with unused space in extended partition 3.

As fdisk does not show any output something might be fishy with your partition table. Maybe cfdisk would be more useful.

4
  • 1
    If you need more info about your partition table, the output from dd if=/dev/sda bs=512 count=1 | xxd | cat - might be useful to study your partition table, but such a study will take me some time... Commented Feb 19, 2015 at 22:04
  • Is it possible that the linux mint partition that was inside the extended one has changed its status and position (and now is a primary partition) just by installing XP and reinstalling grub?
    – user162573
    Commented Feb 19, 2015 at 22:06
  • 1
    I don't think installing XP or reinstalling grub would rearrange your partitions like that. More likely parted or some graphical fronted for parted has caused this, maybe because of interrupted resize operation or because of hardware error. Commented Feb 19, 2015 at 22:12
  • I have used gparted just to shrink the Depo partition to install XP in the freed part.
    – user162573
    Commented Feb 19, 2015 at 22:14
0

Because Henrik Carlqvist's answer seemed to "advanced" for my skills, I tried to just remove the mint partition in a live Gparted usb session, which showed this image

enter image description here

But that was still inaccurate, because the 39.47 GB space of the mint partition appears both inside and outside the extended partition, but also outside of the 100 GB space of the ex-Win7 partition: the drive was shown as having 39.47 GB more than it really has. Anyway I carried on. Removing the Mint partition (which appeared as primary) in Gparted session seemed to work, but I also extended the eOS partition to the right into the 39.47 GB space of the initial logical partition of mint. That resulted in both being merged into one unallocated space: as if the empty space had been extended... The eOS partition was thus lost.

So, I decided to delete all partitions, cleaning all the drive.

I noticed that "Disks" (`gnome-disk-utility', available in sources, default in Unity) was not only able to see the correct situation of the partitions, but also to create (backup) and restore disk images. I saved and then restored one of my systems in this way (I didn't care about the rest).

It was clear that Gparted was not seeing things right, searched for a solution, asked a new question and went on as follows:

Booted in a live usb session and did

sudo dd if=/dev/urandom of=/dev/sda bs=1M

But that didn't seem o work as I wanted, as the light for the processor working was mostly off (or is it the hdd light?), while the cooler was very loud.

Then I read that the urandom command is very slow as it is really trying to produce really random numbers. I was not interested in wiping all the data for security, but just in clearing off all partitions (something was wrong with them), so I stopped the procedure and did:

sudo dd if=/dev/zero of=/dev/sda bs=1M

With this the cooler calmed down while that "working light" was there permanently.

And to see the progress of this, I opened a separate terminal window and did

watch -n5 'sudo kill -USR1 `pgrep ^dd`'

which every 5 secs reports the progress in the initial terminal window (source)

245423407104 bytes (245 GB) copied, 3430.82 s, 71.5 MB/s
234354+0 records in
234354+0 records out
245737979904 bytes (246 GB) copied, 3435.84 s, 71.5 MB/s
234655+0 records in
234655+0 records out
246053601280 bytes (246 GB) copied, 3440.88 s, 71.5 MB/s
234956+0 records in
234956+0 records out
246369222656 bytes (246 GB) copied, 3445.91 s, 71.5 MB/s

... it took 2 hours and thirty minutes for a 500GB HDD on a 4-year average laptop with 4GB ram.

I restored the image of one of my systems with Disk utility, which seems a great tool.

You must log in to answer this question.