2

I'm trying to find the best way to store lots of small files on a volume, without hitting the inode limits. I created a new drive with:

sudo mkfs.ext4 -N 100000000 /dev/device

and this correctly shows:

/dev/device  100040704 13929894 86110810   14% /mnt/websites2

However, it seems to have made a fair hit to the speed for read/writes on that drive. I was doing some research, and came across:

https://www.tecmint.com/increase-disk-inode-number-in-linux/

They suggest:

sudo mkfs.ext4 -T largefile /dev/device

What is the option for "small files"? I can't seem to find any documentation on what the values of -T can be? Also - any other suggestions on how to configure a drive for LOTS of small files (~3-10kb each), would be much appreciated!

Andrew Newby
  • 1,041
  • 1
  • 22
  • 48
  • You should strongly consider using a different filesystem, such as XFS. – Michael Hampton Sep 19 '20 at 16:32
  • @MichaelHampton thanks. What is the benefit of XFS? I'm afraid I'm not that knowledgable in the different types of filesystems – Andrew Newby Sep 20 '20 at 05:59
  • How many is "lots" of files, order of magnitude? What is the distribution of files sizes? How many IOPS is the workload? What are you comparing to where this is a "fair hit to the speed": what was the other configuration, and quantify what the difference is? – John Mahowald Sep 20 '20 at 16:05
  • @JohnMahowald there are about 150 million files. The main hit I saw was the CPU load jumping quite a lot. Originally I stored the HTML in the MySQL table, but then I had problems with the drive filling up (and I didn't want to keep upgrading the server spec to get more disk space). In terms of the setup - I split them into 5 layers. So "foobar.com" would be put in `/f/o/o/b/a/foobar.com.txt` – Andrew Newby Sep 21 '20 at 05:31

1 Answers1

1

For lots of small files it's better to use,
mkfs.ext4 -T news /dev/device

There is also mkfs.ext4 -T small /dev/device but this sets a small inode size.

The labels for -T in mkfs.ext4 can be found in /etc/mke2fs.conf. You can find more info using man mke2fs and man mke2fs.conf

Apparently you need a large inode number and a small bytes/inode ratio. You could make a new label in /etc/mke2fs.conf and try some configurations to get the optimal performance for your scenario.

Krackout
  • 1,559
  • 6
  • 17