## f_mkfs

The f_mkfs fucntion creates a file system on the drive.

    FRESULT f_mkfs (
      BYTE  Drive,            /* Logical drive number */
      BYTE  PartitioningRule, /* Partitioning rule */
      BYTE  AllocSize         /* Allocation unit size */
    );

#### Parameters

Drive
  Logical drive number (0-9) to be formatted.
PartitioningRule
  When 0 is given, a partition table is created into first sector on the drive and then the file system is created on the partition. This is called FDISK format. When 1 is given, the file system starts from the first sector without partition table. This is often called super floppy (SFD) format.
AllocSize
  Specifies allocation unit size (number of sectors per cluster). The value must be power of 2 in range of from 1 to 64.

#### Return Values

FR_OK (0)
  The function succeeded.
FR_INVALID_DRIVE
  The drive number is invalid.
FR_NOT_READY
  The drive cannot work due to any reason.
FR_WRITE_PROTECTED
  The drive is write protected.
FR_NOT_ENABLED
  The logical drive has no work area.
FR_RW_ERROR
  The function failed due to a disk error or an internal error.
FR_MKFS_ABORTED
  The function aborted before start in format due to a reason as follows.
  - The disk size is too small.
  - Invalid parameter was given to any parameter.
  - Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7.

#### Description

The f_mkfs function creates a FAT file system on the drive. There are two partitioning rules, FDISK and SFD, for removable media. It can be selected with a parameter and FDISK format is recommended for most case. This function currently does not support multiple partition, so that existing partitions on the physical dirve will be deleted and re-created a partition occupies entire disk space.

The FAT type, FAT12/FAT16/FAT32, is determined by only how many clusters on the drive and nothing else, according to FAT specification. Thus which FAT type is selected, is depends on the drive size and specified cluster size. The cluster size affects performance of file system and large cluster increases the performance, so that 64 sectors per cluster is recommended except for small drive.

This function is supported on only FatFs with _USE_MKFS option.

Return