LinuxCommandLibrary

mkfs.f2fs

Create F2FS filesystem on a device

TLDR

Create an F2FS filesystem inside partition Y on device X

$ sudo mkfs.f2fs [/dev/sdXY]
copy

Create an F2FS filesystem with a volume label
$ sudo mkfs.f2fs -l [volume_label] [/dev/sdXY]
copy

SYNOPSIS

mkfs.f2fs [options...] <device>

PARAMETERS

-a <alloc_type>
    Set allocation type: heap, section, or bestfit

-c <cp_type>
    Set checkpoint type: disable or enable

-C <cluster_size>
    Specify cluster size in bytes

-d <debug_level>
    Set debug level (0-1)

-D <discard>
    Enable discard (TRIM) during formatting

-E <root_hash_algo>
    Set root hash algorithm for verity

-e <encrypt_level>
    Set encryption level (0-3)

-f
    Force overwrite without prompts

-g <group_size>
    Set section size in power of 2 (0-7)

-l <label>
    Set volume label (max 512 bytes)

-m
    Enable inline xattrs

-M
    Enable inline data

-O [<feature_list>]
    Enable features: extra_attr, compr, pin_file, etc.

-o <overprovision_ratio>
    Set overprovision ratio (0-80%)

-p <inline_xattr_size>
    Set inline xattr size (0-64)

-P
    Enable inline data in directory

-q
    Quiet mode

-r <reserved_blocks>
    Reserve blocks percentage for root (0-50)

-s <sector_size>
    Set sector size

-t
    Show current time in UTC

-T <trim>
    Pass TRIM to device

-u
    Make filesystem with userspace checkpoint

-U <uuid>
    Set filesystem UUID

-v
    Verbose mode

-V
    Print version

-z <compression_algo>
    Set compression algorithm

-z0
    Disable compression

DESCRIPTION

The mkfs.f2fs command formats a block device or file with the Flash-Friendly File System (F2FS), optimized for NAND flash storage like SSDs and eMMC. Developed by Samsung, F2FS uses a log-structured design with segment-based organization to minimize random writes, improve performance, and extend flash lifespan through features like adaptive logging, compression, and encryption support.

It supports advanced options for over-provisioning, inline data/xattrs, filesystem features (e.g., compression, quota), and TRIM for wear-leveling. Ideal for mobile devices and embedded systems, it handles hot/cold data separation and multi-head logging. Use with caution as it erases all data on the target. Requires kernel support (>=3.8) and f2fs-tools package. After formatting, mount with mount -t f2fs or add to /etc/fstab.

CAVEATS

Irreversibly wipes all data on device; requires root privileges. Not suitable for HDDs due to flash-specific optimizations. Kernel must support F2FS. Large devices may take time; use -f to skip prompts.

EXAMPLE

mkfs.f2fs -l myfs -O extra_attr,compr -o 10 /dev/sdb1
Formats /dev/sdb1 with label, extra attrs, compression, 10% overprovision.

FILESYSTEM FEATURES

Key -O features: encryption, blkzoned (ZNS SSDs), casefold (case-insensitive), quota_ino, projquota.

HISTORY

F2FS developed by Samsung Electronics, announced December 2012. Merged into Linux kernel 3.8 (Feb 2013). mkfs.f2fs introduced in f2fs-tools 1.0 (2013), with ongoing enhancements for features like compression (kernel 4.2+), encryption (4.1+), and verity (5.14+). Widely used in Android since 4.3.

SEE ALSO

mkfs(8), fsck.f2fs(8), mount(8), f2fs_io(8), dumpe2fs(8)

Copied to clipboard