Monday, July 20, 2009

mkdosfs on larger then 2GB filesystems

If you have trouble creating FAT (a.k.a. vfat, fat32) filesystems larger then 2GB, remember to build mkfs.vfat (mkdosfs) from dosfstools with:

make CFLAGS='-D_FILE_OFFSET_BITS=64'

Some embedded chip vendors forget to do this in their Linux Board Support Packages.

See 'feautre_test_macros(7)' for the details regarding defining the '_FILE_OFFSET_BITS=64' C preprocessor symbol.
Basically it causes the 'off_t' type in the C library to become 64 bits. ISO C and POSIX functions that uses 'off_t' include:

ftruncate, lockf, lseek, pread, pwrite, truncate, fseek, ftello
Google 'large file support' for more info.