LVM and disk quotas
One, LVM logical volume management
1, LVM overview
Logical Volume Manager, logical volume management
(1) Dynamically adjust the disk capacity to improve the flexibility of disk management sex.
(2) The /boot partition is used to store boot files and cannot be created based on LVM
(3) Graphical interface management tool: system-config-lvm
The basic concept of LVM mechanism
(1) PV (Physical Volume)
Physical volume is the basic storage device of LVM mechanism, usually corresponding to an ordinary partition or the entire hard disk.
The physical volume is composed of multiple basic units (PE) with a default size of 4MB. A reserved partition is created at the head of it to record LVM attributes.
For ordinary partitions to be converted into physical volumes, it is recommended to use the fdisk tool to change the ID mark number of the partition type to “8e”.
(2) VG (Volume Group)
Consists of one or more physical volumes. You can dynamically add or remove physical volumes in the volume group.
(3) LV (Logical Volume, logical volume)
Logical volumes are built on volume groups and have no direct relationship with physical volumes.
For logical volumes, each volume group is a whole, and a small piece of space is “cut out” from this whole. As the basis for users to create a file system, this small piece of space is called a logical volume.
2, LVM management command
LVM management command It is mainly divided into three categories: PV physical volume management, VG volume group management, and LV logical volume management. The corresponding commands start with “pv”, “vg” and “lv”.
Main command
(1) pvcreate device name 1 [device name 2 …. … ] Let
convert the partition or the entire hard disk into a physical volume
(2) Vgcreate volume group name physical volume name 1 physical volume name 2
create one or more physical volumes as a volume group
(3) Lvcreate -L capacity size -n logical volume name volume group name
Split space from the specified volume group to create the specified logical volume
(4) Lvextend -L +size /dev/volume group name /Logical volume name
When the currently used logical volume is insufficient, the space of the logical volume is dynamically expanded.
3, LVM application example
The basic path to create the mount is as follows:
1. Add three SCSI disks to the virtual machine, restart the virtual machine, and connect with Xshell.
Partition the added disk.
Configure the added 3 disks and convert the configured partitions to Linux LVM type
Second disk
The third disk
The fourth disk
will be created Convert good partitions sdb1, sdc1, sdd1 to physical volumes
View physical volumes and integrate them into a mailbox volume group
View the detailed information of the volume group
Create two logical volumes in the mailbox volume group, 25G and 15G
View the created logical volume
View the information of the created logical volume
When the space of logical volume Mbox1 is insufficient, dynamically add 10G of memory to mbox1
Format the created logical volume
Create an automatic mount point and implement automatic mount
Second, disk quota
1. Overview of disk quotas
Conditions for realizing disk quotas
(1) Linux kernel support is required
(2) xfsprogs and quota software packages need to be installed
Characteristics of Linux disk quotas
(1 ) Scope: for the specified file system (partition)
(2) Restricted objects: user account, account group
(3) Restriction type: disk capacity, number of files
(4) Restriction method: soft Restrictions and hard restrictions
Steps for disk quotas
(1) Mount the file system in a way that supports the quota function
(2) Edit the quota settings of user and group accounts
(3) Verify disk quotas Function
(4) View disk quota usage
2, enable disk quota support
Enable Use file system quota support
Add usrquota, grpquota mount parameters
Add common commands for mount parameters
3. Disk quota management
Edit Quota settings for user and group accounts
Use the xfs_quota command to edit the quota settings
Xfs_quota -x -c’limit -u bsoft=N bhard=N isoft=N ihard=N username’ mount point
Commonly used Options
-u: Specify user
-x: Enable expert mode
-c: Use command execution
Limit field
bsoft: Soft limit size
bhard: Hard limit size
isoft: soft limit node
ihard: hard limit node
soft limit cannot exceed hard limit
4. Verify the disk quota function
(1) Switch to the partition where quota is set (mount directory)
(2) Create a specified number of files: use the touch command , Or the cp command.
(3) Create a file with a specified capacity: use the dd command or the cp command.
5. View quota usage
xfs_quota -x -c’report option’ mount point
report common options
-b output report
-a view all
-i node information
-u, -g
< img alt="Linux command LVM and disk management" src="/wp-content/uploads/images/os/linux/1626797219118.png" >