Decoding Linux Disk Quota Output: Understanding Blocks, Limits, and Grace Periods in Backup Systems


2 views

When working with Linux backup servers, the quota command output follows this standardized format:

Disk quotas for user vps**** (uid 1234):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
/dev/mapper/backup3-backup3
                6094452  2147483648 2147483648          365672       0       0
Column Description Measurement Unit Example Interpretation
blocks Current disk usage 1KB blocks 6094452 blocks = ~6GB (6094452/1024/1024)
quota Soft limit threshold 1KB blocks 2147483648 blocks = 2TB
limit Hard limit maximum 1KB blocks 2147483648 blocks = 2TB
grace Time remaining for soft limit exceedance Days/Hours Blank means no grace period active

For the given output:

/dev/mapper/backup3-backup3
                6094452  2147483648 2147483648          365672       0       0

We can extract these key points:

  • Current usage: 6,094,452 blocks (~6GB) of storage
  • Soft limit (quota): 2,147,483,648 blocks (2TB)
  • Hard limit: Same as soft limit (2TB)
  • No grace period active (blank field)
  • 365,672 files currently stored
  • No file count limits (0 in quota/limit columns)

The user mentions expecting a 10GB quota. Here's how to verify:

# Convert expected quota to blocks
10GB = 10 * 1024 * 1024 = 10,485,760 blocks

# Compare with output:
2,147,483,648 (current quota) >> 10,485,760 (expected)

This suggests either:

  1. The quota hasn't been properly configured
  2. You're interpreting the units incorrectly
  3. The system administrator set different limits

Here's a Python script to parse and analyze quota output:

import re
import math

def parse_quota(output):
    pattern = r"(\d+)\s+(\d+)\s+(\d+)"
    match = re.search(pattern, output)
    
    if match:
        blocks = int(match.group(1))
        quota = int(match.group(2))
        limit = int(match.group(3))
        
        return {
            'blocks_used': blocks,
            'blocks_gb': blocks / (1024*1024),
            'quota_gb': quota / (1024*1024),
            'limit_gb': limit / (1024*1024),
            'percentage_used': (blocks/quota)*100 if quota > 0 else 0
        }
    return None

# Example usage:
output = """/dev/mapper/backup3-backup3
                6094452  2147483648 2147483648          365672       0       0"""

result = parse_quota(output)
print(f"Storage used: {result['blocks_gb']:.2f}GB of {result['quota_gb']:.2f}GB ({result['percentage_used']:.2f}%)")

For system administrators:

# Set user quota
sudo setquota -u username 10485760 11534336 0 0 /backup

# Check all quotas
sudo repquota -a

# Edit quota for user
sudo edquota -u username

Where the numbers represent (soft limit, hard limit) in blocks.


When working with Linux backup servers, understanding quota output is crucial for storage management. Let's break down what each column means in this typical quota report:

Disk quotas for user vps**** (uid 1234):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
/dev/mapper/backup3-backup3
                6094452  2147483648 2147483648          365672       0       0

Filesystem: The storage device where quotas are applied (/dev/mapper/backup3-backup3)

blocks: Current disk usage in 1KB blocks (6094452 blocks = ~6GB)

quota: Soft limit (2147483648 blocks = 2TB) - warning threshold

limit: Hard limit (2147483648 blocks = 2TB) - absolute maximum

grace: Time remaining before soft limit becomes hard limit (empty in this case)

files: Number of files owned (365672 files)

You mentioned your quota should be 10GB. The output shows much higher limits (2TB), which suggests either:

  1. Your host hasn't properly set your individual quota
  2. You're looking at system-wide defaults rather than user-specific limits

To check your actual quota settings, try:

sudo edquota -u vps****

Here's a bash script to monitor your quota and convert blocks to human-readable format:

#!/bin/bash
USER="vps****"
QUOTA_OUTPUT=$(quota -u $USER | awk '/mapper/ {print $1,$2,$3,$4,$5}')
read -r fs blocks quota limit grace <<< "$QUOTA_OUTPUT"

# Convert 1KB blocks to GB
used_gb=$(echo "scale=2; $blocks/1024/1024" | bc)
quota_gb=$(echo "scale=2; $quota/1024/1024" | bc)

echo "Usage: $used_gb GB of $quota_gb GB"
echo "Filesystem: $fs"
[ -n "$grace" ] && echo "Grace period: $grace"

The grace period appears when you exceed your soft limit (quota). The format is typically:

  • 6days (6 days remaining)
  • 23hours (23 hours remaining)
  • 59mins (59 minutes remaining)

If no grace period appears, it means you're either:

  1. Under your soft limit
  2. Have exceeded the hard limit (in which case you can't write more files)

If you believe your quota should be 10GB but see different values:

# Check if user-specific quotas are enabled
sudo repquota -a | grep vps****

# Verify quota files are properly set up
sudo quotacheck -avugm
sudo quotaon -avug

Remember that quota values are set in 1KB blocks, so 10GB would be 10485760 blocks (10*1024*1024).