2

I'm creating a small (~4GB) ext4 volume to store mostly text documents, and no files larger than ~200 MB. I estimate the total number of files won't exceed 150,000 (I know because I'm migrating data from a comparable NTFS volume).

What parameters should I pass to mkfs.ext4 in order to minimize the reserved space? I've read that -m 0 is not recommended, but this will be a data volume stored on SSDs (so fragmentation isn't an issue), not a system partition.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

1 Answers1

1

The main reason to have reserved space is to allow root to use the mounted filesystem if it becomes filled by an user. Normal users could not write to the reserved space. However, erasing a file (make a copy to some other filesystem) will immediately provide some usable space.

It may become quite difficult even for root to erase a file if there is no free space. I strongly suggest to keep at least a 1% (but never less than 10 megabytes) of free space.

The command should look similar to:

mkfs.ext4 -Eroot_owner=0:0,discard -m1

Probably executed as root. In any case, make sure the correct high-privileges user is set as the root_owner (may default to the user who creates the filesystem).

If you are absolutely sure that you will never make more than 150,000 files, you can also set the number of inodes (if free space is really that important, I would suggest to not use this option):

mkfs.ext4 -Eroot_owner=0:0,discard -m1 -N200000 /dev/sdZ2
  • Note that already existing filesystem can be reconfigured with tune2fs. It also supports option -r where you can set reserved blocks as absolute block count instead of dealing with percentages. – Mikko Rantalainen Feb 11 '21 at 20:12