Sunday, August 1, 2010

Setting Up and Using JFS2 Filesystem Quotas

Technote (FAQ)

Question
How do I set up and manage quotas on a JFS2 filesystem?



Answer
Enable quotas on an existing JFS2 filesystem, or create a new filesystem with quotas enabled.
1. To change an existing filesystem:
# chfs -a quota=userquota /myfs
The other option is quota=groupquota, or both can be added

2. mount the filesystem
# mount /myfs

3. Make sure it mounted with quotas enabled:
# lsfs -q /myfs
Name Nodename Mount Pt VFS Size Options Auto Accounting
/dev/fslv02 -- /myfs jfs2 2097152 rw no no
(lv size: 2097152, fs size: 2097152, block size: 4096, sparse files: yes, inline log: no, inline log size: 0, EAformat: v1, Quota: userquota, DMAPI: no, VIX: no)

Set up a new class of quotas for a user

# j2edlimit -e /myfs

This will load the current quota class into a 'vi' editor session:

User Limits Classes for file system /myfs
Block Limits units: g=gigabyte, m=megabyte, or optional k=kilobyte
Grace Period units: d=days, h=hours, m=minutes, or s=seconds
Limits Class ID 0 is the default class.

Block Limits File Limits Grace Period
ID soft hard soft hard block file

0 0 0 0 0 0 0

Add a new class by creating a new line, using ID=+ and setting your limits:

+ 1g 2g 12000 15000 7d 7d

Save the file using :wq or ZZ.

The command should assign ID 1 to your new class, and list it out for you after the vi session. You can also list it using:

# j2edlimit -l /myfs
User Limits Classes for file system /myfs
Block Limits units: g=gigabyte, m=megabyte, or optional k=kilobyte
Grace Period units: d=days, h=hours, m=minutes, or s=seconds
Limits Class ID 0 is the default class.

Block Limits File Limits Grace Period
ID soft hard soft hard block file

0 0 0 0 0 0 0
1 1g 2g 12000 15000 7d 7d


Assign a user to your new limits class

# j2edlimit -a 1 -u bob /myfs
Where: 1 is the ID of the class you wish to assign
bob is the username

To report on a user's quota usage in a filesystem

# repquota /myfs
Block limits File limits
Group used soft hard grace used soft hard grace
system -- 64 0 0 4 0 0
staff -- 18756 0 0 1 0 0

Block limits File limits
User used soft hard grace used soft hard grace
root -- 32 0 0 4 0 0
bob -- 18756 1048576 2097152 1 12000 15000


To remove a user from a particular class

Reassign that user to class 0, which is unlimited.

# j2edlimit -a 0 bob /myfs
User Limits Classes for file system /myfs
Block Limits units: g=gigabyte, m=megabyte, or optional k=kilobyte
Grace Period units: d=days, h=hours, m=minutes, or s=seconds
Limits Class ID 0 is the default class.

Block Limits File Limits Grace Period
ID soft hard soft hard block file

0 0 0 0 0 0 0

No comments: