Linux FAT32 Support

Overview
FAT32 is an extension to the FAT (File Allocation Table) that allows larger partitions than FAT16 while having a normal cluster size of 4096 bytes. Previously, you could have up to 64K clusters in FAT. This would make for very inefficient use of the disk on large hard drives. For features of FAT32, read this information from Microsoft.
Technical Info
On the disk, the boot_info structure has been extended. Microsoft documentation calls this the BPB. Additionally, there is an on-disk structure called BIGFATBOOTFSINFO that keeps track of the free clusters on the partition. In the directory entry, the two unused bytes of the shortname entry are used to hold the high 16 bits of the starting cluster. All FAT entries have been increased to 32 bits. Microsoft has technical documentation on their site. Here is some additional information on the FAT Boot Sector.
Kernel Patch Notes
The patches here have already applied to kernels 2.0.34 and newer. Please do not send me mail asking if they have been applied. The kernel patches that I am making available here seem to be safe as I have heard no reports of corruption. However, use them at your own risk.

Each patch is a self-contained patch against some kernel. You only need to get one patch to apply. To apply a patch, first cd to /usr/src or the directory with the linux source tree, and then run

    patch -p0 < patch_file
To reverse an old patch so that you can apply a new one, use
    patch -R < old_patch_file
One problem with reversing a patch has been reported. If a file is removed by a normal patch, then trying to reverse it fails. The file linux/fs/fat/tables.h is such a file, and some of the patches will fail when trying to reverse that. To correct, after running the command above, run
    patch < linux/fs/fat/tables.h.rej
    File to patch: linux/fs/fat/tables.h
To build, you also need to select the Unicode, Native language support option (CONFIG_NLS) under Filesystems, and you should select a codepage and and input/ouput charset although these are not strictly necessary. The default mount options are codepage=437 and iocharset=iso8859-1. Codepage 437 is for U.S. English, and iso8859-1 is the Latin 1 character set used in much of Western Europe and the United States.

Assuming everything gets built, what special invocation to mount is needed? None. Just mount as vfat or msdos as you used to.

Known problems: Number of free clusters not handled correctly. It needs to be written in multiple places on the disk, but currently, it only gets written in one place. This will cause scandisk to complain, but it doesn't cause any real problems.

Note: The patches from 0.2.0 on also includes Joliet CD support. I didn't feel like extracting the two from one another since I have added native language tables that are used by both fat and joliet code.

Troubleshooting:

  • If you have trouble downloading, try using a raw ftp client to get to bmrc.berkeley.edu:/pub/linux/fat32. Use this option if you see errors when you try to gunzip the file.
  • Make sure that the file /usr/src/linux/fs/fat/inode.c exists. If it doesn't, you don't have a full kernel source tree installed. This is often the case with RedHat distributions. The most common sympton of this is that patch with ask you which file to patch. If is does, something is wrong.
  • If you have trouble compiling, make sure that your .config file has CONFIG_NLS set and does not have CONFIG_UVFAT_FS set. These seems to be the most common source of compile problems.
  • If you still have problems during compiling, especially if you see an error message about multiply defined symbols in namei.ver and vfatfs.ver, do
      cd /usr/src/linux (or wherever your Linux source code is)
      cp .config /tmp/
      make distclean
      cp /tmp/.config .config
      make menuconfig (or xconfig)
      make dep
      make zImage
      make modules
      make modules_install
      Install the kernel however you normally do (i.e. make zlilo)
  • If you still see errors about multiply defined symbols in namei.ver and vfatfs.ver, disable module versioning (CONFIG_MODVERSIONS).
  • If you see multiply defined symbols in tables.h, nls.c, or nls.h, make sure that there are not two (or more) copies of everything in these files. This can happen if you've tried to reverse a patch. Because reversing patches on new files doesn't work properly, if you reapply a patch, you will end up with the code duplicated.
  • If the patch applied cleanly and the compile worked but you are still unable to mount the FAT32 partition, there could be a number of problems.
    1. Make sure you are running the new kernel by running uname -a. Carefully check the build date.
    2. If you are using modules, make sure you built and installed the modules. See above for those instructions.
    3. Make sure you are mounting the correct partition. Do fdisk /dev/disk followed by the p command. This will list the partitions. Make sure the partition you are trying to mount matches the listed partition. FAT32 ids will probably be b or c.
    4. If you still aren't having any luck, use the -o debug mount option when mounting the filesystem. Then check you system log messages from /var/log/messages and see what was printed.

    The Slackware distribution now includes kernels that have FAT32 support built in. You can get Slackware boot disks from a Slackware distribution site near you.

    The Debian distribution has the FAT32 patch already applied to the 2.0.33 source distribution. I don't know about the binary kernel distribution.

    If you are trying to install RedHat 5.0 from a FAT32 partition, I think you should be able to use the Joliet boot disk courtesy of Rod Smith. He created it for booting RedHat 5.0 from a Joliet CD, but I think it should also work for booting from a FAT32 partition.

fixdisktable-0.3.tar.gz
fixdisktable-0.3 binary
fixdisktable-0.2.tar.gz
fixdisktable-0.2 binary
If you somehow manage to corrupt your PC disk partition table, this Linux utility will attempt to recover it. It scans the disk looking for filesystems. It currently tries to recognize partitions of type FAT16, FAT32, NTFS, UFS, EXT2, or BSD disk labels. It should be able to handle disks of any size--I've tried in on a disk of 10GB. You will need to boot a Linux system to run this program. I would recommend trying Tom's Single Floppy Linux to get a running Linux system. Write fixdisktable to another floppy using another machine--it can be put on a vfat/msdos floppy. Then mount the floppy and run fixdisktable. It might not always get the partition table quite right. It tends to get very close, but the beginning or the end might be off by a few blocks. In that case, use fdisk to set the partitions to cylinder boundaries.
mkdosfs-0.4.1.tgz
This is a modified version of mkdosfs that can create FAT32 partitions and it should run on big endian machines such as SparcLinux. The big endian support has not been tested. When partitioning with fdisk, use 0B as the type. It can create partitions larger than 2GB when using Linux 2.1.x.
fips15c.zip
fips15c.tar.gz
Fips is a program to non-destructively resize a FAT partition. I have done an update to fips to support FAT32. This update has now been incorporated into FIPS 2.0. Another newer partition manager/resizing program is the Ranish Partition Manager. I would recommend people try this. If you use fips, it is strongly recommended that you backup your root and boot sectors when it asks you if you want to! This will allow you to restore everything to the previous condition if something goes wrong. It would also help to have a system boot floppy around. You can create one with format /s a: or with sys a: on an already formatted floppy. Fips was not written to support partitions marked with type 0xC, 0xE, or 0xF. All of these partition type use Logical Block Addressing (LBA). LBA allows the BIOS to address disks over 8GB. A partition type of 0xC is a FAT32 partition that uses Logical Block Addressing (LBA). A partition type of 0xE is a FAT16 partition that uses LBA. A partition type of 0xF is a FAT16 partition that uses LBA but is less than 32MB. Not all partitions on LBA disks get marked with partition types 0xC, 0xE, or 0xF, so it is worth trying first. Someone has even reported success on one of the unsupported partition types--0xC.

For more information on fips, see the fips homepage.

patch-0.2.10.gz
  • This is the most current patch for 2.0.31-2.0.33 kernels
  • Kernel patch made against 2.0.31. It works with 2.0.31 to 2.0.33. When applied to 2.0.33, you will get a reject in linux/fs/vfat/namei.c.rej. You can ignore this reject since this piece has already been applied.
  • Incorporated into 2.0.34
  • Changes Linux kernel to recognize LBA extended partitions (type 0xf)
  • Adds support for IDE drives larger than 8GB. You might need to get a new version of cfdisk or sfdisk to partition IDE drives that are this big.
  • patch-0.2.9.gz
  • Kernel patch made against 2.0.31. It works with 2.0.31 to 2.0.33. When applied to 2.0.33, you will get a reject in linux/fs/vfat/namei.c.rej. You can ignore this reject since this piece has already been applied.
  • In the kernel as of 2.0.34.
  • Adds ISO9660 Level 3 support. Thanks to Eric Lammerts.
  • If Joliet and RockRidge are both available on a CD, use RockRidge by default.
  • Change to remove multiply defined symbols in .ver files. Thanks to Phil Karn.
  • Configuration and fixes.
  • patch-0.2.8.gz
  • Kernel patch made against 2.0.31. It works with 2.0.31 to 2.0.33.
  • Small change to vfat shortname creation when longname has a space in it. This makes Win95 scandisk happier.
  • patch-0.2.7.gz
  • Kernel patch made against 2.0.29. It should work on all 2.0.x kernels through 2.0.30.
  • Fixed initialization of native language tables when built into kernel.
  • patch-0.2.6.gz
  • Kernel patch made against 2.0.29. It should work on kernels from 2.0.x to 2.0.29.
  • Fixes a problem when compiling with module versioning on 2.0.x.
  • This is essentially the same patch as 0.3.5 except for Linux 2.0.x kernels. See the notes from 0.3.5 for the changes.
  • patch-0.2.5.gz
  • Kernel patch made against 2.0.29. It should work on kernels from 2.0.x to 2.0.29.
  • This is essentially the same patch as 0.3.5 except for Linux 2.0.x kernels. See the notes from 0.3.5 for the changes.
  • patch-0.2.4.gz
  • Kernel patch made against 2.0.29. It should work on kernels from 2.0.x to 2.0.29.
  • This is essentially the same patch as 0.3.4 except for Linux 2.0.x kernels. See the notes from 0.3.4 for the changes.
  • patch-0.2.3.gz
  • Kernel patch made against 2.0.29. It should work on kernels from 2.0.x to 2.0.29.
  • This is essentially the same patch as 0.3.3 except for Linux 2.0.x kernels. See the notes from 0.3.3 for the changes.
  • patch-0.2.0.gz
  • Kernel patch made against 2.0.29. It should work on kernels from 2.0.x to 2.0.29.
  • Updates the number of free clusters so scandisk should no longer complain.
  • Should work for reading and writing, but you should probably use it in write mode on less important partitions first.
  • Known problems: Only works properly on 512 byte physical sector disks. Next release will fix problem on 1024 and 2048 byte physical sector disks. There is a problem where a ".. directory not found problem" message is seen. This was fixed in 0.2.3.
  • patch-0.3.13.gz
  • Kernel patch made against 2.1.59, works for 2.1.55 through 2.1.59.
  • Incorporated into the kernel as of 2.1.60.
  • Fixes configuration problems caused by last reorganization.
  • Fixes one rename bug in vfat.
  • patch-0.3.12.gz
  • Kernel patch made against 2.1.59, works for 2.1.55 through at least 2.1.59.
  • Fixes problem with Joliet patch where same file could show up twice.
  • Fixes problems with isofs
  • Reorganizes native language support to be more satisfactory to Linus.
  • patch-0.3.11.gz
  • Kernel patch made against 2.1.56, works at least through 2.1.59.
  • Fixes slightly misformed 0.3.10 patch.
  • Small change to vfat shortname creation when longname has a space in it. This makes Win95 scandisk happier.
  • patch-0.3.10.gz
  • Kernel patch made against 2.1.56. It might work with earlier kernels, but I haven't checked.
  • patch-0.3.9.gz
  • Kernel patch made against 2.1.42. It does not work with any kernel past 2.1.42.
  • patch-0.3.8.gz
  • Kernel patch made against 2.1.36.
  • patch-0.3.7.gz
  • Kernel patch made against 2.1.29.
  • Fixed initialization of native language tables when built into kernel.
  • patch-0.3.5.gz
  • Kernel patch made against 2.1.29.
  • Fixed configuration problem with patch 0.3.4 that occurred when native language support was built into kernel.
  • patch-0.3.4.gz
  • Kernel patch made against 2.1.29.
  • Fixed configuration problems with patch 0.3.3.
  • patch-0.3.3.gz
  • Kernel patch made against 2.1.29.
  • Lots of changes to the native language support.
  • Fixes problem with ".." directory thanks to Mikhail Krivtsov.
  • Fixes 2048 byte blocksize problem thanks to Thomas Eberhardt.
  • Should no longer crash when a native language character set cannot be loaded.
  • patch-0.1.0.gz
  • Kernel patch made against 2.0.25. It should work on kernels from 1.3.xx to 2.0.27.
  • Fixes the two biggest known problems from the initial patch.
  • Does not update the number of free clusters, causing a minor error when running scandisk.
  • Should work for reading and writing, but you should probably use it in write mode on less important partitions first.
  • patch-0.0.1.gz
  • Kernel patch made against 2.0.25. It should work on kernels from 1.3.xx to 2.0.27.
  • This is the first and still buggy patch.
  • I'd recommend mouting FAT32 filesystems read-only with this patch.

  • Back to
    Gordon's Home Page.