Monday, August 29, 2016

Administering Disk Quotas

 Disk quotas are a valuable management tool when you’re administering a Linux system. The problem here is that, because Linux is a multiuser system, it’s possible for one or two users to completely monopolize all the disk space available in the file system. This is especially a problem in today’s networked world where users are downloading large music files and even larger movie files from the Internet. How do you keep these users from consuming more than their fair share of disk space? You use disk quotas. 
Put simply, disk quotas establish space limitations for users on the system. You can specify that users are each allowed only a certain amount of disk space or inodes (a quota). Users are not allowed to exceed this quota. 
To implement quotas on your Linux file system, you first need to install the quota package on your system. Some distributions, especially server distributions, install this package as part of the base installation. Most distributions, however, will require you to install it separately after the system has been set up. To see if quota is already installed on your system, enter rpm –qi quota at the shell prompt. If it isn’t installed, use rpm or another appropriate package management utility to install it. 
Once the package has been installed, complete the following to establish quotas: 
1. Open a terminal session and change to your root user account with su.
2. Configure your mounted file systems to use quotas by doing the following: 
a. Open your /etc/fstab file in a text editor.
b. Add the usrquota and grpquota (or usrjquota=aquota.user,grpjquota=aquota.grp,jqfmt=vfsv0) parameters to the mount options for the file system you want to establish quotas on. In the example that follows, quotas have been established for the / file system:

c. Save your changes to the file and exit the editor.

d. Restart your system so that the changes can take effect. 
3. After the system has rebooted, create your quota files by doing the following: 
a. Open a terminal session and switch to your root user account with su.
b. At the shell prompt, enter quotacheck –amvug. 

4. Enable quotas on your file system by entering quotaon –av at the shell prompt. 
5. View the current disk space used by your users by entering repquota –av at the shell prompt. A report is displayed on the screen showing how much space each user is consuming, as shown here:

Notice in this report that no limits have been configured for any users. 
6. Create disk quotas for your users by doing the following: 
a. At the shell prompt, enter edquota –u username. A screen similar to that shown next for the rtracy user is displayed: 

7. Create disk quotas for your groups by doing the following: 
a. At the shell prompt, enter edquota –g groupname.
b. Use the vi editor to set block and/or inode soft and hard quotas.
c. Save your changes and exit the editor.
8. In the preceding steps, you created soft quotas for blocks and/or inodes. The default value is to allow users to exceed their soft quotas for a maximum of seven days. This is the grace period. You can change this by doing the following:

  1. At the shell prompt, enter edquota –t. The following is displayed: 
b. Edit your grace period settings.
c. Save your changes and exit vi.
9. Check your new quotas by entering repquota –av at the shell prompt. You should now see quotas established for your users. In the example that follows, quotas have been established for the rtracy user: 







No comments:

Post a Comment