File Allocation Table: Difference between revisions

Content deleted Content added
m Reverted edits by 2605:B100:746:17F6:ACD2:B1FF:FEAF:1A8A (talk) (HG) (3.4.12)
m Fixed k capitalization in frequency and storage capacity units (via WP:JWB)
Line 25:
| max_files_no = {{ubli
| FAT12: 4,068 for 8&nbsp;[[kilobyte|KB]] clusters <!-- 2^12 − 12 (reserved clusters) − 16 (number of 8&nbsp;KB clusters for directory entries) -->
| FAT16: 65,460 for 32&nbsp;KBkB clusters <!-- 2^16 − 12 (reserved clusters) − 64 (number of 32&nbsp;KB clusters for directory entries) -->
| FAT32: 268,173,300 for 32&nbsp;KBkB clusters <!-- 2^28 − 12 (reserved clusters) − 262144 (number of 32&nbsp;KB clusters for directory entries) -->
}}
| max_filename_size = [[8.3 filename]], or 255 [[UCS-2]] characters when using [[Long filename|LFN]]<ref group="nb" name="NB_LFN_UNI">Since [[Windows 2000]], Microsoft Windows uses [[UTF-16]] instead of [[UCS-2]] for the [[Unicode in Microsoft Windows|internal "Unicode"]]. In UTF-16, a "character" (code point) may take up two code units.</ref>
| max_volume_size = {{ubli
| FAT12: 32&nbsp;[[megabyte|MB]]<!-- with 2^16 sectors á 512 bytes, or with 8&nbsp;KB clusters --> (256&nbsp;MB for 64&nbsp;KBkB clusters<!-- and EBPB -->)
| FAT16: 2&nbsp;GB (4&nbsp;GB for 64&nbsp;KBkB clusters)
| FAT32: 2&nbsp;[[terabyte|TB]] (16&nbsp;TB for [[4Kn|4 KB sectors]])
}}
Line 82:
FAT is used internally for the [[EFI system partition]] in the boot stage of [[Extensible Firmware Interface|EFI]]-compliant computers.<ref name="efi" /> Hidden FAT filesystems are also used in the [[Unified Extensible Firmware Interface|UEFI]] boot partition on modern PCs.
 
FAT is still used in drives expected to be used by multiple operating systems, such as in shared Windows, [[Linux]] and DOS environments. Microsoft Windows additionally comes with a pre-installed tool to convert a FAT file system into NTFS directly without the need to rewrite all files, though this cannot be reversed easily.<ref>{{cite web |date=11 July 2021 |title=How to Convert a Drive from FAT32 to NTFS without Data Loss |url=https://windowsloop.com/how-to-convert-a-drive-from-fat32-to-ntfs-without-data-loss/ |url-status=live |archive-url=https://web.archive.org/web/20210808233345/https://windowsloop.com/how-to-convert-a-drive-from-fat32-to-ntfs-without-data-loss/ |archive-date=2021-08-08 |access-date=8 August 2021 |website=WindowsLoop |language=en-us}}</ref> The FAT file system is used in removable media such as [[floppy disk]]s, [[superfloppy|super-floppies]], [[memory card|memory]] and [[flash memory]] cards or [[USB flash drives]]. FAT is supported by portable devices such as [[Personal digital assistant|PDA]]s, [[digital camera]]s, [[camcorder]]s, [[Portable media player|media player]]s, and mobile phones.<ref name=":0" />
 
The [[Design rule for Camera File system|DCF]] file system adopted by almost all [[digital camera]]s since 1998 defines a logical file system with [[8.3 filename]]s and makes the use of either FAT12, FAT16, FAT32 or exFAT mandatory for its physical layer for compatibility.<ref name="DC-009-2010" />
Line 104:
The file system uses an index table stored on the device to identify chains of data storage areas associated with a file, the ''[[Design of the FAT file system#FAT|File Allocation Table]]'' (''FAT''). The FAT is statically allocated at the time of formatting. The table is a [[linked list]] of entries for each ''[[cluster (file system)|cluster]]'', a contiguous area of disk storage. Each entry contains either the number of the next cluster in the file, or else a marker indicating the end of the file, unused disk space, or special reserved areas of the disk. The ''root directory'' of the disk contains the number of the first cluster of each file in that directory. The operating system can then traverse the FAT, looking up the cluster number of each successive part of the disk file as a ''cluster chain'' until the end of the file is reached. ''Sub-directories'' are implemented as special files containing the ''directory entries'' of their respective files.
 
Each entry in the FAT linked list is a fixed number of bits: 12, 16 or 32. The maximum size of a file or a disk drive that can be accessed is the product of the largest number that can be stored in the entries (less a few values reserved to indicate unallocated space or the end of a list) and the size of the disk cluster. Even if only one byte of storage is needed to extend a file, an entire cluster must be allocated to it and any single cluster can not hold more than a single file, so large clusters waste much disk space if there are large numbers of small files.
 
Originally designed as an 8-bit file system, the maximum number of clusters must increase as disk drive capacity increases, and so the number of bits used to identify each cluster has grown. The successive major variants of the FAT format are named after the number of table element bits: 12 ([[#FAT12|FAT12]]), 16 ([[#FAT16|FAT16]]), and 32 ([[#FAT32|FAT32]]).
Line 170:
}}
| max_volume_size = {{ubli
| 16&nbsp;MB (with 4&nbsp;KBkB clusters)
| 32&nbsp;MB (with 8&nbsp;KBkB clusters)<!-- larger volumes should use logical sectored FAT partition IDs or FAT16 partition IDs -->
}}
| max_file_size = Limited by volume size
| file_size_granularity = 1&nbsp;byte
| max_files_no = 4,068 for 8&nbsp;KBkB clusters<!-- 2^12 - 12 (reserved clusters) - 16 (number of 8&nbsp;KB clusters for directory entries) -->
| max_filename_size = [[8.3 filename]] with [[OEM character set|OEM]] characters, <br />255 [[UCS-2]] characters<ref group="nb" name="NB_LFN_UNI"/> when using [[Long filename|LFN]]
| max_directory_depth = 32&nbsp;levels or 66&nbsp;characters (with [[Current Directory Structure|CDS]]), <br />60&nbsp;levels or more (without CDS)
Line 205:
The capability to read previously formatted volumes with 16-byte directory entries<ref name="SCP_1981_86-DOS_1.0_Addendum" /> was dropped with [[MS-DOS 1.20]].
 
FAT12 used 12-bit entries for the cluster addresses; some values were reserved to mark the end of a chain of clusters, to mark unusable areas of the disk, or for other purposes, so the maximum number of clusters was limited to 4078.<ref name="Norton2" /><ref name="Jenkinson_2000_Forensic" /> To conserve disk space, two 12-bit FAT entries used three consecutive 8-bit bytes on disk, requiring manipulation to unpack the 12-bit values. This was sufficient for the original floppy disk drives, and small hard disks up to 32 megabytes. The [[#FAT16B|FAT16B]] version available with DOS&nbsp;3.31 supported [[32-bit]] sector numbers, and so increased the volume size limit.
 
All the control structures fit inside the first track, to avoid head movement during read and write operations. Any bad sector in the control structures area would make the disk unusable. The DOS formatting tool rejected such disks completely. Bad sectors were allowed only in the file data area. Clusters containing bad sectors were marked unusable with the reserved value <code>0xFF7</code> in the FAT.
 
While 86-DOS supported three disk formats (250.25&nbsp;KBkB, 616&nbsp;KBkB and 1232&nbsp;KBkB, with [[FAT ID]]s <code>0xFF</code> and <code>0xFE</code>) on 8-inch (200&nbsp;mm) floppy drives, IBM [[PC&nbsp;DOS 1.0]], released with the original [[IBM Personal Computer]] in 1981, supported only an 8-sector floppy format with a formatted capacity of 160&nbsp;KBkB (FAT ID <code>0xFE</code>) for single-sided 5.25-inch floppy drives, and [[PC&nbsp;DOS 1.1]] added support for a [[double-sided disk|double-sided]] format with 320&nbsp;KBkB (FAT ID <code>0xFF</code>). [[PC DOS 2.0]] introduced support for 9-sector floppy formats with 180&nbsp;KBkB (FAT ID <code>0xFC</code>) and 360&nbsp;KBkB (FAT ID <code>0xFD</code>).
 
86-DOS&nbsp;1.00 and PC&nbsp;DOS 1.0 directory entries included only one date, the last modified date. PC&nbsp;DOS 1.1 added the last modified time. PC&nbsp;DOS 1.x [[file attribute]]s included a hidden bit and system bit, with the remaining six bits undefined. At this time, DOS did not support sub-directories, but typically there were only a few dozen files on a [[floppy disk|diskette]].
 
The [[PC XT]] was the first PC with an IBM-supplied hard drive, and PC&nbsp;DOS 2.0 supported that hard drive with FAT12 ([[FAT ID]] <code>0xF8</code>). The fixed assumption of 8&nbsp;sectors per clusters on hard disks practically limited the maximum partition size to 16&nbsp;MB for 512&nbsp;byte sectors and 4&nbsp;KBkB clusters.
 
The ''[[BIOS Parameter Block]]'' (''BPB'') was introduced with PC&nbsp;DOS&nbsp;2.0 as well, and this version also added read-only, [[archive bit|archive]], [[volume (computing)|volume label]], and [[Directory (file systems)|directory]] attribute bits for hierarchical sub-directories.<ref name="two" />
Line 236:
| max_file_size = 4,294,967,295 bytes (4&nbsp;GB − 1)<!-- Not "limited by volume size" if volumes larger than 4 GB are possible. -->
| file_size_granularity = 1&nbsp;byte
| max_files_no = 65,536 for 32&nbsp;KBkB clusters<!-- 2^16 − 12 (reserved clusters) − 64 (number of 32 KB clusters for directory entries) -->
| max_filename_size = [[8.3 filename]] with [[OEM character set|OEM]] characters, 255&nbsp;[[UCS-2]] characters<ref group="nb" name="NB_LFN_UNI"/> when using [[Long filename|LFN]]
| max_directory_depth = 32&nbsp;levels or 66&nbsp;characters (with [[Current Directory Structure|CDS]]), <br />60&nbsp;levels or more (without CDS)
Line 309:
| max_volume_size = {{ubli
| 2&nbsp;[[gigabyte|GB]] (with 32&nbsp;[[kilobyte|KB]] clusters)
| 4&nbsp;GB (with 64&nbsp;KBkB clusters) (NT&nbsp;4, PTS-DOS, EDR-DOS)
| 8&nbsp;GB (with 128&nbsp;KBkB clusters and <!-- 128 s/c -->1 or <!-- 64 s/c -->2&nbsp;KBkB sectors) (NT&nbsp;4 and EDR-DOS only)
| 8&nbsp;GB (with 128&nbsp;KBkB clusters and <!-- 256 s/c -->512 byte sectors) (EDR-DOS only)
| 16&nbsp;GB (with 256&nbsp;KBkB clusters and <!-- 128 s/c -->2 or <!-- 64 s/c -->4&nbsp;KBkB sectors) (NT&nbsp;4 only)
}}
| max_file_size = {{ubli
Line 320:
}}
| file_size_granularity = 1&nbsp;byte
| max_files_no = 65,460 for 32&nbsp;KBkB clusters<!-- 2^16 − 12 (reserved clusters) − 64 (number of 32 KB clusters for directory entries) -->
| max_filename_size = [[8.3 filename]] with [[OEM character set|OEM]] characters, <br />255 [[UCS-2]] characters<ref group="nb" name="NB_LFN_UNI"/> when using [[Long filename|LFN]]
| max_directory_depth = 32&nbsp;levels or 66&nbsp;characters (with [[Current Directory Structure|CDS]]), <br />60&nbsp;levels or more (without CDS)
Line 354:
If partitions to be used by pre-DOS&nbsp;3.31 issues of DOS need to be created by modern tools, the only criteria theoretically necessary to meet are a sector count of less than 65536, and the usage of the old partition ID (<code>[[Partition type#PID_04h|0x04]]</code>). In practice however, type <code>[[Partition type#PID_01h|0x01]]</code> and <code>[[Partition type#PID_04h|0x04]]</code> primary partitions should not be physically located outside the first 32&nbsp;MB of the disk, due to other restrictions in MS-DOS&nbsp;2.x, which could not cope with them otherwise.
 
In 1988, the FAT16B improvement became more generally available through [[DR&nbsp;DOS]]&nbsp;3.31, PC&nbsp;DOS&nbsp;4.0, [[OS/2]]&nbsp;1.1, and MS-DOS&nbsp;4.0. The limit on partition size was dictated by the 8-bit [[Signedness|signed]] count of sectors per cluster, which originally had a maximum power-of-two value of 64. With the standard hard disk sector size of 512&nbsp;bytes, this gives a maximum of 32&nbsp;KBkB cluster size, thereby fixing the "definitive" limit for the FAT16 partition size at 2&nbsp;GB for sector size 512. On [[magneto-optical]] media, which can have 1 or 2&nbsp;KBkB sectors instead of 0.5&nbsp;KBkB, this size limit is proportionally larger.
 
Much later, [[Windows&nbsp;NT]] increased the maximum cluster size to 64&nbsp;KBkB, by considering the sectors-per-cluster count as unsigned. However, the resulting format was not compatible with any other FAT implementation of the time, and it generated greater [[internal fragmentation]]. [[Windows 98]], SE and ME also supported reading and writing this variant, but its disk utilities did not work with it and some [[File control block|FCB]] services are not available for such volumes. This contributes to a confusing compatibility situation.
 
Prior to 1995, versions of DOS accessed the disk via [[Cylinder-head-sector|CHS]] addressing only. When [[Windows&nbsp;95]](MS-DOS 7.0) introduced [[Logical block addressing|LBA]] disk access, partitions could start being physically located outside the first c. 8&nbsp;GB<!-- exact value is somewhat smaller --> of this disk and thereby out of the reach of the traditional CHS addressing scheme. Partitions partially or fully located beyond the CHS barrier therefore had to be hidden from non-LBA-enabled operating systems by using the new partition type <code>[[Partition type#PID_0Eh|0x0E]]</code> in the partition table instead. FAT16 partitions using this partition type are also named '''FAT16X'''.<ref name="Microsoft_2004_KB120138" /> The only difference, compared to previous FAT16 partitions, is the fact that some CHS-related geometry entries in the BPB record, namely the number of sectors per track and the number of heads, may contain no or misleading values and should not be used.
Line 380:
| min_volume_size = {{ubli
| 32&nbsp;[[megabyte|MB]] – 4.5&nbsp;[[kilobyte|KB]] (with 65525 clusters and 512 byte sectors)
| 256&nbsp;MB – 36&nbsp;KBkB (with 65525 clusters and 4&nbsp;[[kilobyte|KB]] sectors)
}}
| max_volume_size = {{ubli
| 2&nbsp;[[terabyte|TB]] (with 512&nbsp;byte sectors)
| 8&nbsp;TB (with 2&nbsp;KBkB sectors and 32&nbsp;KBkB clusters)
| 16&nbsp;TB (with 4&nbsp;KBkB sectors and 64&nbsp;KBkB clusters)
}}
| max_file_size = {{ubli
Line 392:
| 274,877,906,943 bytes (256&nbsp;GiB − 1 byte)<!-- 2^38 - 1 --> (only with FAT32+<ref name="DRDOS_FAT+_R2" />)
}}
| max_files_no = 268,173,300 for 32&nbsp;KBkB clusters<!-- 2^28 − 12 (reserved clusters) − 262144 (number of 32&nbsp;KB clusters for directory entries) -->
| max_filename_size = [[8.3 filename]] with [[OEM character set|OEM]] characters, <br />255 [[UCS-2]] characters<ref group="nb" name="NB_LFN_UNI"/> when using [[Long filename|LFN]]
| max_directory_depth = 32&nbsp;levels or 66&nbsp;characters (with [[Current Directory Structure|CDS]]), <br />60&nbsp;levels or more (without CDS)
Line 417:
}}
 
In order to overcome the volume size limit of FAT16, while at the same time allowing DOS [[Real mode|real-mode]] code to handle the format, Microsoft designed a new version of the file system, '''FAT32''', which supported an increased number of possible clusters, but could reuse most of the existing code, so that the [[conventional memory]] footprint was increased by less than 5 KB&nbsp;kB under DOS.<ref name="Microsoft_1998_CC768180" /> Cluster values are represented by [[32-bit]] numbers, of which 28 bits are used to hold the cluster number.
 
==== Maximal sizes ====
Line 505:
While resembling the same basic design ideas as [[#FAT16|FAT16]] and [[#FAT32|FAT32]], the '''FATX16''' and '''FATX32''' on-disk structures are simplified, but fundamentally incompatible with normal FAT16 and FAT32 file systems, making it impossible for normal FAT file system drivers to mount such volumes.
 
The non-bootable [[superblock (file systems)|superblock]] sector is 4&nbsp;KBkB in size and holds an 18&nbsp;byte large BPB-like structure completely different from normal [[FAT BPB|BPB]]s. Clusters are typically 16&nbsp;KBkB in size and there is only one copy of the FAT on the Xbox. Directory entries are 64&nbsp;bytes in size instead of the normal [[FAT directory entry|32&nbsp;bytes]]. Files can have filenames up to 42 characters long using the [[OEM character set]]<!-- not Unicode --> and be up to 4&nbsp;GB minus 1&nbsp;byte in size. The on-disk timestamps hold creation, modification and access dates and times but differ from FAT: in FAT, the [[Epoch (computing)|epoch]] is [[Epoch of 1980-01-01|1980]]; in FATX, the epoch is [[Epoch of 2000-01-01|2000]]. On the [[Xbox 360]], the epoch is 1980.<ref name="Xbox360_FATX" />
 
=== exFAT ===
Line 633:
* Microsoft Technet; [https://web.archive.org/web/20060307082555/http://www.microsoft.com/technet/prodtechnol/winxppro/reskit/c13621675.mspx ''Volume and file size limits of FAT file systems''], copy made by [https://archive.org/ Internet Archive Wayback Machine] of an article with summary of limits in FAT32 which is no longer available on Microsoft website.
* [[Raymond Chen (Microsoft)|Chen, Raymond]]; [https://web.archive.org/web/20081118122857/http://www.microsoft.com/technet/technetmag/issues/2006/07/WindowsConfidential/ ''Microsoft TechNet: A Brief and Incomplete History of FAT32'']
* [https://web.archive.org/web/20170610205053/https://support.microsoft.com/en-us/help/263044/fdisk-does-not-recognize-full-size-of-hard-disks-larger-than-64-gb Fdisk does not recognize full size of hard disks larger than {{nowrap|64 GB}}]: Microsoft Knowledge Base Article 263044, copy made by [https://archive.org/web/ Internet Archive Wayback Machine]. Explains inability to work with extremely large volumes under Windows 95/98.
* [https://web.archive.org/web/20050319235548/http://www.microsoft.com/resources/documentation/Windows/XP/all/reskit/en-us/prkc_fil_cycz.asp ''Microsoft Windows XP: FAT32 File System''], copy made by the [[Internet Archive]]'s [[Wayback Machine]] of an article with summary of limits in FAT32 which is no longer available on Microsoft website.