Linux Command LVM and Disk Management

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”.
Linux command LVM and disk management
(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.
Linux command LVM and disk management
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”.
Linux command LVM and Disk Management
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
Linux command LVM and disk management
The basic path to create the mount is as follows:
Linux command LVM and disk management
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
Linux command LVM and disk management

Linux command LVM and disk management
The third disk
Linux command LVM and disk management
The fourth disk
Linux command LVM and disk management
will be created Convert good partitions sdb1, sdc1, sdd1 to physical volumes
Linux command LVM and disk management
View physical volumes and integrate them into a mailbox volume group
Linux command LVM and disk management
View the detailed information of the volume group
Linux command LVM and disk management
Create two logical volumes in the mailbox volume group, 25G and 15G
Linux command LVM and disk management
View the created logical volume
Linux command LVM and disk management
View the information of the created logical volume
Linux command LVM and disk management
When the space of logical volume Mbox1 is insufficient, dynamically add 10G of memory to mbox1
Linux command LVM and disk management
Format the created logical volume
Linux command LVM and disk management
Create an automatic mount point and implement automatic mount
Linux command LVM and disk management

Linux command LVM and disk management
Linux command LVM and disk management
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
Linux command LVM and disk management
Linux command LVM and disk management
Linux command LVM and disk management

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
Linux command LVM and disk management
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.
Linux command LVM and disk management
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" >

Leave a Comment

Your email address will not be published.