Course contentsShow
← Linux
Lesson 306 of 1,8193. The Filesystem Hierarchy and POSIX StandardsFree lesson

Disk Quotas and Resource Management

Impose storage limits on users and groups to prevent partition exhaustion.

In this lesson, you will learn how to enforce storage limits on individual users and groups to ensure that no single account can exhaust your entire partition.

Preventing Partition Exhaustion

In a shared multi-user environment, a single user—whether by accident or malice—could potentially fill an entire filesystem by creating massive files or infinite logs. When a partition reaches 100% capacity, the system often becomes unstable, as critical processes fail to write their logs or temporary files. To prevent this, we use Disk Quotas.

Quotas allow an administrator to define strict boundaries on two primary metrics:

  1. Block Quotas: The total number of disk blocks (storage space) a user can occupy.
  2. Inode Quotas: The total number of files or directories a user can own.

Soft and Hard Limits

Quotas function using two specific thresholds:

  • Soft Limit: This is a warning threshold. If a user exceeds this, the system allows it temporarily, but sends a notification that they are nearing their limit.
  • Hard Limit: This is the absolute ceiling. The kernel will refuse any further write operations that would push the user beyond this limit, returning an "out of disk space" error even if the disk actually has free space available.

Implementation

To manage these, you typically interact with the filesystem’s underlying metadata tracking. For example, the edquota command allows you to set these limits per user:

# Edit quotas for a specific username
edquota -u username

When the editor opens, you specify the limits for your filesystem blocks and inodes. Once configured, the kernel monitors every file write request. If the write would cause the user to exceed their hard limit, the write is blocked at the filesystem level. This ensures that even if a user creates many small files (hitting the Inode limit) or one giant file (hitting the Block limit), the integrity of your partition remains protected.

By decoupling the physical disk size from the usable space available to a user, you ensure that the system remains functional for everyone.

Key Takeaway: Disk quotas protect system stability by enforcing hard and soft limits on blocks and inodes, preventing individual users from depleting shared storage resources.