LVM logical volume and disk quota operation Daquan! (With the theoretical cheats)

1. Logical volume management

1. Role: Dynamically adjust disk capacity to improve the flexibility of disk management
2. The /boot partition is used to store boot files and cannot be created based on LVM
3. Graphical interface management tool
4.System–config–lvm

5.PV: physical volume
entire disk or ordinary partition created
including many default 4M size PE (Basic unit)

6.VG: volume group
a whole composed of one or more physical volumes

7.LV: logical volume
from volume group A piece of space divided in the file system is used to create a file system.
LVM logical volume and disk quota operations! (Contains theoretical cheats)

Two, LVM main commands and their functions

LVM logical volume and disk quota operation complete! (Contains theoretical cheats)
Main usage of the command
pvcreate device name 1 [device name 2 … …]
vgcreate Volume group name physical volume name 1 physical volume name 2
lvcreate -L capacity size-n logical volume volume group name
lvetend -L +size /dev/volume group name/logical volume name (make sure that the volume group has Space, logical volume can be expanded.
) name

3. Logical volume production process

Recommended steps: PV—-VG—–LV– —Format, mount and use the file system, if you don’t understand, please see the following picture for details.
LVM logical volume and disk quota operations! (Contains theoretical cheats)

< h2>Four. Overview of disk quotas

1. Conditions for achieving disk quotas
Linux kernel support is required
install xfsprogs and quota software packages
2. The characteristics of Linux disk quotas
Scope: for the specified file system (partition)
Restriction object: user account, group account
Restriction type: disk capacity (default unit KB), Number of files
Limiting methods: soft limit (with a period of validity), hard limit (mandatory limit)

3. Quota process
LVM logic Volume and disk quota operations! (Contains theoretical cheats)

Enable file system quota support: add Usrquota, grpquota mount parameter disk quota management

Five. Edit user and group account quota settings

1. Use the xfs_quota command to edit quota settings
LVM logical volume and disk quota operations! (Contains theoretical cheats)
2 .Common options
-u: for users;
-g: for groups;
-x: enable expert mode;
-c: use commands to execute.

3. Limit field

bsoft: soft limit (≤hard limit, b means block, the maximum time that can be exceeded is 7 days);
bhard: hard limit (cannot be exceeded);
isoft: soft limit (i is the number of nodes, equivalent to the number of files);
ihard: hard limit (i is the number of nodes, the number of files).

Six. Verify disk quota

1. Verify disk quota function
Switch to the partition where quota is set (mount directory)
Create Specified number of files: use touch command, or cp command
to create a file of specified capacity: use dd command, or cp command
2. View quota usage
xfs _ quota -x -c’report option’ mount point
report common options
-a, -i, -b, -u, -g meaning:
-b: output report
-i: View node information
-a: View all
-u:Users
-g:Group

7. Field exercise

1. Logical volume
Add three disks to centos, and divide the three disks into three partitions: sdb1, sdc1, sdd1 according to the previously released disk partition management method. Every time you divide a partition, you must enter w to save it. Then the three partition system types are changed to LVM (LVM ID is 8e)
LVM logical volume and disk quota operation complete! (Contains theoretical cheats)
LVM logical volume and disk quota operations! (Contains theoretical cheats)

Create physical volumes for three LVM disks. The sd{b..d}1 command includes sdb1, sdc1, and sdd1. The pvscan command is used to view physical volume information.
LVM logical volume and disk quota operations! (Contains theoretical cheats)

< p>Create a volume group for three disks, the volume group is named mailbox, and the three disks are in use.
LVM logical volume and disk quota operations! (Contains theoretical cheats)
View volume Group detailed information, which includes information such as name, format LVM, read and write permissions, total size, and PE size of 4M.
LVM logical volume and disk quota operation complete! (Contains theoretical cheats)
Currently in The mailbox volume group cannot be found in the dev directory. Only after the logical volume is created, there will be volume group files in the dev directory, which also contain the files of the logical volume.
LVM logical volume and disk quota operations! (Contains theoretical cheats)

< p>Create a logical volume with a size of 25G and a name of mbox01. You can see the volume group directory in the dev directory, and there are logical volume files in the directory. Follow the same method to create a 15G logical volume of mbox02
LVM logical volume and disk quota operation complete! (Contains theoretical cheats)
When the space of mbox01 is not enough, we need to expand space for it, for example, add 10G space to it, and specify the logical volume to add space.
LVM logical volume and disk quota operations! (Contains theoretical cheats)
Next The created logical volumes mbox01 and mbox02 are formatted. The following are the 01 formatting commands, and the 02 formatting methods are the same.
LVM logical volume and disk quota operation complete! (Contains theoretical cheats)
Next, set up automatic mounting for logical volumes 01 and 02
LVM logical volume and disk quota operations! (Contains theoretical cheats)

Enter the etc/fstab text to set up automatic mounting, note: middle Spaces are separated by Tab or Space.
LVM logical volume and disk quota operations! (Contains theoretical cheats)
Enter the command mount -a reloads everything in etc/fstab, which is equivalent to executing a restart command.
LVM logical volume and disk quota operations! (Contains theoretical cheats)

< p>Second, quota process
Be sure to install the xfsprogs and quota software packages (the top priority) before applying disk quotas.
LVM logical volume and disk quota operation complete! (Contains theoretical cheats)
Next, regardless of version 7 or 6, the enhanced security function must be turned off, otherwise the quota file Cannot write files.
LVM logical volume and disk quota operations! (Contains theoretical cheats)
Enter vim In the /etc/fstab command, write “,usrquota,grpquota” in the configuration file to automatically and permanently mount after booting, save and exit.
LVM logical volume and disk quota operations! (Contains theoretical cheats)
Enter mount Command, check that quota is not enabled. It is not mounted and needs to be mounted again.
LVM logical volume and disk quota operations! (Contains theoretical cheats)
First solution Mount the logical volume mbox2 (must be unmounted in other directories, and cannot be unmounted in its own directory), and then enter mount -a to reload
LVM logical volume and disk quota operations! (Contains theory) Cheats)
Enter the command mount to view, the mount is successful.
LVM logical volume and disk quota operations! (Contains theoretical cheats)

< p>Write quota command: xfs_quota -x -c’limit -u bsoft=50M bhard=80M isoft=4 ihard=6 zhangsan’ /dev/mbox2.
LVM logical volume and disk quota operations! (Contains theoretical cheats)
Verify quota , Give the zhangsan user write permission, switch the login user to zhangsan to verify whether the above quota is configured successfully.
LVM logical volume and disk quota operations! (Contains theoretical cheats)

< p>First to verify the node of the quota, we continue to create empty texts in mbox2, and when the 7th text (over the hard limit node) is created, the system prompts that the quota is exceeded.
LVM logical volume and disk quota operations! (Contains theoretical cheats)
Let’s come again Verify the capacity of the quota, dd in the command is copy (copy capacity), if=/dev/zero is to take out the capacity in the useless file zero, and of=/opt/mbox2/test01.txt command is to take just The output capacity is written into the newly created test01 text in the mbox2 directory, bs=1M means 1M capacity is taken from zero at a time, and count is a total of 50 times capacity, that is, a total of 50M capacity is written in test01.txt.
LVM logical volume and disk quota operation complete! (Contains theoretical cheats)
Follow the above How to use the command, write 50M into the test02.txt text in the mbox2 directory, but in fact only 30M is written. Because the hard limit capacity is 80M, that is, only 80M traffic can be written under the mbox2 directory.
LVM logical volume and disk quota operation complete! (Contains theoretical cheats)
When capacity After exceeding the hard limit we set, can we create more files for it? Take a look at the experiment
LVM logical volume and disk quota operation complete! (Contains theoretical cheats)< /p>

Conclusion: Once one of the nodes and capacity space exceeds the hard limit, you can no longer create files in the directory or write to the capacity space.

Enter the verification command to view the specific details of the hardware and software restrictions: xfs_quota -x -c ‘report -aih’ /opt/mbox2/. From the figure below, we can see that the soft and hard limit capacities we set are 50M and 80M; the soft and hard limit nodes are 4 and 6.
LVM logical volume and disk quota operation complete! (Contains theoretical cheats)

< /p>

Leave a Comment

Your email address will not be published.