By default, the ext4 file system contains constraints. You are not allowed to create hard links across project quotas. However, in practice certain scenarios will require the creation of hard links. Alibaba Cloud Linux 2 provides a custom interface that can bypass the constraints of the ext4 file system to create hard links across project quotas. This topic describes the interface for the function and the sample interface.
Linux distributions support the following disk quota modes: user quota, group quota, and project quota. Compared with user quota and group quota, project quota provides a more fine-grained disk quota. Project quota identifies directories and files within the file system by project ID. This topic describes how to create a hard link across project ID directories in the ext4 file system.
The default value of the /proc/sys/fs/hardlink_cross_projid interface is 0. In this case, hard links cannot be created across project quotas. If the /proc/sys/fs/hardlink_cross_projid interface is set to 1, you can bypass the constraints of the ext4 file system to create hard links across project quotas.
For more information about the interface, see
Documentation/sysctl/fs.txt. You can obtain the kernel document from the Debuginfo package and the source code
package provided by Alibaba Cloud Linux 2. For more information, see Use Alibaba Cloud Linux 2.
A value of
0is returned, indicating that hard links cannot be created across project quotas.
echo 1 > /proc/sys/fs/hardlink_cross_projid