LVM (logicl volume manager) and logical volume manager can dynamically divide and adjust hard disk space by managing hard disk storage devices using the logical volume manager.
I. Basic Concepts
1. Physical Volume ----- PV (physical volume)
The physical volume is at the bottom of the logical volume management. It can be a partition on the actual physical hard disk or the entire physical hard disk.
2. Volume group -------- VG (volumne Group)
A volume is created on top of a physical volume. A volume group must contain at least one physical volume. After a volume group is created, the physical volume can be dynamically added to the volume group. A logical volume Management System project can have only one or more volume groups.
3. logical volume ----- LV (logical volume)
The logical volume is created on the volume group. unallocated space in the volume group can be used to create new logical volumes. After the logical volume is created, the space can be dynamically expanded and reduced. Multiple logical volumes in the system must belong to the same volume group or different volume groups.
4. Physical zone-PE (physical extent)
The physical area is the minimum storage unit that can be allocated to a physical volume. The size of the physical area can be specified when a physical volume is created based on the actual situation. The physical region size cannot be changed once determined. The physical regions of all physical volumes in the same volume group must be consistent.
5. Logical region-Le (logical extent)
The logical area is the minimum storage unit that can be allocated in a logical volume. The size of the logical area depends on the size of the physical area in the volume group where the logical volume is located.
6. Volume group description area ----- (volume group deScriptOr Area)
The volume group description area exists in each physical volume and is used to describe the physical volume itself, the volume group to which the physical volume belongs, the logical volume in the volume group, and the allocation of Physical Areas in the logical volume, the volume group description area is created when you use pvcreate to create a physical volume.
II. General LVM operations
1. Create a physical volume on the disk partition
# Fdisk/dev/HDB
# Pvdisplay/dev/hdb1 // create a physical volume on the created partition or hard disk
# Pvcreate/dev/hdb1
2. Create a volume group using physical volumes
# Vgcreate myvg/dev/hdb1 // create a volume group. You can add new physical volumes to an existing volume group as needed.
3. Create a logical volume in the volume group
# Lvcreate-L 10 m-N mylv1 myvg // create a logical volume from an existing volume group. Generally, only part of the space is allocated to this volume. //
4. Create a file system on a logical volume
5. Mount the file system to the directory tree of the Linux System
6. Add a new physical volume to the volume group.
When the volume group does not have enough space to allocate to the logical volume, you can use the vgextend command to add a new physical volume to the volume group to expand the volume group capacity. In special cases, you can also remove existing physical volumes from the volume group.
# Vgextend myvg/dev/hdb2
7. expand the capacity of the logical volume
When the space of the logical volume cannot meet the requirements, you can use the lvextend command to allocate the free space in the volume group to the logical volume to expand the capacity of the logical volume. When the free space of the logical volume is too large, you can also use the lvreduce command to reduce the capacity of the logical volume. In this way, the logical volume capacity is dynamically adjusted.
# Lvextend-L + 4 m/dev/myvg/mylv
8. Adjust the file system size in the logical volume
Iii. Common commands
1. Physical Volume command
General maintenance commands:
# Pvscan // search for existing physical volumes on all disks of the system
# Pvdisplay physical volume full path name // used to display the properties of the specified physical volume.
# Pvdata physical volume full path name // displays the volume group description area information of the physical volume for debugging purposes.
# Pvchange-x | -- Allocation {Y | n} full physical volume path name // used to change the physical volume allocation permission settings
Command for creating and deleting physical volumes
# Pvcreate device full path name // used to create physical volume initialization information on a disk or disk partition, so that
// Logical volume management for this physical volume.
# Pvmove Source Physical Volume full path I [target physical volume full path name] // used to convert data in a physical volume
// Move to other special journals in the same volume group.
2. Volume Group Command
General maintenance commands
# Vgscan // check all disks in the system
# Vgck [volume group name] // used to check the consistency of volume group description region information in the volume group.
# Vgdisplay [volume group name] // display the volume group attributes
# Vgrename original volume group name new volume group name
# Vgchange-a y | n [volume group name] // change the corresponding attributes of the volume group. Allocable or not
# Vgchange-L maximum number of logical volumes // The maximum number of logical volumes that a volume group can accommodate
# Vgchange-x y | n [volume group name] // whether the volume is valid
# Vgmknodes [volume group name | volume group path] // used to create (re-establish) an existing volume group directory and the device files in it
// Piece
Backup and recovery commands for volume group configuration
# Vgcfgbackup [volume group name] // back up vgda information in the volume group to a file in the "/etc/lvmconf" Directory
# Vgcfgrestore-N volume group name physical volume full path name // you must specify the physical volume information from the backup file
Volume Group Creation and deletion commands
# Vgcreate volume group name physical volume full path name [physical volume full path name]
# Vgmove volume group name
Command to expand or contract a volume group
# Vgextend volume group name physical volume full path name [physical volume full path name]
# Vgreduce volume group name physical volume full path name [physical volume full path name]
Merge and split a volume group
# Vgmerge target volume group name source volume group name // merge two existing volume groups, requiring the physical
// The source volume group is not active when the region size is equal.
# Vgsplit full path name of the physical volume in the new volume group of the existing volume group [full path name of the physical volume]
Volume Group Input and Output commands
# Vgexport volume group name
# Vgimport volume group name physical volume in the volume group [physical volume in the volume group]
3. logical volume command
General commands
# Lvscan
# Lvdisplay full logical volume path name [full logical volume path name]
# Lvrename old logical volume full path name new logical volume full path name
# Lvrename volume group name old logical volume name new logical volume name
# Lvchange
# E2fsadm-L + |-full path name of the logical volume
Command for creating and deleting logical volumes
# Lvcreate
# Lvremove
Logic volume expansion and reduction commands
# Lvextend-L | -- size + logical volume size incremental logical volume full path name
# Lvreduce Q-L | -- size + logical volume reduction full logical volume path name
4. logical volume management commands
# Lvmdiskscan // check all storage devices such as SCSI and IDE
# Lvmchange-r | -- reset // reset logical volume manager
# Lvmsadc [full log file path name] // read/write statistics of the receiver logical volume manager, saved to the log file
.
# Full path name of the lvmsar Log File // read and report the logical volume from the log file generated by the lvmsadc command
// Read/write statistics of the manager.