On the LVM logical coupons and disk quotas

A, LVM Introduction

LVM is the Linux system to a logical disk partition management mechanism, which is based on the hard disk and the partition, a file system under the logical layer, the lower shielding disk partition layout when a file system, it is possible dynamic adjustment disk capacity while keeping unchanged the existing data, thereby improving the flexibility of disk management.
When selecting the automatic installation process partition CentOS system will default to the LVM partitioning scheme, no further manual configuration. If you have special needs, you can also use the installation disk customization tools provided by the wizard to adjust the LVM partition. Note that, "/ boot" partition can not be created on LVM, must be independent.

Two, LVM mechanism

1, PV (physical coupons)
physical storage device LVM volume is substantially mechanism, generally corresponding to a normal hard disk or the entire partition. When creating a physical volume will be created in the head of a hard disk partition or reserved blocks, used for recording attributes of the LVM, and the default size of the storage space is divided into a basic unit of 4MB (Physical Extent, PE), so as to constitute the physical volume .
On the LVM logical coupons and disk quotas
2, VG (volume group)
by one or more physical coupons form a whole, is called volume group can be dynamically added or removed physical vouchers in volume group.
On the LVM logical coupons and disk quotas
3, LV (logical ticket)
the logical volume based on the volume group, and not directly related to physical volumes. For the logical volume, the volume of each group is a whole, this whole "cut out" a small space as the basis for creating the user file system, this small space called logical volumes.
On the LVM logical coupons and disk quotas

Third, management LVM

1, common management command LVM
On the LVM logical coupons and disk quotas
2, PV physical coupon management
(1) pvscan command
pvscan all physical ticket for the scanning system, and outputs the information.
(2) pvcreat command
On the LVM logical coupons and disk quotas
pvcreat for converting the entire hard drive or partition to a physical ticket, primarily to add attribute information and dividing PE LVM memory device.
As shown in our first three disk partitions are converted to LVM type (specifically, how to create partitions, please refer to the disk and file management piece).
On the LVM logical coupons and disk quotas
On this basis, then perform "pvcreate /dev/sd{b..d}1" command to quickly replace hard disk installed physical coupons, and can perform "pvscan" command to view the physical coupons.
On the LVM logical coupons and disk quotas
(. 3) pvdisplay command
pvdisplay details for displaying the physical coupon, use of the specified physical coupons as a command parameter, the default is to display information about all the physical coupons.
(. 4) pvremove command
pvremove physical coupon to restore normal or disk partition, not for LVM systems, the physical coupons are removed pvscan will not be identified.
3, VG volume groups
(. 1) vgscan command
vgscan LVM volume group command to scan the established system and related information.
(2) vgcreat command
On the LVM logical coupons and disk quotas
vgcreat used to create a voucher or more physical volumes to a group, the name of the first command parameter for setting a new volume group, followed by a need to type specified volume group to the physical coupons main parameters .
Figure we execute "vgcreate mailbox /dev/sd{b..d}1" command to create a volume group, however, the implementation of "vgscan" command can not view the volume group information.
On the LVM logical coupons and disk quotas
(3) vgdisplay command
Details of each display system vgdisplay volume group for use of the specified volume group as a command parameter.
We perform "vgdisplay" command to view the volume group information.
On the LVM logical coupons and disk quotas
(. 4) vgremove command
vgremove deletes a specified volume group specified volume group name as a parameter.
(. 5) vgextend command
vgextend disk space for expansion of the volume group.
4, LV coupon management logic
(. 1) lvscan command
lvscan logic coupon information and scanning system established.
(2) lvcreat command
On the LVM logical coupons and disk quotas
lvcreat spatial subdivision logic for coupons from the specified volume group to create innovation.
Figure we execute "lvcreate -L 60G -n mbox01 mailbox" command to create a logical coupons.
On the LVM logical coupons and disk quotas
(. 3) lvdisplay command
lvdisplay logic details for displaying coupons, tickets need to specify the logical device file as a parameter, the volume group name may be used as a parameter to display information change all logical volume group coupons.
Figure we execute "lvdisplay" command to see the logic ticket information.
On the LVM logical coupons and disk quotas
(. 4) lvextend command
On the LVM logical coupons and disk quotas
lvextend space for vouchers dynamic expansion logic, the logic when there is insufficient space currently used vouchers, extra space may be used where split expanded volume group.
(. 5) lvremove command
lvremove deletes a specified logical vouchers, coupons directly logical device file as a parameter.

Fourth, the logical format and mount coupon

On the LVM logical coupons and disk quotas
1、如图我们执行“ mkfs -t xfs /dev/mailbox/mbox01”命令将逻辑券格式化。
On the LVM logical coupons and disk quotas
2、执行“mkdir /opt/mbox{1..2}”创建两个挂载点,然后执行“vim /etc/fstab”命令进入配置文件,按G键再按o键去尾行进行编写。(编写内容“/dev/mailbox/mbox01 /opt/mbox01 xfs defaults 0 0”空白处按Tab键即可)编写号后保存退出,在执行“mount -a”命令即可自动挂载了。
On the LVM logical coupons and disk quotas

五、磁盘配额

1、实现磁盘限额的条件
需要Linux内核支持
安装xfsprogs与 quota软件包
2、Linux磁盘限额的特点
作用范围:针对指定的文件系统(分区)
限制对象:用户帐号、组帐号
限制类型:磁盘容量、文件数量
限制方法:软限制、硬限制

3、启用磁盘配额支持
添加usruota、grquota挂载参数
4、磁盘配额管理
On the LVM logical coupons and disk quotas
(1)编辑用户和组账号的配额设置
On the LVM logical coupons and disk quotas
常用选项如下。
-u:指定用户
-g:指定组
-x:启用专家模式
-c:使用命令执行
限制字段
bsoft:软限制(失效7天)
bhard:硬限制
isoft:软节点(失效7天)
Ihard:硬节点
(2)验证磁盘配额功能
切换到设置配额的分区(挂载目录)
创建指定数量的文件:使用 touch命令,或cp命令
创建指定容量的文件:使用dd命,或cp命令
(3)查看配额使用情况
On the LVM logical coupons and disk quotas
常用选项如下。
-a:查看所有配额
-i:查看节点报告信息
-b:输出报告
-u:查看用户配额
-g:查看组配额
实践部分:
1、我们先执行“rpm -qa | grep xfprogs”命令查看有无“xfprogs”;再检索“xfprogs”里有无“quota”;然后执行“setenforce0”关闭增强安全选项功能
On the LVM logical coupons and disk quotas
2、执行“vim /etc/fstab”命令再来编写配置文件。在“/dev/mailbox/mbox02 /opt/mbox02 xfs defaults 0 0”里添加“,usrquota,gpquota”挂载参数。
On the LVM logical coupons and disk quotas
3, the implementation of "umount + mount point" command to unmount, and then re-mount the device to run mount options!
4, the implementation of "xfs_quota -x -c'limit -u bsoft = 10M bhard = 30M isoft = 4 ihard = 6 zhangsan '/ mailbox /" command sets the user quota.
On the LVM logical coupons and disk quotas
Note: Once the quota is set in a condition beyond the quota, another condition will not be able to execute! ! !
5, as the implementation of "xfs_quota -x -c'report -abi '" command to view the current quota use in a report.
On the LVM logical coupons and disk quotas

Guess you like

Origin blog.51cto.com/14449521/2431220