Directory quotas

更新时间:
复制 MD 格式

You can use directory quotas and user quotas to limit the number of files, storage capacity, or resource usage within a directory in a General-purpose NAS file system. You can also set different resource quotas for multiple users under the same directory path.

Prerequisites

  • A General-purpose NAS file system has been created. For more information, see Create a file system.

  • A mount target has been added. For more information, see Add a mount target.

  • A permission group and its rules have been created. For more information, see Procedure.

  • The file system has been mounted and a directory has been created on it according to your mount scenario. For more information, see Mounting scenarios.

Quota types

Category

Quota type

Quota scope

  • Directory quota: Tracks the total file system usage of all users in a directory.

  • User quota: Tracks the file system usage of a specific user or group in a directory.

Note

User quotas are supported only on General-purpose NAS file systems that use the NFS protocol.

Restriction level

  • Statistical quota: Monitors and reports usage without enforcing limits.

  • Restrictive quota: Enforces limits. Operations such as creating files or directories and appending data fail if usage exceeds the quota.

Limitations

  • File system instances

    • General-purpose NAS file systems that use the NFS protocol support directory quotas and user quotas.

    • General-purpose NAS file systems that use the SMB protocol support directory quotas.

    • Extreme NAS file systems do not support directory quotas.

  • Quotas

    • You can set quotas for up to 500 directories on a single file system, with a maximum supported directory depth of 8 levels. For example, the root directory / is at level 0, /workspace is at level 1, and /workspace/dir1 is at level 2.

    • A single directory quota supports a maximum of 500 UID/GID combinations. Exceeding this limit may cause configuration failures or read errors.

    Important
    • If a restrictive quota is exceeded, write operations (including increasing file length, creating files or directories, and moving files into the directory) fail and the application layer receives an I/O error. For information about how to handle this issue, see Why am I getting a "Disk quota exceeded" error?

    • Because restrictive quotas can block write operations, test them thoroughly before applying them to production systems.

    • After a directory quota is created, its status is Initializing. The initialization can take several hours, depending on the number of files and directories in the file system. After the process is complete, the status changes to Running. You can check the directory quota status in the NAS console or by calling the DescribeDirQuotas API operation.

    • NAS quota settings are applied asynchronously. Therefore, enabling or disabling a restrictive quota takes 5 to 15 minutes to take effect.

  • Regions

    • General-purpose NAS file systems that use the NFS protocol: All regions.

    • General-purpose NAS file systems that use the SMB protocol: All regions except China (Shenzhen) Finance.

Create a directory quota

  1. Log on to the NAS console.

  2. In the left-side navigation pane, choose File System > File System List.

  3. In the upper-left corner of the page, select the resource group and region where the target file system resides.

    image

  4. Find the target file system and click the file system ID or click Manage. On the Quota Management page, click Create Directory Quota.

  5. In the Create Directory Quota dialog box, specify the Directory Path.

    Important
    • You can set quotas only for existing directories in a General-purpose NAS file system. The Directory Path must be the absolute path within the General-purpose NAS file system, not the local path on a compute node, such as an ECS instance or a container.

    • Directory paths cannot contain Chinese characters.

    For example, a General-purpose NAS file system is mounted to the local path /mnt. In the file system, the root directory is /, a level-1 subdirectory is /dir0, and a level-2 subdirectory is /dir/subdir1. If you want to configure directory quotas for these directories, the directory paths are as follows:

    • Root directory: /

    • Level-1 subdirectory: /dir0

    • Level-2 subdirectory: /dir/subdir1

  6. Check the status of the directory quota.

    After the directory quota is created, its status is Initializing until the initialization is complete, at which point the status changes to Running. A default statistical user quota for All Users is also created. You can change its quota type, but not its user type.

Add a user quota

When a user quota is set to statistical, it tracks the usage and file count for a user or group within the directory. When set to restrictive, it limits the storage capacity and file count for that user or group.

Note
  • User quotas are supported only on General-purpose NAS file systems that use the NFS protocol.

  • For each directory, you can set only one user quota per user or group.

Procedure

In the Quota Management section, find the target directory path and click Manage Quotas. In the panel that appears, click Assign Quota to User and configure the parameters in the dialog box. In the Assign Quota to User dialog box, the File System ID and Directory Path fields are read-only. Configure the other parameters as required.

Parameter

Required

Description

User Type

Yes

The type of user ID. Valid values: Uid, Gid, and All Users. These values correspond to a user, a user group, and all users, respectively. You can set different quotas for multiple users under the same path.

ID

No

This parameter is required when User Type is set to Uid or Gid. It specifies the user or user group to which the quota applies.

Examples:

  • To restrict the user with Uid=500, the user type is Uid, and the ID is 500.

  • To restrict the user group with Gid=100, the user type is Gid, and the ID is 100.

Quota Type

Yes

  • Statistical: Only tracks file system usage in the specified directory path.

  • Restrictive: In addition to tracking and displaying usage, I/O operations fail if the quota is exceeded.

Capacity Limit (GiB)

No

This parameter is required when Quota Type is set to Restrictive. It specifies the maximum storage capacity for the files and directories owned by the user in the specified directory path.

Note
  • The value must be between 0 GiB and 10,000,000 GiB.

  • You must specify the capacity limit or the file count limit.

File Limit

No

This parameter is required when Quota Type is set to Restrictive. It specifies the maximum number of files and directories that the user can own in the specified directory path.

Note
  • You must specify a capacity limit or a file count limit.

  • The minimum value is 1 and the maximum value is 1,000,000,000.

Delete a user quota

In the user quota list, find the target quota entry and click Delete.

Important

When you delete a directory that has a quota configured, NAS also deletes the corresponding directory quota and user quota entries.

Edit a user quota

In the user quota list, find the target quota entry and click Edit. You can edit the quota type, capacity limit, and file count limit.

Note

You can modify the capacity limit and file count limit only for restrictive quotas.

API reference

The following API operations are available for quota management:

FAQ

Why am I getting a "Disk quota exceeded" error?

  • Cause

    The storage usage or file count in the target directory has exceeded the restrictive quota limit. As a result, write operations fail, and an error message such as Disk quota exceeded is returned. These operations include increasing file length, creating files or directories, and moving files into the directory.

  • Solution

    1. To resolve this, free up space by deleting data or increase the capacity limit for the directory. For more information, see Edit a user quota.

    2. After freeing up space, perform a test write operation on the affected directory, such as creating and writing data to a test file. This triggers an asynchronous refresh of the quota cache. After you confirm that the test write operation is successful, you can restart your services.