Operating Environment: CENTOS7
One, disk quotas
(1) Introduction
Disk quotas are the limits that administrators set to use disks for normal users, and each user can only use limited disk space and the administrator sets the disk quota. You can clearly understand the disk usage of each ordinary user, to prevent some users from wasting disk space causing other users to not work properly, in the LIUNX system we use the Super Administrator root user to configure the disk quota, you can do the user or group file size limit or limit the number of files.
Restrictions can be divided into two types:
Soft limit: When a user or group allocates more space than the current capacity can be exceeded within a certain grace period, the system will issue a warning, but the system will force the space to be reclaimed after the time has expired.
Hard limit: Data can no longer be stored when a user or group has allocated a full space.
(2) Enable and use disk quotas
Because the file system is different, the way to enable disk quotas is different, so say it separately here.
1, new partition, formatted as EXT4 file system, mount to/myquota this directory
FDISK/DEV/SDB (partition the SDB hard drive)
2, open quota, generate quota database
Vim/etc/fstab (Modify configuration file, add Usrquota and Grpquota) after modifying the configuration file requires a re-mount to take effect, can be mounted after the Mount command to see if it takes effect.
Quotacheck-cugm/myquota (Generate quota database)
Quotaon/myquota (Open quota)
3, configuration Quota
Edquota-u Libai (Configure user's disk quota)
Quota-v Libai (View user's limits)
Repquota-v/myquota (View the limit set by the current directory where the user created the file to be displayed)
Quota-g Tangchao (disk quota for groups, set quota for group, additional group settings should be set, while the directory to set Sgid permissions only makes sense)
Xfs_quota-x-C "xxxx" (-X Start admin mode-C followed by command) Xfs_quota-x-C "limit-u bsoft=60m bhard=100m Lihei"/myquota (set disk limit for user Lihei)
Xfs_quota-x-C "print" (see which quota are turned on in the current XFS system)
Xfs_quota-x-C "Report-ugibh"/myquota (view quota configuration in this directory, U: User g: Group I:inode B: Block device H: Human readable language)
Xfs_quota-x-C "Timer-u-B 10days"/myquota (set time)
Xsf_quota-x-C "State" (View set time)
Second, online expansion
When the size of the company is getting bigger and bigger, the hard disk occupies more and more big, this time we need to expand the hard disk capacity, but the actual mountain most companies are not allowed to expand offline, so the emergence of logical volume solves this problem.
1, the creation of LVM
(1) Prepare the hard disk or hard disk partition (set to 8e).
(2) Create physical volume PV (can be easily viewed via PVS, pvdispliy detailed view)
Pvcreate/dev/sdb1/dev/sdb2
(3) Create a volume group VG
Vgcreate vgfan/dev/sdb1/dev/sdb2 (VGs vgdisplay Simple View and Detailed view)
(4) Creating a logical volume LV
Lvcreate-l 500m-n Lvfan Vgfan
(5) Initialize the file system and mount it
2 Online Extensions
Lvextend-l +2g/dev/vgfan/lvfan
The file system needs to be extended by the DF command to see whether the current mount size or the original size
Resize2fs/dev/vgfan/lvfan (You can also add-r directly in the previous step)
Vgextend VGFAN/DEV/SDB3
Disk quotas and online extensions in Linux