By default, ext4 file systems forbid creating hard links between directories that belong to different project IDs. Alibaba Cloud Linux 2 and Alibaba Cloud Linux 3 provide the /proc/sys/fs/hardlink_cross_projid kernel parameter to bypass this restriction, allowing hard links across project quota boundaries.
How project quotas work
Linux distributions support three types of disk quota: user quota, group quota, and project quota. A project quota applies to all files and directories associated with a project, identified by a project ID. Unlike user or group quotas, a project quota can span multiple directories and files within a single file system, providing more fine-grained control over disk usage.
Supported environments
Alibaba Cloud Linux 2 or Alibaba Cloud Linux 3
ext4 file systems with project quotas configured
Parameter values
The /proc/sys/fs/hardlink_cross_projid parameter controls whether hard links can be created across project quota boundaries on ext4 file systems.
| Value | Behavior |
|---|---|
0 (default) | Hard links across project quotas are disabled |
1 | Hard links across project quotas are enabled |
For more information, see the Documentation/sysctl/fs.txt kernel document. You can get the kernel document from the Debuginfo package and the source code package of Alibaba Cloud Linux 2. For more information, see Use Alibaba Cloud Linux 2.
Enable hard links across project quotas
Step 1: Check the current value
Run the following command to check whether cross-project hard links are enabled:
cat /proc/sys/fs/hardlink_cross_projidExpected output:
0A value of 0 means hard links across project quotas are disabled.
Step 2: Enable cross-project hard links
Run the following command to enable hard links across project quotas:
echo 1 > /proc/sys/fs/hardlink_cross_projidNote: This change takes effect immediately but does not persist across reboots. To make the change persistent, add the following line to
/etc/sysctl.confor create a file in/etc/sysctl.d/:fs.hardlink_cross_projid = 1Then run
sysctl -pto apply the configuration.
Step 3: Verify the result
Run the following command to confirm the change:
cat /proc/sys/fs/hardlink_cross_projidExpected output:
1A value of 1 confirms that hard links across project quotas are now enabled on ext4 file systems.