About LVM
LVM (Logical Volume Manager Logical Volume Manager), the operating system is Linux Logical Volume Manager.
LVM one or more hard disk partitions on a logical collection, is equivalent to using a large hard drive, disk space is not enough when used, may continue to the other hard disk partition was added thereto, which can dynamically manage disk space , relative to the normal disk partition has a great deal of flexibility.
Compared with traditional disks and partitions, LVM provides a higher level of disk storage for your computer. It enables system administrators to more easily allocate storage space for applications and users.
The term basic logical
- A physical storage medium (The physical media): This refers to the storage device system: the hard disk, such as: / dev / hda1, / dev / sda, etc., is the lowest level of the storage system storage unit.
- Physical volume (physical volume, pv): physical volume refers to a hard disk partition or device (e.g., RAID) having the same function from a logical disk partition, is the basic storage logical blocks LVM, but basic physical storage medium (e.g., partition , disk, etc.) compare, but contains management parameters associated with LVM.
- Volume group (Volume Group, vg): LVM volume group non-LVM system similar to the physical hard disk, which is a physical volumes. Can create one or more groups on the volume, "the LVM partitions" (logical volume), LVM volume group by one or more physical volumes.
- Logical volume (logical volume, lv): LVM logical volume similar to non-LVM system hard disk partition, logical volume on the file system can be established (such as / home or / usr, etc.).
- PE (physical extent): Each physical volume is divided into a basic unit called PE (Physical Extents) of, PE having a unique number is the smallest unit that can be addressed LVM. PE size is configurable, default to 4MB.
- LE (logical extent): logical volumes are also divided into the basic unit is called LE (Logical Extents) may be addressed. In the same volume group, LE and PE are the same size, and one correspondence.
Create LVM
- First partition and set the partition type
MBR partition is created
modify the MBR partition type
save and exit
create GPT partitions and modify partition type
using lsblk command to check the partitions - Create a physical volume (PV)
created three disks are converted to their physical volume PV
using the pvs command to view the physical volume information - Create a volume group (VG)
due to late amplification volume group space, where the first two disks using the volume group
Use vgs command to view information about the volume group
- Creating a logical volume (LV)
to create a logical volume test1 4G size of
the remaining space of the entire volume group to create a logical volume test2
using the logical volume created lvs command to view information
Create a file system
Creates ext4 file system on / dev / vg0 / test1
create xfs file system on / dev / vg0 / test2Mount the file system to the specified directory
Create a directory to mount the disk mount process
Create a file on a mounted directory for viewing late expansion, reduce the impact of file system data
Logical Volume Expansion
Use vgdisplay check command to see information about the volume group
It can be found in the free space as the volume group 0, the need for capacity expansion
Use vgextend command is not added until the volume group / dev / sdd1 added to the volume group to achieve expansion of the volume group
After executing the command, whether vgdisplay command to verify the successful expansion of the volume group
Use lvextend command logical volume expansion, and use the lvs command to check whether the successful expansion
Logical volume test1 xfs file system for expansion
of the logical volume test2 ext file system's expansion
to see if the missing files in the file system
proved to expand the file system space will not affect the file data
Logical Volume reduction
Because xfs file system does not support cut, so here to ext4 file system as an example, the logical volume will be reduced treatment test2
Backup processing on the need to reduce it before the file system data to prevent data loss
Before reduce first mounted off-line processing equipment
to reduce the space before the first logical file system are reduced
here message is: you need to do a health check on the file system before reduce file
space file system will be reduced
to logic reduced volumes
using the lvs command to view the changes in the logical volume space
to mount the file system, internal data inspection