Subj : Re: filesystems To : comp.programming From : robertwessel2@yahoo.com Date : Wed Oct 05 2005 12:02 am Bill Cunningham wrote: > What is the difference in HD geometry in the fat16 and fat32 > filesystems? I know 32 bit block can be manually manipulated to be 16 bit > blocks. In other words changing fat32 to fat16. But there would be an > unavoidable loss of data wouldn't there be? Perhaps the definitive description of FAT12/16/32 is: http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx In short, FAT32 volumes have 65,525 or more clusters, FAT12 volumes have 4084 clusters or fewer, and volumes with cluster counts between those limits are FAT16. The only real difference between FAT12 and FAT16 is that FAT itself - it's made up of 12 bit entries (packed two to every three bytes), where as FAT16 uses two byte entries. FAT32 also changes the FAT in the obvious way (FAT entries are now four bytes (of which only 28 bits are usable as a cluster number). All three FAT formats have slightly different conventions on what special cluster number values are defined and how they're used. Beyond that, FAT32 changes how the fields after byte 36 in the boot sector are defined (FAT12/16 defines five fields in 26 bytes, FAT32 defines 11 fields in 54 bytes, including all of the FAT12/16 fields in different places). FAT32 also changes the way a few fields in the first 36 bytes of the boot sector are used (for example, the field that specifies the number of entries in the fixed root directory area must always be zero in FAT32). The major structural change is that FAT32 does not use a fixed root directory area, rather the root directory is a directory like any other, and one of the new FAT32 boot sector field points to the first cluster. In addition FAT32 has an additional sector containing some FAT management data, plus there's a backup boot sector. Also, the boot code on FAT32 volumes tends to take three sectors, and not just one. These are all in the reserved area at the beginning of the disk (which is usually 32 sectors on FAT32 vs. 1 sector on FAT12/16). Conversion between FAT formats is non-trivial and not possible in all cases (for example, you cannot have a 2MB storage device formatted with anything other than FAT12, nor can a device bigger than about 2GB be anything other than FAT32, unless you leave a large enough reserved area to reduce it's capacity to 65,524 32KB clusters). In general, switching to a format with smaller clusters is easier, since you can just slice up the existing clusters. So a 40,000 cluster FAT16 volume could be redefined as an 80,000 cluster FAT32 volume (assuming the FAT16 clusters are at least 1KB). A similar scheme thing could be done converting from FAT12 to FAT16. The big problem is that the FATs themselves will increase in size, which will almost certainly overlay the root directory area and perhaps the first data clusters on the device. If there's not enough space to handle the grown FATs (and some tweaks are possible here - like deleting extra copies of the FAT or reducing the size of the root directory area), the disk will need to be reorg'd such that enough free space is left at the beginning. This is more-or-less the defragmentation process with a tweak or two (although it can be simpler since your goal is just moving data away from one area of the disk rather than a full defragment). Going the other way (smaller to larger clusters) is more difficult. You have to reorg the disk in such a way that the smaller clusters are used in groups that are multiples of the larger cluster size, with padding clusters inserted as needed. Again, this is a tweaked defragmentation process. Once you've done that, you can reorganize the FATs and root directory areas as needed (and if you were starting with FAT32, the reorg will need to leave enough space for the root directory area). In either case, once you get the clusters repacked and repositioned as appropriate, you have to adjust all the directory entries on the volume to use the "new" cluster numbers, rebuild the new format FATs, and rebuild the reserved area at the beginning of the disk to match the new format. .