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.

3
  • I am not sure you should aim only at minimizing reserved space. Disk (even SSD) are cheap. You can afford losing 5% or 10% of it. Performance is often more important. Commented Jun 18, 2017 at 4:50
  • Also, why do you create such a small volume? Why can't you put this 4Gb file tree in some larger file system? Commented Jun 18, 2017 at 4:56
  • @BasileStarynkevitch: it's an encrypted volume, and the goal is to be able to upload it as quickly as possible to the cloud. Commented Jun 19, 2017 at 0:56

1 Answer 1

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 
2
  • 1
    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. Commented Feb 11, 2021 at 20:12
  • It should be added that 1% can already be several GB on a large partition which makes the reserved space likely much bigger than needed. Commented Apr 21, 2024 at 8:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.