Contents
F2FS is a FileSystem for Linux optimized for Flash storage. It was originally introduced in kernel v3.8, on 2012-12-20.
F2FS is popular on portable devices such as smartphones and tablets and uncommon on desktops and servers.
For more information about it, follow the links in the See Also section.
Things you need to know
F2FS is a log-structured file system and it has been designed with the characteristics of storage devices that use NAND flash memory, like Secure Digital (SD) and eMMC drives.
F2FS supports:
- Transparent file compression using LZO, LZ4 and zstd
- File-based encryption
- Online defragmentation
- TRIM
- Atomic operations and recovery from power loss or crash
Status
F2FS is available in Buster, Testing and Unstable
Usage
Enabling compression
To create a compressed FS, f2fs-tools at version >= 1.14.0-1 is required
1 dev=/dev/CHANGEME
2 mnt=/mnt/CHANGEME
3 # Enable compression on FS creation
4 sudo mkfs.f2fs -f -O extra_attr,compression $dev
5 # (or enable encryption and compression)
6 # sudo mkfs.f2fs -f -O encrypt,extra_attr,compression $dev
7
8 # Also at mount time
9 sudo mount -o compress_algorithm=zstd $dev $mnt
10
11 ## Compression demo ##
12 # create a directory and enable compression on it
13 sudo mkdir $mnt/comp
14 sudo chattr -R -V +c $mnt/comp
15
16 # Write a compression-friendly file
17 sudo cp /etc/dictionaries-common/words $mnt/comp
18 # du shows the uncompressed size
19 du -h $mnt/comp/words
20 # notice: df might be misleading
21 # Show F2FS status:
22 sudo cat /sys/kernel/debug/f2fs/status
See also
Wikipedia's article about F2FS
WikiPedia: F2FSManual pages: mkfs.f2fs(8)
CategoryKernel | ?CategoryFileSystem | CategorySystemAdministration