F2FS File-System Adding Device Aliasing Feature For Nifty Uses

Written by Michael Larabel in Linux Storage on 4 November 2024 at 07:00 AM EST. 2 Comments
LINUX STORAGE
The Flash-Friendly File-System (F2FS) is adding a device aliasing file feature that could appear in the upcoming Linux v6.13 merge window.

Queued this past week into the F2FS file-system's Git development tree for the kernel driver in its "dev" branch is this new device aliasing feature.

F2FS device aliasing commit


Device aliasing files can be created using the mkfs.f2fs tool as a special file that could contain another file-system or similar. The pending documentation explains of the device aliasing file feature for F2FS:
f2fs can utilize a special file called a "device aliasing file." This file allows the entire storage device to be mapped with a single, large extent, not using the usual f2fs node structures. This mapped area is pinned and primarily intended for holding the space.

Essentially, this mechanism allows a portion of the f2fs area to be temporarily reserved and used by another filesystem or for different purposes. Once that external usage is complete, the device aliasing file can be deleted, releasing the reserved space back to F2FS for its own use.

use-case

# ls /dev/vd*
/dev/vdb (32GB) /dev/vdc (32GB)
# mkfs.ext4 /dev/vdc
# mkfs.f2fs -c /dev/[email protected] /dev/vdb
# mount /dev/vdb /mnt/f2fs
# ls -l /mnt/f2fs
vdc.file
# df -h
/dev/vdb 64G 33G 32G 52% /mnt/f2fs

# mount -o loop /dev/vdc /mnt/ext4
# df -h
/dev/vdb 64G 33G 32G 52% /mnt/f2fs
/dev/loop7 32G 24K 30G 1% /mnt/ext4
# umount /mnt/ext4

# f2fs_io getflags /mnt/f2fs/vdc.file
get a flag on /mnt/f2fs/vdc.file ret=0, flags=nocow(pinned),immutable
# f2fs_io setflags noimmutable /mnt/f2fs/vdc.file
get a flag on noimmutable ret=0, flags=800010
set a flag on /mnt/f2fs/vdc.file ret=0, flags=noimmutable
# rm /mnt/f2fs/vdc.file
# df -h
/dev/vdb 64G 753M 64G 2% /mnt/f2fs

So, the key idea is, user can do any file operations on /dev/vdc, and reclaim the space after the use, while the space is counted as /data. That doesn't require modifying partition size and filesystem format.

This F2FS device aliasing feature can currently be found in the f2fs.git dev branch and if all goes well could appear with the upcoming Linux 6.13 merge window.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week