Configuration and usage of rquota daemon in NFS on AIX

Configuring rquotad daemon on AIX

This article explains how to set up rquota daemon in the Network File System (NFS) environment on AIX® machines. The article also provides side-by-side hints to Linux® users on how to configure rquota daemon on Linux boxes.

Abhidnya P. Chirmule (achirmul@in.ibm.com), System Software Engineer, WSO2 Inc

author photoAbhidnya Chirmule works as a System Software Engineer for the Network File System Team at the IBM Software Labs in Pune, India on Open Network Computing technologies such as RPC and NFS on the AIX platform. Abhidnya holds a bachelor's degree in computer engineering from the College of Engineering, Pune, India.



Avinesh Kumar (avinesh.kumar@in.ibm.com), System Software Engineer, EMC

Photo of Avinesh KumarAvinesh Kumar works as a System Software Engineer for the Andrew File System Team at the IBM Software Labs in Pune, India. He works with kernel- and user-level debugging of dumps and crashes, as well as reported bugs on the Linux, AIX, and Solaris platforms. Avinesh has an MCA from the Department of Computer Science at the University of Pune. He is a Linux enthusiast who spends his spare time exploring the Linux kernel on his Fedora Core 6 box.


developerWorks Contributing author
        level

10 February 2009

Also available in Chinese

For a UNIX® systems administrator, setting up a disk quota is an important task to control disk space usage. Like the local file system, setting up disk quotas for the Network File System (NFS) is important. This article explains a step-by-step method of setting disk quotas in NFS. Apart from keeping track of disk usage, the quota system empowers systems administrators to specify a soft limit of disk usage for any user or group. When a user crosses the soft limit, he may get warned and after some grace period, as configured, the soft limit will be enforced as a hard limit.

rpc.rquotad daemon is one of the components of the NFS server that provides quota information of the local file system, which is exported to the remote user. So whenever an NFS client tries the quota command on an NFS mounted filesystem, it contacts the rpc.rquotad daemon running on the NFS server and displays the disk quota information for the remote filesystem.

The overall process of configuring disk quota for remote filesystems can be partitioned as follows:

  • Have a filesystem-supporting quota mechanism
  • Have the filesystem use the quota feature, pass the quota options while mounting the filesystem
  • Specify user as well as group Quota Limits Classes for the filesystem
  • Associate user IDs to Quota Limits Classes
  • Make sure that all NFS daemons are running fine along with the rpc.rquotad daemon

In AIX, you need to define Quota Limits Classes and associate the classes to a specific user or group ID to have the quota rule effective for that particular user or group. However, in Linux, you can directly specify quota rules for a specific user or group.

Start by configuring disk quota on an NFS server.

NFS server node

For illustration purposes, you will create a filesystem and configure it so that when it gets mounted, the quota mechanism of the filesystem gets activated.

Creating a filesystem

Here, using SMIT on an AIX machine, you will create a filesystem of type JFS2 and mount it at /j2quota_test. SMIT lets you enable quota management while creating the filesystem. However, for illustration purposes, you will create a filesystem using the crfs command and enable quota attributes in the next step. The following listing shows the commands to create a filesystem and the record of the new filesystem's entry in the /etc/filesystems file once it is successfully created.

# crfs -v jfs2 -g rootvg -a size=1000 -m /j2quota_test -A yes -p rw -a agblksize=4096
File system created successfully.
65328 kilobytes total disk space.
New File System size is 131072

# mount | grep j2quota_test
         /dev/fslv06      /j2quota_test    jfs2   Mar 08 08:25 rw,log=/dev/hd8

# grep -p j2quota_test /etc/filesystems
/j2quota_test:                                                           
        dev             = /dev/fslv06                                    
        vfs             = jfs2                                           
        log             = /dev/hd8
        mount           = true                                          
        options         = rw                                             
        account         = false

Creating a filesystem and enabling quota mechanisms on Linux

The mkfs command is used to create filesystems on Linux. This newly created filesystem should be mounted with 'usrquota' and 'grpquota' options. The mount command normally ignores these options but certain other quota utilities make use of them. To turn on the quota feature of the filesystem, two files, aquota.user and aquota.group, should be created at the top level of the filesystem with permissions 600 and root as the owner. The next step is to initialize the quota system. Run quotacheck -vgum against the filesystem. To start the quota feature, run the quotaon -av command. To know more about the commands and their options, refer to their respective manual pages.

Set JFS2 disk quotas

Newly created filesystems need to be enabled for handling quotas. If a quota is already enabled for the filesystem, this step can be skipped. To change the attributes of the newly created filesystem, use the chfs command so that the quota mechanism will be enabled for it. It is important to note that this will just enable quota mechanisms for the specified filesystem and it will not set the actual quota limits.

# chfs -a quota=userquota,groupquota /j2quota_test                       
*** Checking user and group quotas for /dev/fslv06 (/j2quota_test)       

# grep -p j2quota_test /etc/filesystems                                  
/j2quota_test:                                                           
        dev             = /dev/fslv06                                    
        vfs             = jfs2                                           
        log             = /dev/hd8
        mount           = true                                          
        options         = rw                                             
        account         = false                                          
        quota           = userquota,groupquota

Setting user quotas for the filesystem

To set the actual user quota limit for the /j2quota_test filesystem on the NFS server, use the j2edlimit command. This command manages the Quota Limits Classes for JFS2 filesystems and creates a temporary file that contains the current Limits Classes filesystem, then invokes the vi editor (or the editor specified by the EDITOR environment variable) on the temporary file so that the Limits Classes can be added and modified. When the editor is exited, the command reads the temporary file and modifies the binary quota files to reflect any changes. You need to specify values for Limits Classes, as shown below. Here Block Soft Limit and Block Hard Limit are specified as 1m (1 megabyte) and 2m (2 megabytes), respectively. These are just example values; administrators can specify values according to their own requirements.

#  j2edlimit -e -u /j2quota_test                                          
-------------------------------------- <-- File will be opened in editor.
                           
User Limits Classes for file system /j2quota_test                        
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.                                  
Prepend '-' to ID to delete Limits Class.                                
Use '+' for ID to add new Limits Class.                                  
                                                                        
       Block Limits                File Limits           Grace Period    
ID     soft         hard           soft      hard        block    file   
                                                                        
0      0            0              0         0           0        0      
+ 1m 2m 0 0 0 0  <--*(Additional Setting for User quota.)

:wq  <--*(Save edit)                                                     
------------------------------------------------ 
User Limits Classes for file system /j2quota_test
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      1m           2m             0         0           0        0

Listing user quotas for the filesystem

Now check if the setting of the user quota worked as desired.

# j2edlimit -l -u /j2quota_test                                          
User Limits Classes for file system /j2quota_test                        
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      1m           2m             0         0           0        0

Specifying user and group quota values in Linux

The edquota command invokes the quota editor. By specifying command-line switches -u or -g, the quota limits can be specified for a particular user or group, respectively. To know more about this command and its usage, refer to the manual pages.

Setting group quotas for the filesystem

Similarly, you set actual group quota limits using the same command. Here, add one Quota Limit Class specifying some example values for Block Soft Limit and Block Hard Limit as 4m (4 megabytes) and 5m (5 megabytes), respectively.

#  j2edlimit -e -g /j2quota_test                                          
--------------------------------------------------- <-- File will be opened in editor.
Group Limits Classes for file system /j2quota_test
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.                                  
Prepend '-' to ID to delete Limits Class.                                
Use '+' for ID to add new Limits Class.                                  
                                                                        
       Block Limits                File Limits           Grace Period    
ID     soft         hard           soft      hard        block    file   
                                                                        
0      0            0              0         0           0        0      
+ 4m 5m 0 0 0 0 <--*(Additional Setting for Group quota.)                

:wq  <--*(Save edit)
--------------------------------------------------                       
Group Limits Classes for file system /j2quota_test                       
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      4m           5m             0         0           0        0

Listing group quotas for the filesystem

The following listing shows the group quota values for the filesystem, as set up in the previous step.

# j2edlimit -l -g /j2quota_test                                           
Group Limits Classes for file system /j2quota_test                       
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      4m           5m             0         0           0        0

Associating a user with a specific quota Limit Class

Now associate the Quota Limit Class just created for the /j2quota_test filesystem, to a user user01 on the NFS server. The j2edlimit command is used to associate a Quota Limit Class to a user or group. The following command listing associates the Quota Limit Class 1 to the user user01, as specified using command-line switches -a and -u.

# j2edlimit -a 1 -u user01 /j2quota_test                                 
User Limits Classes for file system /j2quota_test                        
Block Limits units: g=gigabyte, m=megabyte, or optional k=kilobyte       
Grace Period units: d=days, h=hours, m=minutes, or s=seconds             
                                                                        
       Block Limits                File Limits           Grace Period    
ID     soft         hard           soft      hard        block    file   
                                                                        
1      1m           2m             0         0           0        0

Similarly, associate the Quota Limit Class 1 to the group staff with the help of command-line switch -g.

# j2edlimit -a 1 -g staff /j2quota_test                                   
Group Limits Classes for file system /j2quota_test                       
Block Limits units: g=gigabyte, m=megabyte, or optional k=kilobyte       
Grace Period units: d=days, h=hours, m=minutes, or s=seconds             
                                                                        
       Block Limits                File Limits           Grace Period    
ID     soft         hard           soft      hard        block    file   
                                                                        
1      4m           5m             0         0           0        0

Now it is time to verify the actual assigned quota. Have a test file created by user01 and verify the quota values with the quota command as follows on the local node (the NFS server).

Checking disk quotas for a user

Create a directory for the user and give him the necessary permissions.

# mkdir /j2quota_test/user01                                             
# chown -R user01:staff /j2quota_test/user01                             
# ls -ld /j2quota_test
drwxr-xr-x    4 root     system          256 Mar 08 08:40 /j2quota_test
# ls -ld /j2quota_test/user01
drwxr-xr-x    2 user01   staff           256 Mar 08 08:40 /j2quota_test/user01

Now let user01 create a small file in his area, /j2quota_test/user01.

$ cd /j2quota_test/user01                                                
$ echo 111 > test_user01.txt                                              
$ exit

Run the following to ensure that the quota values changed correctly.

# quota -u user01                                                               
Disk quotas for user user01 (uid 210):                                   
    Filesystem  blocks  quota  limit  grace  files  quota  limit  grace  
 /j2quota_test       4   1024   2048             2      0      0         
# quota -g                                                               
Disk quotas for group staff (gid 1):                                     
    Filesystem  blocks  quota  limit  grace  files  quota  limit  grace  
 /j2quota_test       4   4096   5120             1      0      0

Exporting the filesystem for the NFS client

After creating the filesystem, enabling the quota system, and associating the Quota Limit Class to a particular user and group, you are ready to export the filesystem to all NFS clients. You should understand that just exporting quota-enabled filesystems to NFS clients will not ensure availability of quota information on the NFS client side (but the quota restrictions would be applicable). You need to ensure that the rpc.rquotad daemon is running on the NFS server. The following command listing exports the filesystem through NFS.

# /usr/sbin/mknfsexp -d /j2quota_test -S sys,krb5p,krb5i,krb5,dh -t rw
                                                                        
# exportfs                                                       
/j2quota_test           -sec=sys:krb5p:krb5i:krb5:dh,rw

Ensuring that the rpc.rquotad daemon is running

Once the NFS client mounts the exported filesystem from the NFS server, the quota assigned for that filesystem becomes available to the NFS client. You can view quota information from the NFS client for mounted filesystems using the quota command. This command makes an RPC call to the rpc.rquotad daemon running on the NFS server. So, it is very important to ensure that the rpc.rquotad daemon is running on the NFS server before allowing any NFS client access. The rpc.rquotad daemon registers itself with the portmapper daemon. The rpc.rquotad service is started by the inetd daemon, which reads its configuration file /etc/inetd.conf. So, it will trigger rpc.rquotad, depending on whether there is an uncommented entry for this service in the /etc/inetd.conf file. The inetd daemon starts automatically each time the system starts. If the entry for rpc.rquotad is commented in /etc/inetd.conf, you need to uncomment it so that it gets started automatically. The following listing shows how to check if the rpc.routad daemon is running.

# rpcinfo -p | grep rquotad
    100011    1   udp  32930  rquotad

Running rpc.rquotad daemon on Linux

The startup /etc/init.d/quotarpc script checks for the quota option being passed as mount options in the /etc/fstab file and accordingly starts the rpc.rquotad daemon. If the filesystem is mounted by issuing the mount command directly on the shell prompt, you need to run the sudo rpc.rquotad.

This ensures that rpc.rquotad is running. If rpc.rquotad is not running, make sure you have an uncommented entry for rquotad in the /etc/inetd.conf file so that the next time the machine boots, the rquotad daemon starts automatically. The other way to start rpc.rquotad without a system reboot is to make it reread the /etc/inetd.conf configuration file after making changes to it. Use the following commands:

#  refresh -s inetd

or

#  kill -1 <PID of inetd daemon>

The following listing shows the entry for rquotad in the /etc/inetd.conf file.

#  cat /etc/inetd.conf | grep rquota
rquotad  sunrpc_udp     udp     wait    root    /usr/sbin/rpc.rquotad rquotad 100011 1

Now you are ready with all NFS server-side settings and can proceed with NFS client-side steps.


At NFS client node

Mount the exported filesystem at /j2quota_test_nfs_client, as shown as follows.

Mounting the NFS server

# mkdir /j2quota_test_nfs_client                                          
# mount nfs_server:/j2quota_test /j2_test_nfs_client

The mount command shows that you have successfully mounted the NFS filesystem.

# mount | grep j2quota_test_nfs_client
nfs_server /j2quota_test    /j2quota_test_nfs_client nfs3   Mar 08 21:09

Verifying quota configuration from the NFS client

Create user user01 with the same user and group IDs as on the NFS server. Let user01 logon to the client and run quota -u to check if user quota is available to the NFS client. Note that the rpc.rquotad protocol does not support group quotas for NFS. So, it does not return group quota information for NFS.

$ cd /j2quota_test_nfs_client
$ id                                                                     
uid=210(user01) gid=1(staff)                                             
$ quota -u 
Disk quotas for user user01 (uid 210):
 Filesystem            blocks   quota  limit  grace files  quota  limit grace
/j2quota_test_nfs_client  4     1024   2048           2      0       0

Resources

Learn

Get products and technologies

  • Download IBM product evaluation versions and get your hands on application development tools and middleware products from DB2®, Lotus®, Rational®, Tivoli®, and WebSphere®.

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into AIX and Unix on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=AIX and UNIX
ArticleID=368779
ArticleTitle=Configuration and usage of rquota daemon in NFS on AIX
publish-date=02102009