# [SOLVED] gparted: Can't have a partition outside the disk!

## msalerno

Anyone know who how I can fix a messed up partition table?  I had some issues a month or so ago, see The Official Dumb Mistakes Thread (TM) part deux.  In short it had to do with me doing a 

```
cat /dev/urandom >> /dev/sda
```

 (Don't ask!).   Anyway, I recovered my partition table by using testdisk, but there seems to be a problem now.  When I try to resize my partitions with gparted (I want to shrink sda1) I receive the error "Can't have a partition outside the disk!".  When I view the partition info via testdisk, all partitions are within bounds, but  unfortunately fdisk does not see it that way!

I'm pretty sure I need to backup my data and recreate the partition tables, but I would like to avoid that.  I have already backed up my MBR (dd if=/dev/sda of=/media/disk/da-mbr.bin bs=512 count=1), so I figure I can screw around with the partition tables with little risk.  I was looking at this thread for inspiration.  Does anyone around here have any similar experience?

Thanks

The disk reports: total 156250000 sectors

However, sda4 ends at 156264254

```
Disk /dev/sda: 80.0 GB, 80000000000 bytes

255 heads, 63 sectors/track, 9726 cylinders, total 156250000 sectors

Units = sectors of 1 * 512 = 512 bytes

Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *          77    94815629    47407776+   7  HPFS/NTFS

/dev/sda2        94815630    95024474      104422+  83  Linux

/dev/sda3        95024475   102848129     3911827+  83  Linux

/dev/sda4       102848130   156264254    26708062+   5  Extended

/dev/sda5       102848193   104824124      987966   82  Linux swap / Solaris

/dev/sda6       104824188   156248189    25712001   8e  Linux LVM
```

Mod edit: Corrected first link to target the referenced post. --timeBanditLast edited by msalerno on Wed Dec 16, 2009 9:49 pm; edited 1 time in total

----------

## turudd

At what point in the resize effort does gparted spit that error?

Once it has started or when you try to save the new partition table?

Have you tried to use other options, such as doing it without using gparted, by using the core tools (IE: http://www.howtoforge.com/linux_resizing_ext3_partitions)

----------

## msalerno

The main issue is that I would need to first resize the lvm partition followed by the extended partition.   So resizing ext3 is of no help.  Gparted gives the error as soon as I start it.  Once it's started, it shows no partitions on the drive.

----------

## msalerno

```
echo "102848130,53401870,5" | sfdisk -f -uS /dev/sda -N4 -O /media/disk/sda_sectors_modified.save
```

Ok, so here is what I did, I have not rebooted yet, but i'm posting this anyway (mainly so that I have the command saved!)

Basically, (total 156250000 sectors) - the start of sda4 (102848130) = 53401870

At least gparted now shows me the partitions!

I'll hopefully be posting solved as soon as I reboot.

WORKS!!!!!!!

----------

