Fix EXT4-fs bad geometry (block count exceeds size of device)

Same problem after truncating a SD card image where the SD had a few blocks less than the original. Repartitioned the drive with fdisk (see above), but message "Size in superblock is different from the physical size of the partition" remained. Found the solution here: http://www.linuxquestions.org/questions/linux-hardware-18/size-in-superblock-is-different-from-the-physical-size-of-the-partition-298175/

So, on the unmounted partition: e2fsck -f /dev/XXX resize2fs /dev/XXX


The filesystem doesn't care about disk geometry; this is a partition table problem.

I suggest that you make a dump of the partition table, check the result and overwrite the partition table with this dump. That should correct the CHS entries.

sfdisk -d /dev/sdx >sdx.txt
cat sdx.txt
sfdisk /dev/sdx <sdx.txt

I pretty much had the same issue, trying to mount gave:

$sudo mount /dev/sda2 ./oldfs/ 
mount: wrong fs type, bad option, bad superblock on /dev/sda2,
   missing codepage or helper program, or other error
   In some cases useful info is found in syslog - try
   dmesg | tail  or so

I tried the above mentioned re-writing of the part-table, without success.

So, finally I was able to solve the issue by re-partitioning my drive via fdisk. I deleted my 2nd partition and re-created it again.

$fdisk /dev/sda

Command (m for help): p

Disk /dev/sda: 31.4 GB, 31440502784 bytes
64 heads, 32 sectors/track, 29984 cylinders, total 61407232 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: 0x000ecdca

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    20447231    10222592   83  Linux
/dev/sda2        20447232    61406208    20479488+  83  Linux

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2): 
Using default value 2
First sector (20447232-61407231, default 20447232): 
Using default value 20447232
Last sector, +sectors or +size{K,M,G} (20447232-61407231, default 61407231): 
Using default value 61407231

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.