bad geometry: block count exceeds size of device after partition table recovery with testdisk

How to use TestDisk to recover lost partition
Forum rules
When asking for technical support:
- Search for posts on the same topic before posting a new question.
- Give clear, specific information in the title of your post.
- Include as many details as you can, MOST POSTS WILL GET ONLY ONE OR TWO ANSWERS.
- Post a follow up with a "Thank you" or "This worked!"
- When you learn something, use that knowledge to HELP ANOTHER USER LATER.
Before posting, please read https://www.cgsecurity.org/testdisk.pdf
Post Reply
Message
Author
nobody
Posts: 2
Joined: 21 Jun 2026, 17:24

bad geometry: block count exceeds size of device after partition table recovery with testdisk

#1 Post by nobody »

Hello,

I have a failing Seagate ST5000DM000-1FK1 from a Samsung D3 Station that stopped mounting on a debian machine yesterday. After testing further on another laptop and not seeing anything show up with lsblk/lsusb, I removed the drive from the enclosure and connected it directly via SATA to another desktop. testdisk was able to recover the partition table and copy files from the drive as detailed below. I'm still having trouble getting the partition to mount after the table was fixed and grateful for any assistance,


On first boot the BIOS/UEFI hung for a long. If relevant the motherboard is an ASUS 'TUF GAMING X570-PRO (WI-FI)' with firmware version:

Code: Select all

# dmidecode -t bios -q
Platform Firmware Information
        Vendor: American Megatrends Inc.
        Version: 5044
        Release Date: 01/04/2026
After waiting 10-20 minutes the UEFI boot menu appeared and I was able to boot to the desktop's nvme boot drive and run testdisk on the arch install.

testdisk appeared to find the partition table so I wrote it to disk and rebooted (log below). On reboot, the machine no longer was hanging on boot and when I got back into arch I was able to successfully copy a few files off the drive using testdisk.

Code: Select all

Sat Jun 20 23:08:20 2026
Command line: TestDisk

TestDisk 7.2, Data Recovery Utility, February 2024
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org
OS: Linux, kernel 7.0.10-2-cachyos (#1 SMP PREEMPT_DYNAMIC Thu, 28 May 2026 21:12:58 +0000) x86_64
Compiler: GCC 14.2
ext2fs lib: 1.47.4, ntfs lib: libntfs-3g, reiserfs lib: none, ewf lib: none, curses lib: ncurses 6.5
/dev/sda: LBA, HPA, LBA48, DCO support
/dev/sda: size       9767541168 sectors
/dev/sda: user_max   9767541168 sectors
/dev/sda: native_max 9767541168 sectors
[removed other attached disks info]
Warning: can't get size for Disk /dev/mapper/control - 0 B - 0 sectors, sector size=512
Hard disk list
Disk /dev/sda - 5000 GB / 4657 GiB - CHS 608001 255 63, sector size=512 - ST5000DM000-1FK1, FW:CC48
[removed other attached disks info]
Disk /dev/nvme0n1 - 1000 GB / 931 GiB - CHS 953869 64 32, sector size=512 - Samsung SSD 980 PRO 1TB, S/N:S5P2NG0R223391D

Partition table type (auto): Intel
Disk /dev/sda - 5000 GB / 4657 GiB - ST5000DM000-1FK1
Partition table type: EFI GPT

Analyse Disk /dev/sda - 5000 GB / 4657 GiB - CHS 608001 255 63
Bad GPT partition, invalid signature.
Trying alternate GPT
Bad GPT partition, invalid signature.
Current partition structure:
Bad GPT partition, invalid signature.
Trying alternate GPT
Bad GPT partition, invalid signature.

search_part()
Disk /dev/sda - 5000 GB / 4657 GiB - CHS 608001 255 63
NTFS at 0/8/9
Warning: number of bytes per sector mismatches 4096 (NTFS) != 512 (HD)
filesystem size           1220940000
sectors_per_cluster       1
mft_lcn                   786432
mftmirr_lcn               2
clusters_per_mft_record   1
clusters_per_index_record 1
NTFS part_offset=262144, part_size=5000970240000, sector_size=512
NTFS partition cannot be added (part_offset<part_size).
NTFS at 0/8/9
Warning: number of bytes per sector mismatches 4096 (NTFS) != 512 (HD)
filesystem size           1220940000
sectors_per_cluster       1
mft_lcn                   786432
mftmirr_lcn               2
clusters_per_mft_record   1
clusters_per_index_record 1
     MS Data                      512 9767520511 9767520000
     NTFS, blocksize=4096, 5000 GB / 4657 GiB

Results
   P MS Data                      512 9767520511 9767520000
     NTFS, blocksize=4096, 5000 GB / 4657 GiB

Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 9767520000 linear /dev/sda 512" | dmsetup create test0
ntfs_mst_post_read_fixup_warn: magic: 0x0a6e0f7f  size: 4096   usa_ofs: 14882  usa_count: 2084: Invalid argument
Record 0 has no FILE magic (0xa6e0f7f)
Failed to load $MFT: Input/output error
ntfs_device_testdisk_io_ioctl() unimplemented

   P MS Data                      512 9767520511 9767520000
     NTFS, blocksize=4096, 5000 GB / 4657 GiB
Can't open filesystem. Filesystem seems damaged.

interface_write()
 1 P MS Data                      512 9767520511 9767520000

interface_write()
 1 P MS Data                      512 9767520511 9767520000
simulate write!

Analyse Disk /dev/sda - 5000 GB / 4657 GiB - CHS 608001 255 63
Bad GPT partition, invalid signature.
Trying alternate GPT
Bad GPT partition, invalid signature.
Current partition structure:
Bad GPT partition, invalid signature.
Trying alternate GPT
Bad GPT partition, invalid signature.

search_part()
Disk /dev/sda - 5000 GB / 4657 GiB - CHS 608001 255 63
NTFS at 0/8/9
Warning: number of bytes per sector mismatches 4096 (NTFS) != 512 (HD)
filesystem size           1220940000
sectors_per_cluster       1
mft_lcn                   786432
mftmirr_lcn               2
clusters_per_mft_record   1
clusters_per_index_record 1
NTFS part_offset=262144, part_size=5000970240000, sector_size=512
NTFS partition cannot be added (part_offset<part_size).
NTFS at 0/8/9
Warning: number of bytes per sector mismatches 4096 (NTFS) != 512 (HD)
filesystem size           1220940000
sectors_per_cluster       1
mft_lcn                   786432
mftmirr_lcn               2
clusters_per_mft_record   1
clusters_per_index_record 1
     MS Data                      512 9767520511 9767520000
     NTFS, blocksize=4096, 5000 GB / 4657 GiB

Results
   P MS Data                      512 9767520511 9767520000
     NTFS, blocksize=4096, 5000 GB / 4657 GiB

Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 9767520000 linear /dev/sda 512" | dmsetup create test0

interface_write()
 1 P MS Data                      512 9767520511 9767520000
simulate write!
Partition table type (auto): Intel
Disk /dev/sda - 5000 GB / 4657 GiB - ST5000DM000-1FK1
Partition table type: Intel

Analyse Disk /dev/sda - 5000 GB / 4657 GiB - CHS 608001 255 63
Geometry from i386 MBR: head=255 sector=63
check_part_i386 failed for partition type 83
Current partition structure:
No ext2, JFS, Reiser, cramfs or XFS marker
 1 * Linux                    0  32 33 267349 121 35 4294967295
 1 * Linux                    0  32 33 267349 121 35 4294967295

search_part()
Disk /dev/sda - 5000 GB / 4657 GiB - CHS 608001 255 63

recover_EXT2: s_block_group_nr=0/37260, s_mnt_count=4/4294967295, s_blocks_per_group=32768, s_inodes_per_group=4096
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 1220942336
recover_EXT2: part_size 9767538688
Filesystem created: Tue Jan  1 17:21:16 2019
Last mount time:    Mon Jun  1 16:17:49 2026
     Linux                    0  32 33 608001  74  9 9767538688 [External]
     ext4 blocksize=4096 Large_file Sparse_SB Recover, 5000 GB / 4657 GiB

Results
   * Linux                    0  32 33 608001  74  9 9767538688 [External]
     ext4 blocksize=4096 Large_file Sparse_SB Recover, 5000 GB / 4657 GiB

Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 9767538688 linear /dev/sda 2048" | dmsetup create test0

interface_write()
 1 * Linux                    0  32 33 608001  74  9 9767538688 [External]

[removed logs of directories viewed]

interface_write()
 1 * Linux                    0  32 33 608001  74  9 9767538688 [External]
write!

write_mbr_i386: starting...
write_all_log_i386: starting...
No extended partition
You will have to reboot for the change to take effect.

TestDisk exited normally.
At this point I was unable to get the drive to mount. After the mount attempt journalctl shows:

Code: Select all

EXT4-fs (sda1): bad geometry: block count 1220942336 exceeds size of device (536870911 blocks)
I also noticed these errors searching for sda in journalctl -b 0 logs.

Code: Select all

Jun 20 23:46:20 cachy-desktop kernel: ata4: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Jun 20 23:46:20 cachy-desktop kernel: ata4.00: NCQ Non-Data Log not supported
Jun 20 23:46:20 cachy-desktop udisksd[3279]: Error performing housekeeping for drive /org/freedesktop/UDisks2/drives/ST5000DM000_1FK178_W4J0KT2V: Error updating SMART data: Error reading SMART data from device: Input/output error (udisks-error-quark, 0)
Jun 20 23:46:20 cachy-desktop kernel: ata4.00: NCQ Non-Data Log not supported
Jun 20 23:46:20 cachy-desktop kernel: ata4.00: configured for UDMA/133
Jun 20 23:56:20 cachy-desktop kernel: ata4: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Jun 20 23:56:20 cachy-desktop kernel: ata4.00: NCQ Non-Data Log not supported
Jun 20 23:56:20 cachy-desktop udisksd[3279]: Error performing housekeeping for drive /org/freedesktop/UDisks2/drives/ST5000DM000_1FK178_W4J0KT2V: Error updating SMART data: Error reading SMART data from device: Input/output error (udisks-error-quark, 0)
Jun 20 23:56:20 cachy-desktop kernel: ata4.00: NCQ Non-Data Log not supported
Jun 20 23:56:20 cachy-desktop kernel: ata4.00: configured for UDMA/133
Jun 21 00:00:17 cachy-desktop systemd[1]: Started Verify integrity of password and group files.
Jun 21 00:00:17 cachy-desktop systemd[1]: shadow.service: Deactivated successfully.
Jun 21 00:06:20 cachy-desktop kernel: ata4: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Jun 21 00:06:20 cachy-desktop kernel: ata4.00: NCQ Non-Data Log not supported
Jun 21 00:06:20 cachy-desktop udisksd[3279]: Error performing housekeeping for drive /org/freedesktop/UDisks2/drives/ST5000DM000_1FK178_W4J0KT2V: Error updating SMART data: Error reading SMART data from device: Input/output error (udisks-error-quark, 0)
Jun 21 00:06:20 cachy-desktop kernel: ata4.00: NCQ Non-Data Log not supported
Jun 21 00:06:20 cachy-desktop kernel: ata4.00: configured for UDMA/133
Jun 21 00:13:10 cachy-desktop kernel: ata4.00: exception Emask 0x0 SAct 0x70000000 SErr 0x0 action 0x0
Jun 21 00:06:20 cachy-desktop kernel: ata4: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Jun 21 00:06:20 cachy-desktop kernel: ata4.00: NCQ Non-Data Log not supported
Jun 21 00:06:20 cachy-desktop udisksd[3279]: Error performing housekeeping for drive /org/freedesktop/UDisks2/drives/ST5000DM000_1FK178_W4J0KT2V: Error updating SMART data: Error reading SMART data from device: Input/output error (udisks-error-quark, 0)
Jun 21 00:06:20 cachy-desktop kernel: ata4.00: NCQ Non-Data Log not supported
Jun 21 00:06:20 cachy-desktop kernel: ata4.00: configured for UDMA/133
Jun 21 00:13:10 cachy-desktop kernel: ata4.00: exception Emask 0x0 SAct 0x70000000 SErr 0x0 action 0x0
Jun 21 00:13:10 cachy-desktop kernel: ata4.00: irq_stat 0x40000008
Jun 21 00:13:10 cachy-desktop systemd[1]: Starting Update the plocate database...
Jun 21 00:13:10 cachy-desktop kernel: ata4.00: failed command: READ FPDMA QUEUED
Jun 21 00:13:10 cachy-desktop kernel: ata4.00: cmd 60/00:e0:00:20:00/20:00:97:00:00/40 tag 28 ncq dma 4194304 in
                                               res 43/40:00:e0:32:00/00:20:97:00:00/00 Emask 0x408 (media error) <F>
Jun 21 00:13:10 cachy-desktop kernel: ata4.00: status: { DRDY SENSE ERR }
Jun 21 00:13:10 cachy-desktop kernel: ata4.00: error: { UNC }
Jun 21 00:13:10 cachy-desktop kernel: ata4.00: NCQ Non-Data Log not supported
Jun 21 00:13:10 cachy-desktop kernel: ata4.00: NCQ Non-Data Log not supported
Jun 21 00:13:10 cachy-desktop kernel: ata4.00: configured for UDMA/133
Jun 21 00:13:10 cachy-desktop kernel: sd 3:0:0:0: [sda] tag#28 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
Jun 21 00:13:10 cachy-desktop kernel: sd 3:0:0:0: [sda] tag#28 Sense Key : Medium Error [current] 
Jun 21 00:13:10 cachy-desktop kernel: sd 3:0:0:0: [sda] tag#28 Add. Sense: Unrecovered read error
Jun 21 00:13:10 cachy-desktop kernel: sd 3:0:0:0: [sda] tag#28 CDB: Read(16) 88 00 00 00 00 00 97 00 20 00 00 00 20 00 00 00
Jun 21 00:13:10 cachy-desktop kernel: critical medium error, dev sda, sector 2533372640 op 0x0:(READ) flags 0x84700 phys_seg 27 prio class 2
Jun 21 00:13:10 cachy-desktop kernel: ata4: EH complete
thanks again for any help or thoughts.
recuperation
Posts: 3158
Joined: 04 Jan 2019, 09:48
Location: Hannover, Deutschland (Germany, Allemagne)

Re: bad geometry: block count exceeds size of device after partition table recovery with testdisk

#2 Post by recuperation »

You have been possibly trapped by an translating enclosure. ;)

Read:

[...
Drive Specification* ST5000DM000 and ST5000DM001
Formatted capacity (512 bytes/sector)** 5000GB (5TB)
Guaranteed sectors 9,767,541,168
Heads 8
Disks 4
Bytes per sector
(4K physical emulated at 512-byte sectors)
4096

...]

Taken from page 8 of the pdf file:

Source:
https://www.seagate.com/www-content/pro ... 43772c.pdf

Your Seagate disk has a physical sector size of 4096 bytes.
At the interface, the disk emulates a size of 512 bytes per sector.

A MBR partition table can only address 2 TB when operating with a sector size of 512 bytes.
Your disk has a size of 5 TB, though.
Most likely Samsung has built some translating electronics into the enclosure that emulates a sector size of 4096 bytes.
That trick allows to use the old legacy MBR partition table scheme to address the whole space of a disk with a capacity of 5 TB.

Possible solutions are:

1. Copy the content of the disk file-wise to another location
or
2. Clone the disk using ddrescue to another disk with a target sector size of 4096 bytes and a total size of at least 5 TB.
or
3. Use the losetup command under linux to create a new virtual device of your Seagate disk and set the sector size of this virtual disk to 4096 byte.
nobody
Posts: 2
Joined: 21 Jun 2026, 17:24

Re: bad geometry: block count exceeds size of device after partition table recovery with testdisk

#3 Post by nobody »

thank you, that's extremely informative.

after the initial post i was able to use testdisk to copy off all of the important files, many thanks for all your work.
Post Reply