7

TL;DR: How do I get rid of the warnings in the subject line when everything else looks sweet?

I'm getting the following output when running testdisk's Analyze on a 64GB SD card:

TestDisk 6.14, Data Recovery Utility, July 2013                                                                                                                                                       
Christophe GRENIER <grenier@cgsecurity.org>                                                                                                                                                           
http://www.cgsecurity.org                                                                                                                                                                             

Disk /dev/sdb - 63 GB / 59 GiB - CHS 60906 64 32                                                                                                                                                      
Current partition structure:                                                                                                                                                                          
     Partition                  Start        End    Size in sectors                                                                                                                                   

Warning: number of heads/cylinder mismatches 255 (FAT) != 64 (HD)                                                                                                                                     
Warning: number of sectors per track mismatches 63 (FAT) != 32 (HD)                                                                                                                                   
 1 P FAT32 LBA                0   1 32 51199  63 32  104857537 [27GB]                                                                                                                                 
 2 P Linux                51200   0  1 60902  63 32   19871744 [Link2SD]                                                                                                                              
No partition is bootable 

Both partitions are fsck-clean, and /dev/sdb1 is also chkdsk-clean under Win10.

fsck -l says: (it all looks good to me)

Disk /dev/sdb: 63.9 GB, 63864569856 bytes
64 heads, 32 sectors/track, 60906 cylinders, total 124735488 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: 0x1c580740

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63   104857599    52428768+   c  W95 FAT32 (LBA)
/dev/sdb2       104857600   124729343     9935872   83  Linux

If I try to set the geometry mentioned in testdisk's mismatch warning (H=255, S=63) I get:

TestDisk 6.14, Data Recovery Utility, July 2013                                                                                                                                                       
Christophe GRENIER <grenier@cgsecurity.org>                                                                                                                                                           
http://www.cgsecurity.org                                                                                                                                                                             

Disk /dev/sdb - 63 GB / 59 GiB - CHS 7765 255 63                                                                                                                                                      
Current partition structure:                                                                                                                                                                          
     Partition                  Start        End    Size in sectors                                                                                                                                   

 1 P FAT32 LBA                0   1  1  6527  21 22  104857537 [27GB]                                                                                                                                 

Bad relative sector.                                                                                                                                                                                  
 2 P Linux                 6527  21 23  7764  10 54   19871744 [Link2SD]                                                                                                                              
No partition is bootable

Note that the sector 6527 is now "shared" which doesn't seem right.

How can I remove the initial mismatch warnings?

8

Short answer: Ignore the warnings or contact the program's author.

Long answer: Cylinder/head/sector (CHS) values have passed through several stages, from an accurate representation to a convenient fiction to an inconvenient fiction to worse than useless to abandoned. CHS values (as stored in the Master Boot Record, or MBR data structures) max out at about 8 GB, so CHS cannot represent any but the tiniest partitions on a modern disk. In fact, even many USB flash drives now exceed the CHS limitations! The newer GUID Partition Table (GPT) data structures don't even use CHS values, except on one area (the "protective MBR") that exists solely to signal to older software that it shouldn't mess with the disk -- and in practice, the CHS values used in the protective MBR are often completely bogus, by either MBR or GPT standards.

TestDisk is a useful tool, but I admit I haven't used it a lot. When I have used it, I've been appalled at its continuing use of CHS values in prominent locations of its user interface. This is pointless and potentially confusing. Most modern tools -- even tools for manipulating MBR disks -- today use logical block addressing (LBA) almost exclusively, or at least in preference to CHS addressing. LBA can handle up to 2^32 sectors on MBR disks, which works out to 2 TiB, given 512-byte sectors. On GPT disks, 64-bit LBA values are used, so the limit is 2^64 sectors (8 ZiB, assuming 512-byte sectors). Tools that write MBR data structures must continue to populate the CHS fields, but on disks over about 8 GB in size, those fields are likely to be maxed out or contain bogus values; there's simply no helping that fact on over-8GB disks.

As a practical matter, you should simply ignore TestDisk's warnings about CHS values unless you're using really ancient software (like very old versions of DOS). Asking TestDisk's authors to de-emphasize CHS in favor of LBA may be worth doing, too. If you want to eliminate the warnings, your only options are to convince TestDisk's authors to do this or to modify the software yourself.

| improve this answer | |
  • 2
    I raised an issue for this. – Tom Hale Sep 10 '16 at 8:12
  • 1
    The issue has been closed: "Old partitioning tools aligns partition to cylinder boundary. To recover lost partitions, a "correct" CHS geometry is needed." It's still open to comment though. – mwfearnley Nov 6 '17 at 9:45
  • There are however cases when mismatch of CHS values between HDD MBR and boot sectors of NTFS partitions (an possibly others as well). Could you please enhance your answer to add how to make CHS values "consistent" whatever that could mean. – Pawel Debski Apr 14 at 20:51
8

You can ignore this warning as you don't have partition to recover.

Modern partionning software aligns partition to 1-MB boundaries. But a correct geometry is useful to recover lost partition when there were aligned to cylinder boundary.

It's the case for the second partition but it's not the case for the first one is aligned to a cylinder boundary (assuming 255 heads per cylinder and 63 sectors per cylinder, information recorded in the FAT32 boot sector).

So you can safely ignore this warning but it will be wrong to remove this warning from testdisk.

| improve this answer | |
  • 1
    +1 for being an authoritative response from (presumably:) the testdisk author – mwfearnley Nov 6 '17 at 9:48
  • Unfortunately I cannot ignore exactly the same warnings as some disk copy / backup tools get confused and anyway sheer number of warnings is annoying. Would you please elaborate on CHS manipulations and what would be correct value (sized/255/63) and how to make it consistent across all partitions. – Pawel Debski Apr 14 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.