Difference between revisions of "F2FS"

From ArchWiki
Jump to: navigation, search
(F2FS is a file system not a partition)
(Added instructions to use f2fs as root fs)
(2 intermediate revisions by the same user not shown)
Line 31: Line 31:
 
When the filesystem is unmounted, it can be grown if the partition is expanded. [https://www.mail-archive.com/linux-f2fs-devel@lists.sourceforge.net/msg04247.html Shrinking is not currently supported].
 
When the filesystem is unmounted, it can be grown if the partition is expanded. [https://www.mail-archive.com/linux-f2fs-devel@lists.sourceforge.net/msg04247.html Shrinking is not currently supported].
  
First use a [[Partitioning#Partitioning_tools|partition tool]] to resize the partition. This can be done, for example, by deleting the old partition and creating a new one with with the same type, the same start sector, and a new end position.
+
First use a [[Partitioning#Partitioning_tools|partition tool]] to resize the partition: for example, suppose the output of the {{ic|print}} command in the {{ic|parted}} console for your disk is the following:
  
Then expand the filesystem to fill the new partition using:
+
    Number  Start  End    Size        File system    Name                  Flag
 +
    1      1049kB  106MB  105MB      fat32          EFI system partition  boot, esp
 +
    2      106MB  11,0GB  10,9GB      ext4
 +
    3      11,0GB  12,3GB  1322MB      f2fs
 +
    4      31,0GB  31,3GB  261MB      ext4
 +
 
 +
To resize the {{ic|f2fs}} partition to occupy all the space up to the fourth one, just give {{ic|resizepart 3 31GB}} and {{ic|exit}}. You can now expand the filesystem to fill the new partition using:
  
 
  # resize.f2fs /dev/sdxY
 
  # resize.f2fs /dev/sdxY
Line 44: Line 50:
  
 
Checking and repairs to f2fs file systems are accomplished with {{ic|fsck.f2fs}} provided by {{pkg|f2fs-tools}}. See {{man|8|fsck.f2fs}} for available switches.
 
Checking and repairs to f2fs file systems are accomplished with {{ic|fsck.f2fs}} provided by {{pkg|f2fs-tools}}. See {{man|8|fsck.f2fs}} for available switches.
 +
 +
== Using F2FS for root partition ==
 +
 +
Support for F2FS filesystem has been added in [[Grub|GNU Grub]] 2.03. At the moment (november 2018) ArchLinux ships version 2.02 so if you want to use F2FS as root partition file system you will need to install the bootloader on a separate {{ic|/boot}} partition, formatted in a compatible file system.
 +
 +
In the case you have compiled and installed GRUB 2.03, make sure to have {{ic|rw}} option instead of {{ic|ro}} in your boot kernel parameters.
  
 
== Troubleshooting ==
 
== Troubleshooting ==

Revision as of 13:48, 6 November 2018

F2FS (Flash-Friendly File System) is a file system intended for NAND-based flash memory equipped with Flash Transition Layer. Unlike JFFS or UBIFS it relies on FTL to handle write distribution. It is supported from kernel 3.8 onwards.

Creating a F2FS file system

In order to create a F2FS file system, install f2fs-tools.

Create the file system:

# mkfs.f2fs -l mylabel /dev/sdxY

where /dev/sdxY is the target volume to format in F2FS. See mkfs.f2fs(8) for all available options.

Mounting a F2FS file system

The file system can then be mounted manually or via other mechanisms:

# mount /dev/sdxY /mnt/foo

Grow an F2FS file system

When the filesystem is unmounted, it can be grown if the partition is expanded. Shrinking is not currently supported.

First use a partition tool to resize the partition: for example, suppose the output of the print command in the parted console for your disk is the following:

   Number  Start   End     Size        File system     Name                  Flag
    1      1049kB  106MB   105MB       fat32           EFI system partition  boot, esp
    2      106MB   11,0GB  10,9GB      ext4
    3      11,0GB  12,3GB  1322MB      f2fs
    4      31,0GB  31,3GB  261MB       ext4

To resize the f2fs partition to occupy all the space up to the fourth one, just give resizepart 3 31GB and exit. You can now expand the filesystem to fill the new partition using:

# resize.f2fs /dev/sdxY

where /dev/sdxY is the target F2FS volume to grow. See resize.f2fs(8) for supported options.

Note: If you're using GPT, the partition's GUID (seen in /dev/disk/by-partuuid/) might change, but the filesystem UUID (seen in /dev/disk/by-uuid/) should stay the same.

Checking and repair

Checking and repairs to f2fs file systems are accomplished with fsck.f2fs provided by f2fs-tools. See fsck.f2fs(8) for available switches.

Using F2FS for root partition

Support for F2FS filesystem has been added in GNU Grub 2.03. At the moment (november 2018) ArchLinux ships version 2.02 so if you want to use F2FS as root partition file system you will need to install the bootloader on a separate /boot partition, formatted in a compatible file system.

In the case you have compiled and installed GRUB 2.03, make sure to have rw option instead of ro in your boot kernel parameters.

Troubleshooting

GRUB with root on F2FS

When using GRUB your freshly installed system might not boot after reboot. As GRUB does not support F2FS it is not able to extract the UUID of your drive so it uses classic non-persistent /dev/sdXx names instead. In this case you might have to manually edit /boot/grub/grub.cfg and replace root=/dev/sdXx with root=UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. You can use the blkid command to get the UUID of your device, see Persistent block device naming.