Lab environment: Create an LVM logical partition in CENTOS7 and disk quotas for that partition.
-----Procedure-----
1 First add several disks to Centos7 for experimentation in the virtual machine VM14 software option.
Add a hard drive (at least two) in the shutdown state
Simply click Next to finish to add.
2 Open the Centos7 and open the Xsheel to connect the virtual machine for easy control of the system.
3 The root user enters the fdisk–l command to see all the hard drives that are currently recognized by the system.
4 type [[email protected] tmp]# FDISK/DEV/SDD Select a disk to operate.
Enter N to create a new partition.
5 Follow the prompts to type.
?
6 Repeat the previous step to complete the same operation as the other disk SDE.
?
7 type [[email protected] tmp]# Pvcreate/dev/sdd1/dev/sde1
Converting a disk partition SDD1 Sde1 to a physical volume
8 type [[email protected] tmp]# Pvscan
Used to scan all physical volumes in the system
You can see your two physical volumes sdd1 sde1 and in idle state
9 type [[email protected] tmp]# Pvdisplay/dev/sdd1/dev/sde1
You can view more information on two partitions
10 type [[email protected] tmp]# vgcreate zz/dev/sdd1/dev/sde1
Create a volume group with the name ZZ, which contains sdd1 sde1 two physical volumes
11 type [[email protected]/]# Vgdisplay ZZ
View the details of the ZZ volume group
?
12 Volume group creation is complete, we divide a 15G size logical volume named ZZ1
type [[email protected]/]# lvcreate-l 15g-n zz1 ZZ
13 format ZZ1 This partition
Type
[[email protected]/]# PARTPROBE/DEV/ZZ/ZZ1 activate partition from System kernel
[[email protected]/]# MKFS.EXT4/DEV/ZZ/ZZ1 format partition with EXT4 format
14 The required file to detect if the disk quota is installed on this machine.
[Email protected]/]# Rpm-q Quota
That is to have
15 Create a folder that is named ZZ
[[email protected]/]# Mkdir/mnt/zz created
[[email protected]/]# ls-l/mnt/Verification
16 Use the Vim editor to mount and add quota users.
Vim/etc/fstab Edit Fstab
/dev/zz/zz1/mnt/zz ext4 Defaults,usrquota,grpquota 0 0 line at the end enter the above content
WP save exit in the last row mode
17 type [[email protected] ~]# Mount–a mount
[email protected] ~]# Mount | TAIL-1 viewing the last line of Mount information
Already mounted complete, and visible Usrquota Groupquota two items
18 first Type [[email protected] ~]# Setenforce 0 Turn off enhanced security features
then type [[email protected] ~]# QUOTACHECK-CVUG/DEV/ZZ/ZZ1
Two new files will appear under this/mnt/zz.
19 Assume that you need to restrict a regular user named Zcent that already exists on the system.
type [[email protected] zz]# edquota-u zcent modify his file quota
Define your own desired quota after Wq save exit
Enable file quotas [[email protected] zz]# Quotaon-ugv/mnt/zz
20 validation is in effect
First of all, we put ZZ This folder permissions to release, so that ordinary users can not manipulate the file.
type [[email protected] zz]# chmod 777/mnt/zz use digital mode to modify permissions to maximum
[Email protected] zz]# LS-LH. View File permissions specific information
21 Switch user to zcent start test
To test the number of files:
Test for the capacity size that can be used:
Switch root users can view the current usage of each disk quota using REPQUOTA-A. It can be seen that the Myquota user has reached the maximum capacity limit for disk usage.
?
Finally: It is important to note that when a user triggers a soft limit, grace time is counted down, and if the user does not clean the disk so that it meets the soft limit, the soft limit becomes a hard limit, which is called the grace period, until the time (by default, 7 days) is exhausted. You can set this time by edquota-t, setting a grace period for the capacity and number of files, respectively.
Soft and hard limit operations on disk quotas in Linux