[gparted] Limit FAT32 maximum volume size to 2 TiB



commit 2bb78cf8dc0028fc5d01044655a7cf12bb01d95d
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sat Mar 19 10:22:17 2016 +0000

    Limit FAT32 maximum volume size to 2 TiB
    
    GParted is allowing creation of a FAT32 formatted partition of any size.
    However with a 512 byte sector size the maximum volume size of a FAT32
    file system is reported to be 2 TiB.
    * Wikipedia: File Allocation Table / FAT32
      https://en.wikipedia.org/wiki/File_Allocation_Table#FAT32
      "The boot sector uses a 32-bit field for the sector count, limiting
      the FAT32 volume size to 2 TB for a sector size of 512 bytes and 16 TB
      for a sector size of 4,096 bytes."
    * Microsoft: Default cluster size for NTFS, FAT, and exFAT / Default
      cluster sizes for FAT32
      https://support.microsoft.com/en-us/kb/140365
    
    Trying to create a FAT32 file system in a partition larger than 2 TiB
    results in unallocated space being left after the file system.
    
    Nuances:
    [1] Larger sector sizes allow larger maximum volume sizes up to 16 TiB
        with 4096 byte sectors.
    [2] mkdosfs/mkfs.fat has an -S SECTOR_SIZE option which allows changing
        the "logical" sector size of the file system allowing the maximum
        volume to be proportionally increased.
    [3] mkfs.fat appears to have an signed overflow bug when the size of the
        partition is larger than maximum signed 32-bit integer of logical(?)
        sectors.  (2 TiB for a sector size of 512 bytes).  It reports the
        partition size as minus size and creates a 1 TiB file system.
    
    GParted wants a single maximum file system size and the code is not
    ready for a differing maximum file system size for different sector
    sizes.
    
    In fat16::create() could specify larger "logical" sector sizes to
    mkfs.fat when the partition is larger than 2 TiB to allow maximum volume
    size to be increased further.  However that will take a lot of cross
    platform testing to ensure that all sorts of devices support "logical"
    sector sizes other than 512 bytes on devices with a hardware sector size
    of 512 bytes.  This is too much effort.
    
    Therefore implement a single FAT32 maximum volume size of 2 TiB.
    
    Bug 763896 - GParted not restricting creation of FAT32 volume to maximum
                 size of 2 TiB

 src/fat16.cc |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/src/fat16.cc b/src/fat16.cc
index f89f6e1..e85042f 100644
--- a/src/fat16.cc
+++ b/src/fat16.cc
@@ -120,6 +120,11 @@ FS fat16::get_filesystem_support()
        else //FS_FAT32
        {
                fs .MIN = 33 * MEBIBYTE ; //Smaller file systems will cause windows scandisk to fail.
+
+               // Maximum FAT32 volume size with 512 byte sectors is 2 TiB.
+               // *   Wikipedia: File Allocation Table / FAT32
+               //     https://en.wikipedia.org/wiki/File_Allocation_Table#FAT32
+               fs.MAX = 2 * TEBIBYTE;
        }
 
        return fs ;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]