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.

  • 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. – Basile Starynkevitch Jun 18 '17 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? – Basile Starynkevitch Jun 18 '17 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. – Dan Dascalescu Jun 19 '17 at 0:56

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.