Understanding Linux File System Quotas - Installation and Setup
Minggu, 15 Januari 2012
0
komentar
When you are running your own web hosting, it is important to monitor how much space is being used by each user. This is not a simple task to be done manually since one of the users or group could fill up the whole hard disk, preventing others from availing any space. Therefore, it is important to allow each user or group their own hard disk space called quota and locking them out from using more than what is allotted.
The system administrator sets a limit or a disk quota to restrict certain aspects of the file system usage on a Linux operating system. In multi-user environments, disk quotas are very useful since a large number of users have access to the file system. They may be logging into the system directly or using their disk space remotely. They may also be accessing their files through NFS or through Samba. If several users host their websites on your web space, you need to implement the quota system.
How to Install Quota
For installing a quota system, for example, in your Debian or RedHAT Linux system, you will need two tools called ‘quota’ and ‘quotatool’. At the time of installation of these tools, you will be asked if you wish to send daily reminders to users who are going over their quotas.
Now, the administrator also needs to know the users that are going over their quota. The system will send an email to this effect, therefore the email address of the administrator has to be inputted next.
In case the user does not know what to do if the system gives him a warning message, the next entry is the contact number of the administrator. This will be displayed to the user along with the warning message. With this, the quota system installation is completed.
At this time, a user and a group have to be created and proper permissions given. For creating, you have to assume root status, and type the following commands:
# touch /aquota.user /aquota.group
# chmod 600 /aquota.*
# chmod 600 /aquota.*
Next, these have to be mounted in the proper place on the root file system. For this, an entry has to be made in the ‘fstab’ file in the directory /etc. In the ‘fstab’ file, the root entry has to be modified with:
noatime,nodiratime,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0
After this, the computer has to be rebooted, or the file system remounted with the command:
# mount -o remount /
The system is now able to work with disk quotas. However, you have to allow the system to build/rebuild its table of current disk usage. For this, you must first run quotacheck.
This will examine all the quota-enabled file systems, and build a table of the current disk usage for each one. The operating system’s copy of the disk usage is then updated. In addition, this creates the disk quota files for the entire file system. If the quota already existed, they are updated. The command looks like:
# quotacheck -avugm
Some explanation is necessary here. The (-a) tells the command that all locally mounted quota-enabled file systems are to be checked. The (-v) is to display the status information as the check proceeds. The (-u) is to enable checking the user disk quota information. The (-g) is to enable checking the group disk quota information. Finally, the (-m) tells the command not to try to remount file system read-only.
After checking and building the disk-quota files is over, the disk-quotas have to be turned on. This is done by the command ‘quotaon’ to inform the system that disk-quota should be enabled, such as:
# quotaon -avug
Here, (-a) forces all file systems in /etc/fstab to enable their quotas. The (-v) displays status information for each file system. The (-u) is for enabling the user quota. The (-g) enables the group quota.
Define Quota for Each User/Group
Now that the system is ready with quotas, you can start defining what each user or group gets as his limit. Two types of limits can be defined. One is the soft limit and the other is the hard limit. To set the two limits try editing the size and inode size with:
# edquota -u $USER
This allows you to edit the line:
/dev/sda1 1024 200000 400000 1024 0 0
Here, the soft limit is 200000 (200MB) and the hard limit is 400000 (400MB). You may change it to suit your user (denoted by $USER).
The soft limit has a grace period of 7 days by default. It can be changed to days, hours, minutes, or seconds as desired by:
# edquota -t
This allows you to edit the line below. It has been modified to change the default to 15 minutes:
/dev/sda1 15minutes 7days
For editing group quota use:
# edquota -g $GROUP
Quota Status Report
Now that you have set a quota, it is easy to create a mini report on how much space a user has used. For this use the command:
root@gateway [~]# repquota -a
*** Report for user quotas on device /dev/vzfs
Block grace time: 00:00; Inode grace time: 00:00
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 5578244 0 0 117864 0 0
bin -- 30936 0 0 252 0 0
mail -- 76 0 0 19 0 0
nobody -- 0 0 0 3 0 0
mailnull -- 3356 0 0 157 0 0
smmsp -- 4 0 0 2 0 0
named -- 860 0 0 11 0 0
rpc -- 0 0 0 1 0 0
mailman -- 40396 0 0 2292 0 0
dovecot -- 4 0 0 1 0 0
mysql -- 181912 0 0 857 0 0
firewall -- 92023 153600 153600 21072 0 0
#55 -- 1984 0 0 74 0 0
#200 -- 1104 0 0 63 0 0
#501 -- 6480 0 0 429 0 0
#506 -- 648 0 0 80 0 0
#1000 -- 7724 0 0 878 0 0
#50138 -- 43044 0 0 3948 0 0
Once the user and group quotas are setup, it is simple to manage your storage. Thus, you do not allow users to hog all of the disk space. By using disk quotas, you force your users to be tidier, and users and groups of users will not fill their home directories with junk or old documents that are no longer needed.
TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: Understanding Linux File System Quotas - Installation and Setup
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke https://androidblackberries.blogspot.com/2012/01/understanding-linux-file-system-quotas.html. Terima kasih sudah singgah membaca artikel ini.Ditulis oleh Unknown
Rating Blog 5 dari 5
0 komentar:
Posting Komentar