Linux system Introduction: how to add a quota for a hard disk

Source: Internet
Author: User
Article Title: Linux system Introduction: how to add a quota for a hard disk. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

The following new hard drive quota experiment is completed in the vmvm.

To implement disk quota, the quota package must be installed in the system. The quota package is installed by default in RHEL4. Confirm that the software has been installed.

In fact, Red Hat Enterprise Linux 4 is used by multiple servers. SCSI disks support hot plugging and you can simply add a new hard disk.

Run the command fdisk-l to view the hard disk on the computer. The last line shows the newly added/dev/sdb. Run the command fdisk/dev/sdb. You can use the help prompt to complete the n (new) p (view the partition status) w (SAVE) q (exit) l (view the system type ID) t (change the file system type)

Create a new partition and set the partition size. In this experiment, a primary partition and an extended partition are created to verify that both the primary partition and the extended partition can meet the disk quota.

  Create logical partitions

Save Configuration

Use fdisk-l to view the new hard disk. The next step is to format the newly created partition. In this experiment, format/dev/sdb1/dev/sdb5/dev/sdb6 respectively.

Next, modify the "/etc/fstab" file to implement automatic mounting. Add the "usrquota" and "kgquota" option to the partition loading settings to be configured, you can set limits for users and groups in the system.

After correctly configuring the "fstab" file, you need to re-mount the file system to make the configuration of the file system take effect. The simplest way is to restart the Linux system to make the settings take effect.

You cannot use the quota function after setting partitions to support quota, because there is no quota file in the partition. Use the "quotacheck-cmug" command to create a quota file for a partition that supports the quota function. The quota file is automatically created in the root directory of the partition file system. After creating a quota, you can see the generated aquota. group and aquota. user.

The "edquota-u username" and "edquota-g group name" command can be used to set quotas for users and groups.

The filesystem field indicates the file system, that is, the hard disk partition where the quota needs to be set.

The blocks field indicates the number of data blocks currently occupied by the user. The size of each data block is 1 kb. This number is automatically calculated by the edquota program.

The inodes field indicates the number of "I nodes" occupied by the current user in the file system, that is, the number of Files Owned by the user. This number is automatically calculated by the edquota program.

The first and second soft fields indicate the number of soft Limits of disk capacity (KB) or number of files (files), which must be set by the user. Each hard field indicates the hard limit of disk capacity (KB) or number of files (Files). You need to set the hard limit.

After you have set a quota for a partition, you may not have the write permission yet. You must set the corresponding permissions. It is also necessary to enable the "quotaon quota directory. (Quotaon/quota; quotaon/quota2 in this experiment)

  Verify that the quota takes effect

"Edquota-t" is used to set the disk quota. The disk quota refers to the amount of disk space (the number of files) occupied by the user exceeds the soft limit, but before the hard limit is reached, you can use the system for a maximum period of time. During this period, you need to reduce the disk capacity occupied by the system to a soft limit. Otherwise, the system cannot be used normally. The unit of the grace period can be set to days, hours, minutes, and seconds ). The default grace period set in RHEL4 is 7 days (7 days)

When you limit a disk, you must master the following principles:

1. Because the limit on the number of files is not very practical for users, the disk quota usually only limits the disk capacity occupied by users.

2. The value of the soft and hard limits set for the user should not be smaller than the disk capacity or file quantity occupied by the user. Otherwise, the user may not be able to log on to and use the system normally.

3. The number of Hard limits should be greater than the number of Soft Limits. Otherwise, there is no practical significance.

4. the disk quota for the root user can be fully realized, but the root user must be able to log on normally at any time in the system, therefore, do not set the disk quota for the root user if you have no special requirements.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.