FAT32

From LQWiki
Jump to navigation Jump to search

FAT32 is a filesystem type used by large Windows partitions, and fully supported by Linux. A FAT32 partition can by accessed for read and write by Linux, and also by Windows (98, XP, ...) on a dual boot system.

To create a FAT32 filesystem on a partition ("format" it) use mkdosfs.

Copying bootable FAT32 partitions

  1. Create format the new partition with "mkdosfs -s 8 -F 32 /dev/newpartition". This creates a FAT32 partition with a cluster size of 4KB, regardless of the partition size. This is much better than formatting using a windows format tool, because if partitions are big, windows format defines the cluster size as 16KB. If you have about 700'000 files, you save about 4GB of space (due to less internal fragmentation) this way. So using mkdosfs actually is worth it.
  2. Unfortunately mkdosfs (version 2.10) does not make it right from the start. You have to change some fields in the boot sector (BIOS parameter block):
    1. Number of heads to the number of heads of the hard disk
    2. Wether the booting drive is a hard disk (0x80) or not (0x00). The latter is the default with mkdosfs.
    3. The number of hidden sectors. The name of this field is actually misleading a bit, it is the number of sectors which are on the disk before the first sector of the new FAT-partition starts.
  3. Copy the data. Ideally, mount with "-o iocharset=utf8" and use the tool "mirrordir" to really mirror the directories. Even this is not perfect (e.g. files might loose the "hidden" attribute)
  4. Boot with a Windows setup CD to a "recovery console" and apply "fixboot" (and maybe "fixmbr" too).
  5. Try to boot from the new partition.
  6. If necessary (you run both windows and linux on your machine), reinstall your favourite boot loader (e.g. "grub"), e.g. by booting from a Linux CD.

It is very important that you set the abovementioned values which are incorrectly set by mkdosfs. Else the new partition will not be able to boot. Unlike one may expect, "fixboot" does not fix these wrong values either.