LVM logical volume understanding and management of linux disk management

LVM logical volume understanding and management of Linux disk management

Preface

This paper then extends the previous article as follows:
Links: Disk management and file system of Linux disk management

  1. What is LVM? Why do I need LVM?
  2. How to manage LVM logical volumes?
  3. What is disk quota? Why do I need disk quotas?
  4. What are the conditions for disk quotas in Linux?
  5. How to make disk quota?

Next, I'll explain the above problems one by one, go deep into the examples for operation, and take you to have a deep understanding of LVM logical volume management of linux disk management.

I. LVM overview

1. What is LVM? Why do I need LVM?

Many Linux users will encounter such a dilemma when installing the operating system: how to accurately evaluate and allocate the capacity of each hard disk partition? If the initial evaluation is not accurate, once the system partition is not enough, they may have to back up, delete relevant data, or even be forced to re plan the partition and reinstall the operating system to meet the needs of the application system. LVM technology realizes the requirement of dynamic management and allocation of disks.

LVM -- Logical Volume Manger, logical volume management, is a logical mechanism for Linux system to manage disk partitions. It is a logical layer built on the hard disk and partition, and under the file system. When establishing the file system, it shields the partition layout of the lower layer, dynamically adjusts the disk capacity while keeping the existing data unchanged, so as to improve the disk Management flexibility.

Note: the boot partition is used to store boot files and cannot be created based on LVM!

2. Basic concept of LVM mechanism

  1. PV (physical volume)

    physical volume is the basic storage device of LVM mechanism, which usually corresponds to a common partition or the whole hard disk. During creation, a reserved block will be created at the head of partition or hard disk to record LVM attributes, and the storage space will be divided into basic units (PE) with a default size of 4MB, and multiple PES will form physical volumes

  2. VG (volume group)

    Multiple physical volumes make up volume groups

  3. LV (logical volume)

    Built on a volume group, not directly related to a physical volume.

The three diagrams are as follows:

! [] (C:\Users\alienware\Pictures\Saved Pictures \ physical volume. png)

! [] (C:\Users\alienware\Pictures\Saved Pictures \ volume group. png)

! [] (C:\Users\alienware\Pictures\Saved Pictures \ logical volume. png)

3. Main management commands of LVM

function Physical volume management Volume group management Logical volume management
Scan scan pvscan vgscan lvscan
create establishment pvcreate vgcreate lvcreate
Display display pvdisplay vgdisplay lvdisplay
remove delete pvremove vgremove lvremove
extend extension - vgextend lvextend
reduce reduction (not necessarily supported in some formats) - vgreduce lvreduce

The above table mainly lists the specific operation commands for managing logical volumes. The following is a demonstration of the common commands in the above table combined with the actual operation.

II. LVM logical volume management practice operation process (can follow)

4. How to manage LVM logical volumes?

Experimental environment: virtual machine environment of Centos7 on VMware 15

  1. Add disks and restart the virtual machine according to your own requirements and hardware limitations

    I have added three pieces. For details, please refer to: https://blog.51cto.com/14557673/2447274

  2. Check whether the disk is added successfully. If it is added successfully, partition operation will be carried out (the ID tag number of the partition type needs to be changed to 8e, which means LVM partition is supported)

    [root @ lokott ~] (uname - A / / displays the kernel version of 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
    
    Disk / dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors
     Units = sector of 1 * 512 = 512 bytes
     Sector size (logical / physical): 512 bytes / 512 bytes
     I/O size (minimum / best): 512 bytes / 512 bytes
     Disk label type: dos
     Disk identifier: 0x000a0791
    
      Device 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
    
    Disk / dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
     Units = sector of 1 * 512 = 512 bytes
     Sector size (logical / physical): 512 bytes / 512 bytes
     I/O size (minimum / best): 512 bytes / 512 bytes
    
    Disk / dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors
     Units = sector of 1 * 512 = 512 bytes
     Sector size (logical / physical): 512 bytes / 512 bytes
     I/O size (minimum / best): 512 bytes / 512 bytes
    
    Disk / dev/sdd: 21.5 GB, 21474836480 bytes, 41943040 sectors
     Units = sector of 1 * 512 = 512 bytes
     Sector size (logical / physical): 512 bytes / 512 bytes
     I/O size (minimum / best): 512 bytes / 512 bytes
    

    Partition operation is as follows:

    [root @ lokott ~] (fdisk / dev / sdb / / set the partition and partition type of sdb and sdc
     Welcome to fdisk (util Linux 2.23.2).
    ... / / the intermediate interaction process is omitted. Please refer to the above link for details
    
    Command (enter m for help): p
    
    Disk / dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
     Units = sector of 1 * 512 = 512 bytes
     Sector size (logical / physical): 512 bytes / 512 bytes
     I/O size (minimum / best): 512 bytes / 512 bytes
     Disk label type: dos
     Disk identifier: 0x5e2f4ad3
    
      Device boot start end blocks ID system
    /dev/sdb1            2048    20973567    10485760   8e  Linux LVM
    /dev/sdb2        20973568    31459327     5242880   83  Linux
    
    Command (enter m for help): w
    [root@lokott ~]# fdisk /dev/sdc
     Welcome to fdisk (util Linux 2.23.2).
    
    Changes stay in memory until you decide to write them to disk.
    Think twice before using the write command.
    
    Command (enter m for help): p
    
    Disk / dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors
     Units = sector of 1 * 512 = 512 bytes
     Sector size (logical / physical): 512 bytes / 512 bytes
     I/O size (minimum / best): 512 bytes / 512 bytes
     Disk label type: dos
     Disk identifier: 0xfd710363
    
      Device boot start end blocks ID system
    /dev/sdc1            2048    10487807     5242880   83  Linux
    /dev/sdc2        10487808    31459327    10485760   8e  Linux LVM
    

    At present, sdb1 and sdc2 have been used as logical partitions, and fdisk-l can be used to view information

    [root @ lokott ~] (fdisk - L / dev / SD [B-C] / / simplify the operation
    
    Disk / dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
     Units = sector of 1 * 512 = 512 bytes
     Sector size (logical / physical): 512 bytes / 512 bytes
     I/O size (minimum / best): 512 bytes / 512 bytes
     Disk label type: dos
     Disk identifier: 0x5e2f4ad3
    
      Device boot start end blocks ID system
    /dev/sdb1            2048    20973567    10485760   8e  Linux LVM    
    /dev/sdb2        20973568    31459327     5242880   83  Linux
    
    Disk / dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors
     Units = sector of 1 * 512 = 512 bytes
     Sector size (logical / physical): 512 bytes / 512 bytes
     I/O size (minimum / best): 512 bytes / 512 bytes
     Disk label type: dos
     Disk identifier: 0xfd710363
    
      Device boot start end blocks ID system
    /dev/sdc1            2048    10487807     5242880   83  Linux
    /dev/sdc2        10487808    31459327    10485760   8e  Linux LVM        
    [root@lokott ~]# 
    
  3. When the partition is complete, use the pvcreate command to convert the required operation partition to a physical volume

    [root@lokott ~]# pvscan / / view all the physical volumes of the system. The result is no
     No matching physical volumes found
    [root@lokott ~]# pvcreate /dev/sdb1 /dev/sdc2 / / convert partition to physical volume
     Physical volume "/dev/sdb1" successfully created.
     Physical volume "/dev/sdc2" successfully created.
    [root@lokott ~]# pvdisplay / / view physical volume details
     "/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 the vgcreate command to group one or more physical volumes into a volume group

    [root@lokott ~]# vgscan 
     Reading volume groups from cache.
    [root@lokott ~]# Vgcreate vgroup / dev / sdb1 / dev / sdc2 / / vgroup is the name of the created volume group
     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. Use the lvcreate command to separate space from the user specified volume group to create a logical volume.

    [root@lokott ~]# lvscan / / view the system's built logical volume information
    [root@lokott ~]# lvcreate -L 10G -n vgroup1 vgroup / / creates a logical volume by splitting space from a volume group
     Logical volume "vgroup1" created.
    [root@lokott ~]# ls /dev/vgroup/vgroup1 / / displays the link file of logical volume vgroup1             
    /dev/vgroup/vgroup1
    [root@lokott ~]# ls /dev/mapper/vgroup-vgroup1 / / displays the device file of logical volume vgroup1
    /dev/mapper/vgroup-vgroup1
    [root@lokott ~]# lvdisplay / / displays the logical volume details
     --- 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. Format the logical volume, create a mount point (mkdir) for mounting, and view it with df command

    [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
    //Filesystem type capacity used% free used mount point
    /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 the lvextend command to expand the capacity of the logical volume, and then use the resize2fs command to update the file system size recognized by the system
[root@lokott ~]# lvextend -L +5G /dev/vgroup/vgroup1 / / the following information indicates successful expansion (provided there is free space in the volume group)
  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 / / it is not shown that the system needs to be updated to identify the file system
//Filesystem type capacity used% free used mount point
/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 use XFS ﹣ growfs command, ext4 use resize2fs command
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 / / after the update, you can see the extension to 15G
/dev/mapper/vgroup-vgroup1 xfs        15G   33M   15G    1% /mail
[root@lokott ~]# 

5. Experiment summary (1)

The above is the whole process operation of LVM logical volume management, which can be followed! Be sure to pay attention to the operation of the logical partition when partitioning, and the later updated commands need to use the corresponding commands according to the file system type (ext4 - resize2fs, XFS - xfs_growfs)

III. disk quota

6. What is disk quota? Why do I need disk quotas?

Disk quota, as the name implies, is to limit the use of disk resources. Disk quota is the system's control (or restriction) on the use of disk resources by users. In Linux, disk quota can limit the use of space by users and the number of files (actually the number of inodes, the number of files is the result of the limitation of inodes). If it is out of this range, the user cannot continue to write data to the disk.

For ordinary people, it may not be easy to understand the explanation. Let's give an example to illustrate:

Suppose there is a basket of peaches, a total of 50 peaches, allocated to 10 monkeys on average, then each monkey can be allocated to 5 peaches. First, the total number of peaches and the number of peaches that each monkey can be allocated to are limited. This is the disk quota, but the allocation in the system must not be average. This requires quota allocation. If some monkeys are allocated to more peaches, it means that Some monkeys will get fewer points, but the total will not change. For linux system, it means that the actual resource space of a single disk is limited, so the reasonable allocation of the disk is particularly important.

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

7. What are the conditions for disk quota in Linux?

  1. Linux kernel support is required first
  2. Install xfsprogs and quota

8. Characteristics of Linux disk quota

  1. Scope: for the specified file system (partition)
  2. Restricted to: user account, group account
  3. Limit type: disk capacity, number of files
  4. Limit method: soft limit, hard limit

Among them, soft limit < = hard limit, otherwise, soft limit has no meaning, but soft limit is the method that plays a real control role

Depending on the type and method

  1. Capacity soft: bsoft
  2. Hard capacity: bhard
  3. Quantity soft: isoft
  4. Hard quantity: ihard

The following details the specific experimental operation process to demonstrate how to do disk quota.

IV. specific operation steps of disk quota experiment (the above experiment can be followed)

9. How to make disk quota?

The specific operation process is as follows:

  1. First, you need to check whether the above two conditions are met

    [root@lokott ~]# rpm -q xfsprogs / / use rpm -q to check whether the packages of the above two conditions are in the
    xfsprogs-4.5.0-12.el7.x86_64
    [root@lokott ~]# rpm -q quota
    quota-4.01-14.el7.x86_64
  2. If the conditions are met, the above experiment is followed. First, unmount (umount /mail)

    [root@lokott ~]# umount /mail/
    [root@lokott ~]# df -hT
    //Filesystem type capacity used% free used mount point
    /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. After unmounting, add usrquota and grpquota parameters to mount the file system in a way that supports quota function

    [root@lokott ~]# mount -o usrquota,grpquota /dev/vgroup/vgroup1 /mail/
    [root@lokott ~]# The following grep command can also be used to view the information of the last line in combination with the "Mount" command
    /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 the quota settings of user and group accounts (non root users are required here. You can use the tail command to view the information of / etc/passwd. If no other user uses useradd to create a user, the specific demonstration process is shown below)

    [root@lokott ~]# tail -3 /etc/passwd / / see, I am a lokott user here. To demonstrate, create a 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 / / create a new user account and password                           
    [root@lokott ~]# passwd lisi
    //Change the password for user lisi.
    //New password:
    //Invalid password: password is less than 8 characters
    //Reenter new password:
    passwd: All authentication tokens have been successfully updated.
    [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 is a detailed explanation of the following command. This command is really used to edit the user's quota settings. Xfs'quota is the command, option-x is the expert mode, - c is the command (in fact, the content in single quotation marks, similar to the database's add, delete, modify and query operation, limit is the limit, - u is the user, followed by the limit of quota size , then the user name, and finally do not forget the mount point!!!)

  5. Check the usage of disk quota and verify the function of disk quota. First, change the permission of mount point to 777 under root. Otherwise, the permission to create files is not enough when switching users

    [root@lokott ~]# XFS? Quota - C 'quota - UV Lisi' / mail / / / view disk capacity limit
    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 / / / view file limit
    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 / / / view all quota information
    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 / / switch users
    //Last login: June 2 16:15:17 CST 2019pts/0
    [lisi@lokott ~]$ cd /mail/                           //Enter the mount point directory to create a file to verify (method 1)
    [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  //The limit of the number of views above is 50. Now it's over 50
    touch: could not be built"51.txt": Disk quota exceeded
    touch: could not be built"52.txt": Disk quota exceeded
    touch: could not be built"53.txt": Disk quota exceeded
    touch: could not be built"54.txt": Disk quota exceeded
    touch: could not be built"55.txt": Disk quota exceeded
    touch: could not be built"56.txt": Disk quota exceeded
    touch: could not be built"57.txt": Disk quota exceeded
    touch: could not be built"58.txt": Disk quota exceeded
    touch: could not be built"59.txt": Disk quota exceeded
    touch: could not be built"60.txt": Disk quota exceeded
    [lisi@lokott mail]$ ls | wc -l         //Indicates 30 successfully created
    50
    [lisi@lokott mail]$ su               //Switch to root to see the change of quantity limit, where warn/time becomes 6days
    //Password:
    [root@lokott mail]# cd 
    [root@lokott ~]#  XFS? Quota - C 'quota - Iuv Lisi' / mail / / / view the quota limit function
    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 quota operation on the disk, the limit is very strict. We have verified the effect of quota limit on the disk by creating files. The warning time means 6 days from tomorrow. If the time exceeds the limit of 40 file nodes, the 10 files created later will be deleted!

    Use the dd command to verify the effect of quota capacity restriction:

    [root@lokott ~]# su - lisi / / first switch to cd on the lisi user and delete the original file in the mount point directory
    //Last login: 6 / 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        //Delete all files and use dd command to operate, soft limit 1G hard limit 2G
    [lisi@lokott mail]$ cd 
    [lisi@lokott ~]$ dd if=/dev/zero of=/mail/demo01.txt bs=50M count=10   //No problem for the first time
    //Recorded 10 + 0 reads
    //It records the writing of 10 + 0
    524288000 byte(524 MB)Copied, 0.647092 Seconds, 810 MB/second
    [lisi@lokott ~]$ dd if=/dev/zero of=/mail/demo02.txt bs=50M count=20   //No problem for the second time
    //Recorded 20 + 0 reads
    //Recorded the writing of 20 + 0
    1048576000 byte(1.0 GB)Copied, 0.685654 Seconds, 1.5 GB/second
    [lisi@lokott ~]$ dd if=/dev/zero of=/mail/demo03.txt bs=50M count=20    //Failed for the third time
    dd: Write in"/mail/demo03.txt" error: Disk quota exceeded
    //Recorded 11 + 0 reads
    //It records the writing of 10 + 0
    574619648 byte(575 MB)Copied, 0.357243 Seconds, 1.6 GB/second
    [lisi@lokott ~]$ du -sh /mail/    //Statistics of directory space size usage
    2.0G /mail/
    [lisi@lokott ~]$ ls -lh /mail/         //View details
    //Total consumption 2.0G
    -rw-rw-r--. 1 lisi lisi  500M 11 Month 217:08 demo01.txt
    -rw-rw-r--. 1 lisi lisi 1000M 11 Month 217:09 demo02.txt
    -rw-rw-r--. 1 lisi lisi  548M 11 Month 217:10 demo03.txt
    [lisi@lokott ~]$ su 
    //Password:
    [root@lokott lisi]# cd
    [root@lokott ~]# XFS [quota - C 'quota - UV Lisi' / mail / / / view capacity quota limit function
    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. Summary of experiment (3)

    Through the dd command (the dd command copies a file with a block of a specified size and performs the specified conversion at the same time of copying) to verify the functional test verification of the capacity limit in the disk quota, it can be seen that this is similar to the result of the previous method verification, and the following two points should be noted during the experimental operation:

    You need to switch user authentication and update the content of the mount point (if the second method does not delete the original file first, you cannot experiment)

Five, summary

This paper mainly introduces the concept of LVM and the specific operation of management logical volume, the concept of disk quota, why and how to carry out the specific operation verification experiment of quota. The points that need to be paid attention to are all in the above experimental summary and the explanation of principle reasons. The experiment is very detailed, you can follow it!! Thank you for reading!

Tags: Linux CentOS RPM ascii

Posted on Sat, 02 Nov 2019 07:32:29 -0700 by evil turnip