All Products
Search
Document Center

Alibaba Cloud Linux:Create hard links across project quotas

Last Updated:Oct 13, 2023

By default, ext4 file systems have limits that forbid hard links to be created across project quotas. However, in practice, hard links need to be created across project quotas in specific scenarios. Alibaba Cloud Linux 2 and 3 provide a customized interface that can bypass the limits of ext4 file systems to create hard links across project quotas. This topic describes the interface and provides an example on how to use the interface.

Background information

Linux distributions support the following types of disk quota: user quota, group quota, and project quota. A project quota applies to all files or directories that are associated with a project. A project can include multiple directories and files within a file system. The directories and files are identified by the project ID. Project quotas provide more fine-grained restrictions on disk usage than user or group quotas. This topic describes the interface that allows you to create hard links across directories that have different project IDs within an ext4 file system.

Interface description

The default value of the /proc/sys/fs/hardlink_cross_projid interface is 0. This value specifies that hard links cannot be created across project quotas. If you set the /proc/sys/fs/hardlink_cross_projid interface to 1, you can bypass the limits of ext4 file systems to create hard links across project quotas.

For more information about the interface, see the Documentation/sysctl/fs.txt kernel document. You can obtain 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.

Example

You can run the following command to query the value of the /proc/sys/fs/hardlink_cross_projid interface:

cat /proc/sys/fs/hardlink_cross_projid

A value of 0 is returned, which specifies that hard links cannot be created across project quotas.

You can run the following command to change the value from 0 to 1. This way, you can create hard link across project quotas.

echo 1 > /proc/sys/fs/hardlink_cross_projid