2

My Ubuntu installed on PC is stucked at boot screen. So, I tried to install anew, but partition table is shown empty at installation wizard. I learned that my partitions overlapped.

I found this link to fix problem http://gparted.org/h2-fix-msdos-pt.php. But it doesn't seem to make sense for my fdisk output.

$ sudo fdisk -l -u /dev/sda
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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: 0x49fec944

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *      616448   257441624   128412588+   7  HPFS/NTFS/exFAT
/dev/sda2       452753408   484210687    15728640    7  HPFS/NTFS/exFAT
/dev/sda3       484210688   488394751     2092032    c  W95 FAT32 (LBA)
/dev/sda4       257433598   452753407    97659905    5  Extended
/dev/sda5       257433600   452753407    97659904   83  Linux
Partition table entries are not in disk order

Could you help me?

3
  • 1
    First things first: 11.04 has been unsupported for a year and a half; you need to stop using it at once.
    – psusi
    Mar 21, 2014 at 14:18
  • @psusi even for upgrading the partition table needs to be fixed first..
    – rusty
    Mar 22, 2014 at 4:18
  • user260538 please edit your question to include the output of sudo sfdisk -d /dev/sda
    – rusty
    Mar 22, 2014 at 4:22

5 Answers 5

2

Fixing the partition table with sfdisk:

  1. Boot with live Ubuntu disk;

  2. Confirm the problem on your disk device, here /dev/sda with parted e.g.

    sudo parted /dev/sda unit s print
    

    which should show:

    Error: Can't have overlapping partitions.
    
  3. Partition details can be checked with:

    sudo fdisk -l -u /dev/sda
    

    which, for you, according to your post is:

    Disk /dev/sda: 250.1 GB, 250059350016 bytes
    255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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: 0x49fec944
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *      616448   257441624   128412588+   7  HPFS/NTFS/exFAT
    /dev/sda2       452753408   484210687    15728640    7  HPFS/NTFS/exFAT
    /dev/sda3       484210688   488394751     2092032    c  W95 FAT32 (LBA)
    /dev/sda4       257433598   452753407    97659905    5  Extended
    /dev/sda5       257433600   452753407    97659904   83  Linux
    
  4. Checking the overlaps: You can see that your end of primary partition /dev/sda1 overlaps the beginning of extended partition /dev/sda4.

    sda1end = 257441624

    sda4start = 257433598

  5. As suggested in the documentation that - "In cases where we do not know if the starting or ending sector is the problem, we assume that the starting sector of each partition is correct, and that the ending sector might be in error", we assume that the starting sector of extended partition sda4 is correct. Hence we will be looking to change the end sector of primary partition sda1.

    Calculations:

    sda1newEnd = sda4start - 1 = 257433598 - 1 = 257433597

    sda1newSize = sda1newEnd - sda1start + 1 = 257433597 - 616448 + 1 = 256817150

  6. Dumping a copy of the partition table in an file using the sfdisk command:

    sudo sfdisk -d /dev/sda should dump the partition table details. This can be dumped to a file, which after necessary corrections are made, can be fed back to sfdisk. [To OP: Please edit your Question and include the output of sudo sfdisk -d /dev/sda]

    Dump a copy of partition table with:

    sudo sfdisk -d /dev/sda > sda-backup.txt
    

    which for you would look something like this:

    # partition table of /dev/sda
    unit: sectors
    
    /dev/sda1 : start=   616448, size=256825177, Id= 7, bootable
    /dev/sda2 : start=452753408, size= 31457279, Id= 7
    /dev/sda3 : start=484210688, size=  4184064, Id= c
    /dev/sda4 : start=257433598, size=195319810, Id= 5
    /dev/sda5 : start=257433600, size=195319808, Id=83
    
  7. Open the file with root privilege, created in the previous step, using text editor of your choice. In the example I'll use nano.

    sudo nano sda-backup.txt
    

    (sda-backup.txt assuming the file is in the current directory, else repalce it with the file's absolute path.)

    Change the old size of sda1 (256825177) to the corrected size (256817150) so that your new partition table dump would look something like:

    # partition table of /dev/sda
    unit: sectors
    
    /dev/sda1 : start=   616448, size=256817150, Id= 7, bootable
    /dev/sda2 : start=452753408, size= 31457279, Id= 7
    /dev/sda3 : start=484210688, size=  4184064, Id= c
    /dev/sda4 : start=257433598, size=195319810, Id= 5
    /dev/sda5 : start=257433600, size=195319808, Id=83
    

    Save the file (Ctrl+O for nano) and close the editor (Ctrl+X for nano).

  8. Feeding back the corrected partition details to the partition table using the sfdisk command:

    sudo sfdisk /dev/sda < sda-backup.txt
    
  9. Confirm if the problem is resolved by running parted on your disk device:

    sudo parted /dev/sda unit s print
    
  10. If step 9 confirm that the partition table is fixed, you can then use GParted or other partition editors with the device.


The GParted documentition also suggests an alternative method, using testdisk to scan the disk device to rebuild the partition table. The testdisk application is included on GParted Live. So if you are not comfortable with the command-line way, you can try the alternative.

source

3
  • thanks for detailed reply, advice of @psusi seems as easy to me. So, i followed it. Now, my problem is solved. and i also have brand new ubuntu 13.10 :)
    – user260538
    Mar 22, 2014 at 14:18
  • good to know that it's fixed..
    – rusty
    Mar 22, 2014 at 14:25
  • Just changing the partition table may leave you with a broken filesystem if it believes it is actually using the full size ( which it normally would be ).
    – psusi
    Mar 23, 2014 at 0:27
0

Download a currently supported release ( 12.04 or 13.10 ), boot it up, and backup any data you want to save from your current install. Then use fdisk to delete partitions 5 and 4, and then reinstall.

2
  • This will work, but the "backup" that you describe is extremely critical, because the procedure will effectively destroy Ubuntu user data and settings. After re-installing, it will be necessary to restore such data. I just want to highlight this point so that user260538 doesn't miss this vital detail.
    – Rod Smith
    Mar 22, 2014 at 13:18
  • @RodSmith you're right but i backed up my home directory and it's enough to me. Thanks for attention.
    – user260538
    Mar 22, 2014 at 14:21
0

Rusty's suggestion should work, but it's a bit intimidating. The same thing can be done with fdisk a bit more simply:

  1. Launch fdisk on the disk by typing sudo fdisk /dev/sda.
  2. Verify that you're working on the right disk by typing p to see the partition table and verify that it shows the same partitions you've posted.
  3. Type d and, when prompted for a partition number, type 1.
  4. Type n to create a new partition. When prompted, enter p for the partition type, 1 for the partition number (actually, I think that fdisk won't prompt for this detail), 616448 for the first sector, and 257433597 (the start point of the extended partition minus 1) for the last sector. (That last-sector value may be the default, in which case you can just hit Enter.)
  5. Type p to verify that the partitions are correct. They should look just like what you've got now, except that the end point of /dev/sda1 should be one sector before the start of /dev/sda4.
  6. Type w to save your changes and exit.

Whether you follow my procedure or rusty's, be aware that there's a chance that the filesystem within /dev/sda1 thinks that it can use beyond sector 257,433,597. If so, repairing the disk in this way could cause problems on that partition. There's really no way around this problem, and avoding it by not repairing your current problem runs the risk of damaging your partition table in a way that will cause /dev/sda5 to disappear or its contents to be damaged, so fixing the problem is definitely in order. To mitigate the risk of damage to /dev/sda1, though, I recommend you run CHKDSK in Windows (or use its GUI front-ends) to verify that integrity of /dev/sda1. I'm not positive, but I'd expect that CHKDSK would detect a too-small container partition. You might need to do a filesystem resize to fix the problem if the partition is too small for the filesystem -- but do this after resizing the partition to minimize the risk of damaging /dev/sda5. All this is largely precautionary, though; there's a good chance that the filesystem in /dev/sda1 isn't sized to the very end of /dev/sda1, in which case resizing the partition in the way that I and rusty suggest won't cause problems. (We're both telling you to do the same thing; we just differ in the tools used to do the job.)

0

When resizing/moving in GParted there is an additional option "Align to:" it lists 3 options:

  • MiB
  • Cylinder / choose this one and try again -it worked for me
  • None

I found it here when I had the same problem. http://ubuntuforums.org/showthread.php?t=1980664&p=12319906#post12319906

0

If you've access to any windows machine, simply open partition manager formate it to NTFS. Than in Linux formate it again (I used Disks in Mint) to your desired partition formate (EXT4 in my case).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .