Everything you wanted to know about DISKINODES for ploop but were afraid to ask.
With simfs layout, vzquota is used to set limits for DISKSPACE and DISKINODES, so these limits can be changed any time.
Unlike simfs, ploop contains a real file system, so amount of disk space and disk inodes are properties of the file system, determined while creating a filesystem. It is possible to resize an ext4 file system in terms of disk space, but there's no way to change the number of available inodes.
|Note: There is no way to change DISKINODES for existing ploop. This is a limitation of ext4.|
In other words,
vzctl set --diskinodes is ignored for ploop layout.
By default, ext4 allocates 1 (one) inode per each 16 KB of data; this is practically the same as to assume that the average file size will be 16KB.
For example, when creating a ploop with 40GB of disk space, 2621440 inodes will be available:
If the above default is too low for your usage (for example, a container has or will have too many small files), you can specify a larger value for DISKINODES during container creation or conversion only. The feature works since vzctl 4.7.
|Note: You can only specify |
The way it works is the following. First, a file system big enough to accommodate the requested number of DISKINODES is created, and then ploop resize is performed to downsize the file system to meet the requested amount of DISKSPACE.
vzctl create 123 --diskspace 40G --diskinodes 5242880
Here, a filesystem big enough to have 5242880 of diskinodes will be created (it's 5242880 * 16K = 80G), then downsized to 40G.
Too high DISKINODES value
Sometimes, when the amount of DISKINODES specified is too high, a very large filesystem is created, and it can not be downsized to a specified amount. In this case, the following error will be shown when converting a container from simfs to ploop:
vzctl set CTID --diskspace 40G --diskinodes 1000000000 --save ... vzctl convert CTID ... Error in ploop_resize_image (ploop.c:2477): Unable to change image size to 83877888 sectors, minimal size is 502423144 Unmounting file system at /vz/private/101.ploop/root.hdd/root.hdd.mnt Unmounting device /dev/ploop37776 Failed to resize image: Error in ploop_resize_image (ploop.c:2477): Unable to change image size to 83877888 sectors, minimal size is 502423144 
In this case, 1G inodes requirement leads to creation of 16TB filesystem (remember, 1 inode per 16K). Unfortunately, such huge FS can't be downsized to as low as 40G, the minimum seems to be around 240G (values printed in the error message are in sectors which are 512 bytes each).
Solution 1: please be reasonable when requesting diskinodes for ploop.
Solution 2: please set DISKINODES to 0 before conversion:
vzctl stop CTID vzctl set CTID --diskspace xxxG--diskinodes 0 --save vzctl convert CTID
This will lead to creating a filesystem with default number of inodes.
Too low DISKINODES value
If DISKINODES specified during
lower than the default (1 inode per 16K of disk space), it is silently ignored.
In other words, there is no way to limit DISKINODES to lower than DISKSPACE / 16384.