Ext | Windows |
Block | Cluster |
allocation units
.sudo fdisk -l /dev/sda5
(view sector size)A disk formatted with FAT is allocated in clusters, whose size are determined by the size of the volume. When a file is created, an entry is created in the directory and the first cluster number containing data is established. This entry in the FAT table either indicates that this is the last cluster of the file, or points to the next cluster.
The Root Directory, sometimes referred to as the Root Folder, contains an entry for each file and directory stored in the file system. This information includes the file name, starting cluster number, and file size. This information is changed whenever a file is created or subsequently modified. (Also includes the create time, last access, etc… see here)
The Boot Record, FATs, and Root Directory are collectively referred to as the System Area. The remaining space on the logical drive is called the Data Area, which is where files are actually stored. It should be noted that when a file is deleted by the operating system, the data stored in the Data Area remains intact until it is overwritten.
Adv | Disadv |
Can be undeleted | As size of volume increases, perfomance decreases |
Cannot set permissions on files |
The difference between the files logical size and the size of the cluster. OS doesn’t write there, so could store old data or secret
data.
sudo mkfs.vfat -s 16 /dev/sda5
(man mkfs.vfat)sudo fsck.vfat -vr /dev/sda5
sudo file -s /dev/sda5
The above command utilized 16 sectors per cluster. If each sector is 512 Bytes, we could calculate that each cluster is then 8192 bytes in size. If you then create a file, you should be able to determine how many clusters it will use and then verify it using the du
command.
This example utilized 2 sectors per cluster (i.e. mkfs.vfat -s 2 -F 32 /dev/sda25). 14493 is the size of the contents of the file (i.e. fallocate -l 14493 foo.txt). 14493⁄1024 = 14.15 (round to 15)
joe@12g:~/2sectorpercluster$ ls -l z.txt
-rwxrwxr-x 1 joe joe 14493 Apr 3 15:04 z.txt
joe@12g:~/2sectorpercluster$ du z.txt
15 z.txt
Create a file that is one less than a multiple of the cluster size… For example if you have 2 sectors per cluster, 16 clusters would be a file size of 15360. What if you create a file of 15359? What if you create a file of 15361? See the output of the du command.
Preferably, when using drives or partitions of over 200 MB the FAT file system should not be used. This is because as the size of the volume increases, performance with FAT will quickly decrease. It is not possible to set permissions on files that are FAT partitions.
Today, FAT file systems are still commonly found on floppy disks, USB sticks, flash and other solid-state memory cards and modules, and many portable and embedded devices.