Mounting errors with large ntfs partition and solution hint
I have encountered some problems with using ntfs-based filesystem on large sdhc cards.
A mount command for a single ntfs formatted partition on a 8GB SDHC Card fails with the following output:
mount -t ntfs-3g /dev/sda1 /media/sd/
Failed to read last sector (15644671): Invalid argument
HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,
or it was not setup correctly (e.g. by not using mdadm --build ...),
or a wrong device is tried to be mounted,
or the partition table is corrupt (partition is smaller than NTFS),
or the NTFS boot sector is corrupt (NTFS size is not valid).
Failed to mount '/dev/sda1': Invalid argument
The device '/dev/sda1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
mkfs.ntfs also results in an error:
mkfs.ntfs -f /dev/sda1
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
Error writing non-resident attribute value.
add_attr_data_positioned failed: Invalid argument
Couldn't create $MFTMirr: Invalid argument
Version of ntfs-3g and the ntfsprogs is 2012-1-15, almost the most recent i think.
The specific in our environment is that the ntfs-3g components are cross-compiled for atom based targets.
Some investigations leads to the preprocessor define of _FILE_OFFSET_BITS. The cross compiler toolchain with its integrated autotools has not set this define into the config.h of the libntfs-3g components.
So the lib binary libntfs-3g.so.83.0.0 uses the lseek, fopen aso. functions and not the lseek64... So most probably partitons <= 4GB can be handled with (for example) signed integer parameters in lseek. Tests with partitions smaller than 4GB can be handled by this lib. But if there are bigger partitions like 8GB or so the errors above happens.
I have no clue why the cross compiler and its autotools has not set the _FILE_OFFSET_BITS define. Could be the AC_SYS_LARGEFILE macro, but i have not investigated any further at this point. Defining it manually in the CFLAGS env var builds a libntfs-3g which uses the lseek64 variant. No more errors has happened with this new lib. Mounting partitions larger than 4GB is OK now.
Maybe this is of interest for someone else who runs into such error messages. Otherwise just ignore this post