LVM Logical Volume Detailed understanding and management of linux disk management (experimental details, can now do)

linux disk management knowledge and management of LVM Logical Volume Detailed

Foreword

Subsequently the article article ( https://blog.51cto.com/14557673/2447274) extend as follows :

  1. What is LVM? Why LVM?
  2. How to carry out specific LVM Logical Volume Management?
  3. What are disk quotas? Why do you need disk quotas?
  4. What conditions disk quotas in Linux is it?
  5. How specific disk quotas?

Here to explain each of the above issues, in-depth examples operate with you in-depth understanding of linux disk management LVM Logical Volume Management.

A, LVM Overview

1. What is LVM? Why LVM?

Many Linux users face such difficulties when installing the operating system: how to accurately assess and distribution capacity of each hard disk partition, if the original assessment is not accurate, once the system partition may have enough backup, delete data, or even forced re-zoning and reinstall the operating system to meet the needs of the application system. The LVM technology to achieve the needs of users of dynamic allocation of disk management.

LVM - Logical Volume Manger, logical volume management, Linux system is a logical disk partition management mechanism, which is built on the hard disk and partition, a logical layer below the file system, the file system at the time of the establishment a lower shielding disk partition layout, dynamic adjustment disk capacity while maintaining the existing data unchanged, thereby increasing the flexibility of disk management.

Note: / boot partition for storing boot files, it can not be based LVM created! ! !

The basic concept 2.LVM mechanism

  1. PV (physical volume)

    Physical volume (physical volume), the storage device is substantially LVM mechanism, generally corresponding to a normal hard disk or the entire partition. When the head is created to create 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 (PE), a plurality of physical volumes configured PE

  2. VG (volume group)

    A plurality of physical volumes configured volume group

  3. LV (Logical Volume)

    Built on top of volume groups, and physical volumes are not directly related.

Schematic three as follows:

![](C:\Users\alienware\Pictures\Saved Pictures\物理卷.png)

![](C:\Users\alienware\Pictures\Saved Pictures\卷组.png)

![](C:\Users\alienware\Pictures\Saved Pictures\逻辑卷.png)

3.LVM key management command

Features Physical Volume Management Volume Group Management Logical Volume Management
scan scan pvscan vgscan lvscan
create build pvcreate vgcreate lvcreate
display display pvdisplay vgdisplay lvdisplay
remove delete pvremove vgremove lvremove
extend extension —— vgextend lvextend
reduce reduce (some formats may not be supported) —— vgreduce lvreduce

The main table lists the specific logical volume management operation command, the actual operation on the following table demonstrates common commands.

Second, the process of practical operation LVM Logical Volume Manager (available now do)

4. How specific were LVM Logical Volume Management ?

Experimental environment: on VMware15 Centos7 version of the virtual machine operating environment

  1. Add the disk and restart the virtual machine, according to their specific needs and a few hardware restrictions

    I added three specific steps can refer to: https://blog.51cto.com/14557673/2447274

  2. Check whether to add disk case is successful, the success of the operation to partition (which needs to be as the partition type ID tag number instead 8e, 8e expressed support for a LVM partition)

    [root@lokott ~]# uname -a                //显示Centos7的内核版本
    Linux lokott 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    [root@lokott ~]# fdisk -l
    
    磁盘 /dev/sda:42.9 GB, 42949672960 字节,83886080 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    磁盘标签类型:dos
    磁盘标识符:0x000a0791
    
      设备 Boot      Start         End      Blocks   Id  System
    /dev/sda1   *        2048    12584959     6291456   83  Linux
    /dev/sda2        12584960    54527999    20971520   83  Linux
    /dev/sda3        54528000    62916607     4194304   82  Linux swap / Solaris
    /dev/sda4        62916608    83886079    10484736    5  Extended
    /dev/sda5        62918656    83886079    10483712   83  Linux
    
    磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    
    磁盘 /dev/sdc:21.5 GB, 21474836480 字节,41943040 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    
    磁盘 /dev/sdd:21.5 GB, 21474836480 字节,41943040 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    

    Zoning as follows:

    [root@lokott ~]# fdisk /dev/sdb           //完成sdb和sdc的分区和分区类型设置
    欢迎使用 fdisk (util-linux 2.23.2)。
    .....                                    //中间交互过程省略,具体信息查看上述链接文章
    
    命令(输入 m 获取帮助):p
    
    磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    磁盘标签类型:dos
    磁盘标识符:0x5e2f4ad3
    
      设备 Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048    20973567    10485760   8e  Linux LVM
    /dev/sdb2        20973568    31459327     5242880   83  Linux
    
    命令(输入 m 获取帮助):w
    [root@lokott ~]# fdisk /dev/sdc
    欢迎使用 fdisk (util-linux 2.23.2)。
    
    更改将停留在内存中,直到您决定将更改写入磁盘。
    使用写入命令前请三思。
    
    命令(输入 m 获取帮助):p
    
    磁盘 /dev/sdc:21.5 GB, 21474836480 字节,41943040 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    磁盘标签类型:dos
    磁盘标识符:0xfd710363
    
      设备 Boot      Start         End      Blocks   Id  System
    /dev/sdc1            2048    10487807     5242880   83  Linux
    /dev/sdc2        10487808    31459327    10485760   8e  Linux LVM
    

    Now to the sdb1 and sdc2 as a logical partition, use fdisk -l to view information

    [root@lokott ~]# fdisk -l /dev/sd[b-c]           //简化操作
    
    磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    磁盘标签类型:dos
    磁盘标识符:0x5e2f4ad3
    
      设备 Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048    20973567    10485760   8e  Linux LVM    
    /dev/sdb2        20973568    31459327     5242880   83  Linux
    
    磁盘 /dev/sdc:21.5 GB, 21474836480 字节,41943040 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    磁盘标签类型:dos
    磁盘标识符:0xfd710363
    
      设备 Boot      Start         End      Blocks   Id  System
    /dev/sdc1            2048    10487807     5242880   83  Linux
    /dev/sdc2        10487808    31459327    10485760   8e  Linux LVM        
    [root@lokott ~]# 
    
  3. After completion of partitioning, the desired operation using the command pvcreate partition to physical volume

    [root@lokott ~]# pvscan                            //查看系统所有的物理卷,结果是没有
     No matching physical volumes found
    [root@lokott ~]# pvcreate /dev/sdb1 /dev/sdc2      //转换分区为物理卷
     Physical volume "/dev/sdb1" successfully created.
     Physical volume "/dev/sdc2" successfully created.
    [root@lokott ~]# pvdisplay                         //查看物理卷详细信息
     "/dev/sdc2" is a new physical volume of "10.00 GiB"
     --- NEW Physical volume ---
     PV Name               /dev/sdc2
     VG Name               
     PV Size               10.00 GiB
     Allocatable           NO
     PE Size               0   
     Total PE              0
     Free PE               0
     Allocated PE          0
     PV UUID               AzPaEA-X9Um-HPQQ-zdOg-mzVf-wXvh-QWEEXt
    
     "/dev/sdb1" is a new physical volume of "10.00 GiB"
     --- NEW Physical volume ---
     PV Name               /dev/sdb1
     VG Name               
     PV Size               10.00 GiB
     Allocatable           NO
     PE Size               0   
     Total PE              0
     Free PE               0
     Allocated PE          0
     PV UUID               5fh3Yx-Bwlm-ym7b-Qg0P-3HRb-iKRi-lwQyG9
    
  4. Use vgcreate command to one or more physical volumes Volume Group

    [root@lokott ~]# vgscan 
     Reading volume groups from cache.
    [root@lokott ~]# vgcreate vgroup /dev/sdb1 /dev/sdc2      //vgroup是所建卷组的名字
     Volume group "vgroup" successfully created
    [root@lokott ~]# vgdisplay 
     --- Volume group ---
     VG Name               vgroup
     System ID             
     Format                lvm2
     Metadata Areas        2
     Metadata Sequence No  1
     VG Access             read/write
     VG Status             resizable
     MAX LV                0
     Cur LV                0
     Open LV               0
     Max PV                0
     Cur PV                2
     Act PV                2
     VG Size               19.99 GiB
     PE Size               4.00 MiB
     Total PE              5118
     Alloc PE / Size       0 / 0   
     Free  PE / Size       5118 / 19.99 GiB
     VG UUID               K2s77S-fAfb-C5V2-P7ci-m4eo-DdNh-nanIW4
    
  5. Dividing the lvcreate command from the user specified volume group to create the logical volume space.

    [root@lokott ~]# lvscan                               //查看系统已建逻辑卷信息
    [root@lokott ~]# lvcreate -L 10G -n vgroup1 vgroup    //从卷组分割空间创建逻辑卷
     Logical volume "vgroup1" created.
    [root@lokott ~]# ls /dev/vgroup/vgroup1              //显示逻辑卷vgroup1的链接文件             
    /dev/vgroup/vgroup1
    [root@lokott ~]# ls /dev/mapper/vgroup-vgroup1        //显示逻辑卷vgroup1的设备文件
    /dev/mapper/vgroup-vgroup1
    [root@lokott ~]# lvdisplay                           //显示逻辑卷详细信息
     --- Logical volume ---
     LV Path                /dev/vgroup/vgroup1
     LV Name                vgroup1
     VG Name                vgroup
     LV UUID                ucTRFz-DK1l-fVgf-Gvzr-562n-nkYS-kuRACZ
     LV Write Access        read/write
     LV Creation host, time lokott, 2019-11-02 14:27:41 +0800
     LV Status              available
     # open                 0
     LV Size                10.00 GiB
     Current LE             2560
     Segments               2
     Allocation             inherit
     Read ahead sectors     auto
     - currently set to     8192
     Block device           253:0
    
  6. Logical volume is formatted, and create a mount point (mkdir) to mount, using the df command to view it

    [root@lokott ~]# mkfs.xfs /dev/vgroup/vgroup1 
    meta-data=/dev/vgroup/vgroup1    isize=512    agcount=4, agsize=655360 blks
            =                       sectsz=512   attr=2, projid32bit=1
            =                       crc=1        finobt=0, sparse=0
    data     =                       bsize=4096   blocks=2621440, imaxpct=25
            =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
    log      =internal log           bsize=4096   blocks=2560, version=2
            =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    [root@lokott ~]# mkdir /mail
    [root@lokott ~]# mount /dev/vgroup/vgroup1 /mail/
    [root@lokott ~]# df -hT
    文件系统                   类型      容量  已用  可用 已用% 挂载点
    /dev/sda2                  xfs        20G  4.4G   16G   22% /
    devtmpfs                   devtmpfs  474M     0  474M    0% /dev
    tmpfs                      tmpfs     489M     0  489M    0% /dev/shm
    tmpfs                      tmpfs     489M  7.2M  482M    2% /run
    tmpfs                      tmpfs     489M     0  489M    0% /sys/fs/cgroup
    /dev/sda5                  xfs        10G   37M   10G    1% /home
    /dev/sda1                  xfs       6.0G  158M  5.9G    3% /boot
    tmpfs                      tmpfs      98M  4.0K   98M    1% /run/user/42
    tmpfs                      tmpfs      98M   24K   98M    1% /run/user/0
    /dev/sr0                   iso9660   4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64
    /dev/mapper/vgroup-vgroup1 xfs        10G   33M   10G    1% /mail
    
  7. Use lvextend command logical capacity expansion, then use resize2fs command to update the file system size recognized by the system
[root@lokott ~]# lvextend -L +5G /dev/vgroup/vgroup1 //下面的信息表示成功扩展(前提是卷组中有空余空间)
  Size of logical volume vgroup/vgroup1 changed from 10.00 GiB (2560 extents) to 15.00 GiB (3840 extents).
  Logical volume vgroup/vgroup1 successfully resized.
[root@lokott ~]# df -hT                              //查看是没有显示出来需要更新让系统识别文件系统
文件系统                   类型      容量  已用  可用 已用% 挂载点
/dev/sda2                  xfs        20G  4.4G   16G   22% /
devtmpfs                   devtmpfs  474M     0  474M    0% /dev
tmpfs                      tmpfs     489M     0  489M    0% /dev/shm
tmpfs                      tmpfs     489M  7.2M  482M    2% /run
tmpfs                      tmpfs     489M     0  489M    0% /sys/fs/cgroup
/dev/sda5                  xfs        10G   37M   10G    1% /home
/dev/sda1                  xfs       6.0G  158M  5.9G    3% /boot
tmpfs                      tmpfs      98M  4.0K   98M    1% /run/user/42
tmpfs                      tmpfs      98M   24K   98M    1% /run/user/0
/dev/sr0                   iso9660   4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64
/dev/mapper/vgroup-vgroup1 xfs        10G   33M   10G    1% /mail
[root@lokott ~]# xfs_growfs /dev/vgroup/vgroup1   //xfs的使用xfs_growfs命令,ext4用resize2fs命令
meta-data=/dev/mapper/vgroup-vgroup1 isize=512    agcount=4, agsize=655360 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=2621440, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2621440 to 3932160
[root@lokott ~]# df -hT | grep /dev/mapper/vgroup-vgroup1 //更新后可以查看到扩展到15G
/dev/mapper/vgroup-vgroup1 xfs        15G   33M   15G    1% /mail
[root@lokott ~]# 

5. Experimental Summary (1)

Above is the whole process of LVM logical volume management operation, you can do what I do! Always operating logical partition when the partition note, and later requires updating command corresponding commands based on the file system type (ext4 - resize2fs, xfs - xfs_growfs)

Third, disk quotas

6. What are disk quotas? Why do you need disk quotas?

Disk quotas, by definition, is to limit the use of disk resources, disk quota system to control the user can use the disk resources (or limit). In Linux, you can use disk quotas to user space, number of files (in fact, is the number of the inode, the number of documents to limit the result of the inode) limit. If you exceed this range, the user can not continue to write data to the disk in.

For the average person, it may not be particularly good understanding of this section to explain that we give an example to illustrate:

Suppose a basket of peaches, a total of 50, the average allocation to 10 monkeys, each monkey can then be assigned to five peaches, first of all is to limit the number of peaches and peach total number can be assigned to each monkey, which is disk quota, but not necessarily the average allocation in the system, which need to be this quota allocation, some monkeys assigned to multi-point, then it means that some of the monkeys will be assigned will be less, but the total number will not change. For linux systems, it means that a single disk actual resource space is limited, so it is particularly important for the rational allocation of disk.

Therefore, the reason is that the disk quota disk space resources are limited, and its purpose can be understood as rational planning, to avoid waste of resources.

7. What are the conditions that disk quotas in Linux is it?

  1. First you need Linux kernel support
  2. Installation and quota xfsprogs

Features 8.Linux disk quota

  1. Range: for a specified file system (partition)
  2. Restrictions target: user accounts, group accounts
  3. Limit Type: disk capacity, the number of files
  4. Restriction method: soft limit, hard limit

Where the soft limit <= hard limit, soft limit or does not make sense, but the soft limit is to play really play the role of control methods

According following types and methods

  1. Capacity soft: bsoft
  2. Capacity Hard: bhard
  3. Number of soft: isoft
  4. Number of Hard: ihard

The following specific experiments give a specific process operation and demonstration of how to perform disk quota.

Fourth, disk quota specific steps experiments (experiments may then be operated above)

9. How specific disk quotas?

Specific procedure is as follows:

  1. First need to see if these two conditions are met

    [root@lokott ~]# rpm -q xfsprogs      //用rpm -q 进行查看上述两个条件的软件包是否在
    xfsprogs-4.5.0-12.el7.x86_64
    [root@lokott ~]# rpm -q quota
    quota-4.01-14.el7.x86_64
  2. Condition is satisfied, then operation of the above experiment, to unmount (umount / mail)

    [root@lokott ~]# umount /mail/
    [root@lokott ~]# df -hT
    文件系统       类型      容量  已用  可用 已用% 挂载点
    /dev/sda2      xfs        20G  4.4G   16G   22% /
    devtmpfs       devtmpfs  474M     0  474M    0% /dev
    tmpfs          tmpfs     489M     0  489M    0% /dev/shm
    tmpfs          tmpfs     489M  7.2M  482M    2% /run
    tmpfs          tmpfs     489M     0  489M    0% /sys/fs/cgroup
    /dev/sda5      xfs        10G   37M   10G    1% /home
    /dev/sda1      xfs       6.0G  158M  5.9G    3% /boot
    tmpfs          tmpfs      98M  4.0K   98M    1% /run/user/42
    tmpfs          tmpfs      98M   24K   98M    1% /run/user/0
    /dev/sr0       iso9660   4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64
  3. Add usrquota and grpquota parameters unmounted functions to support the quota mount the file system

    [root@lokott ~]# mount -o usrquota,grpquota /dev/vgroup/vgroup1 /mail/
    [root@lokott ~]# mount | tail -1    //mount 命令结合“|”查看尾部一行的信息也可以使用下面的grep命令
    /dev/mapper/vgroup-vgroup1 on /mail type xfs (rw,relatime,seclabel,attr2,inode64,usrquota,grpquota)
    [root@lokott ~]# mount | grep /dev/mapper/vgroup-vgroup1
    /dev/mapper/vgroup-vgroup1 on /mail type xfs (rw,relatime,seclabel,attr2,inode64,usrquota,grpquota)
  4. Edit user and group account quota settings (here need to have a non-root user, you can view using the tail command / etc / passwd information, if no other user using useradd to create a user, description is given during the presentation)

    [root@lokott ~]# tail -3 /etc/passwd //查看,我这里是由一个lokott的用户的,为了演示下面创建一个lisi
    postfix:x:89:89::/var/spool/postfix:/sbin/nologin
    tcpdump:x:72:72::/:/sbin/nologin
    lokott:x:1000:1000:lokott:/home/lokott:/bin/bash
    [root@lokott ~]# useradd lisi            //创建新的用户账号和密码                           
    [root@lokott ~]# passwd lisi
    更改用户 lisi 的密码 。
    新的 密码:
    无效的密码: 密码少于 8 个字符
    重新输入新的 密码:
    passwd:所有的身份验证令牌已经成功更新。
    [root@lokott ~]# tail -3 /etc/passwd
    tcpdump:x:72:72::/:/sbin/nologin
    lokott:x:1000:1000:lokott:/home/lokott:/bin/bash
    lisi:x:1001:1001::/home/lisi:/bin/bash
    [root@lokott ~]# xfs_quota -x -c 'limit -u bsoft=1G bhard=2G isoft=20 ihard=50 lisi' /mail/

    Here for a detailed explanation of the bottom command, this command is a command truly edit user quota settings of the operation, which is xfs_quota commands, options -x represent the expert mode, -c indicates a command (command, in fact, single quotes content, similar to a database CRUD operations, limit represents the limit, -u representation of the user, the latter is to limit the size of the quota, then the user name, and finally do not forget to mount point !!!)

  5. Create a file permissions to view disk quota usage and verify disk quota feature, first mount privileges points to 777 in the root, otherwise it will be enough to switch users

    [root@lokott ~]# xfs_quota -c 'quota -uv lisi'  /mail/  //查看磁盘容量限制
    Disk quotas for User lisi (1001)
    Filesystem              Blocks      Quota      Limit  Warn/Time      Mounted on
    /dev/mapper/vgroup-vgroup1
                                0    1048576    2097152   00 [--------] /mail
    [root@lokott ~]# xfs_quota -c 'quota -iuv lisi'  /mail/  //查看文件数量限制
    Disk quotas for User lisi (1001)
    Filesystem               Files      Quota      Limit  Warn/Time      Mounted on
    /dev/mapper/vgroup-vgroup1
                                0         20         50   00 [--------] /mail
    
    [root@lokott ~]# xfs_quota -x -c 'report -a'  /mail/     //查看配额的所有信息
    User quota on /mail (/dev/mapper/vgroup-vgroup1)
                                  Blocks                     
    User ID          Used       Soft       Hard    Warn/Grace     
    ---------- -------------------------------------------------- 
    root                0          0          0     00 [--------]
    lisi                0    1048576    2097152     00 [--------]
    
    Group quota on /mail (/dev/mapper/vgroup-vgroup1)
                                  Blocks                     
    Group ID         Used       Soft       Hard    Warn/Grace     
    ---------- -------------------------------------------------- 
    root                0          0          0     00 [--------]
    
    [root@lokott ~]# chmod 777 /mail/
    [root@lokott ~]# su - lisi                           //切换用户
    上一次登录:六 11月  2 16:15:17 CST 2019pts/0 上
    [lisi@lokott ~]$ cd /mail/                           //进入挂载点目录创建文件方式来验证(方法一)
    [lisi@lokott mail]$ ls
    [lisi@lokott mail]$ touch {1..20}.txt
    [lisi@lokott mail]$ ls 
    10.txt  12.txt  14.txt  16.txt  18.txt  1.txt   2.txt  4.txt  6.txt  8.txt
    11.txt  13.txt  15.txt  17.txt  19.txt  20.txt  3.txt  5.txt  7.txt  9.txt
    [lisi@lokott mail]$ touch {20..60}.txt  //上面查看的数量限制是50,现在超过50了
    touch: 无法创建"51.txt": 超出磁盘限额
    touch: 无法创建"52.txt": 超出磁盘限额
    touch: 无法创建"53.txt": 超出磁盘限额
    touch: 无法创建"54.txt": 超出磁盘限额
    touch: 无法创建"55.txt": 超出磁盘限额
    touch: 无法创建"56.txt": 超出磁盘限额
    touch: 无法创建"57.txt": 超出磁盘限额
    touch: 无法创建"58.txt": 超出磁盘限额
    touch: 无法创建"59.txt": 超出磁盘限额
    touch: 无法创建"60.txt": 超出磁盘限额
    [lisi@lokott mail]$ ls | wc -l         //表示成功创建了30个
    50
    [lisi@lokott mail]$ su               //切换到root下看一下数量限制的变化,其中warn/time变为6days
    密码:
    [root@lokott mail]# cd 
    [root@lokott ~]#  xfs_quota -c 'quota -iuv lisi'  /mail/   //查看数量配额限制功能
    Disk quotas for User lisi (1001)
    Filesystem               Files      Quota      Limit  Warn/Time      Mounted on
    /dev/mapper/vgroup-vgroup1
                               50         20         50   00  [6 days] /mail
    

    10. Experimental summary (2):

    After the disk quota operations, its limits are very strict, above we verify the effect of the number of disk quota restrictions by the method of creating the file where the warning time indicates the start to six days from tomorrow, more than due to the soft limit 40 limit the number of nodes files, 10 files created later will be deleted!

    Below and to verify the capacity limit by the quota dd command:

    [root@lokott ~]# su - lisi                  //首先切换到lisi用户上cd到挂载点目录删除原来的文件
    上一次登录:六 11月  2 16:46:28 CST 2019pts/0 上
    [lisi@lokott ~]$ cd /mail/
    [lisi@lokott mail]$ ls
    10.txt  14.txt  18.txt  21.txt  25.txt  29.txt  32.txt  36.txt  3.txt   43.txt  47.txt  50.txt  8.txt
    11.txt  15.txt  19.txt  22.txt  26.txt  2.txt   33.txt  37.txt  40.txt  44.txt  48.txt  5.txt   9.txt
    12.txt  16.txt  1.txt   23.txt  27.txt  30.txt  34.txt  38.txt  41.txt  45.txt  49.txt  6.txt
    13.txt  17.txt  20.txt  24.txt  28.txt  31.txt  35.txt  39.txt  42.txt  46.txt  4.txt   7.txt
    [lisi@lokott mail]$ rm *.txt -f        //删除所有文件然后使用dd命令操作,软限制1G 硬限制2G
    [lisi@lokott mail]$ cd 
    [lisi@lokott ~]$ dd if=/dev/zero of=/mail/demo01.txt bs=50M count=10   //第一次没问题
    记录了10+0 的读入
    记录了10+0 的写出
    524288000字节(524 MB)已复制,0.647092 秒,810 MB/秒
    [lisi@lokott ~]$ dd if=/dev/zero of=/mail/demo02.txt bs=50M count=20   //第二次没问题
    记录了20+0 的读入
    记录了20+0 的写出
    1048576000字节(1.0 GB)已复制,0.685654 秒,1.5 GB/秒
    [lisi@lokott ~]$ dd if=/dev/zero of=/mail/demo03.txt bs=50M count=20    //第三次失败了
    dd: 写入"/mail/demo03.txt" 出错: 超出磁盘限额
    记录了11+0 的读入
    记录了10+0 的写出
    574619648字节(575 MB)已复制,0.357243 秒,1.6 GB/秒
    [lisi@lokott ~]$ du -sh /mail/    //统计目录空间大小使用情况
    2.0G /mail/
    [lisi@lokott ~]$ ls -lh /mail/         //查看详细信息
    总用量 2.0G
    -rw-rw-r--. 1 lisi lisi  500M 11月  2 17:08 demo01.txt
    -rw-rw-r--. 1 lisi lisi 1000M 11月  2 17:09 demo02.txt
    -rw-rw-r--. 1 lisi lisi  548M 11月  2 17:10 demo03.txt
    [lisi@lokott ~]$ su 
    密码:
    [root@lokott lisi]# cd
    [root@lokott ~]# xfs_quota -c 'quota -uv lisi'  /mail/  //查看容量配额限制功能
    Disk quotas for User lisi (1001)
    Filesystem              Blocks      Quota      Limit  Warn/Time      Mounted on
    /dev/mapper/vgroup-vgroup1
                          2097152    1048576    2097152   00  [6 days] /mail
    

    11. Experimental summary (3)

    By dd command (dd command is a copy of a specified size block of a file, and the specified conversion simultaneous copies) to verify the function test to verify disk quota capacity constraints, seen This is similar to a method of verifying the results of the experiment During operation note the following points:

    You need to switch user authentication and content updates mount point (if the second method without first deleting the original file, is not the experiment)

V. Summary

To do this paper leads to several problems begins to illustrate the concept and management of logical volumes LVM, the concept of disk quotas, why should the quotas and how to operate specific quotas verification experiment, the point to note in the above experiment Summary and the principles set forth in the cause. Experiments in great detail, I can do what I do! ! Thank you for reading!

Guess you like

Origin blog.51cto.com/14557673/2447324