Disk Management: LVM Logical Volume

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

  1. First partition and set the partition type
    MBR partition is created
    Disk Management: LVM Logical Volume
    modify the MBR partition type
    Disk Management: LVM Logical Volume
    save and exit
    Disk Management: LVM Logical Volume
    create GPT partitions and modify partition type
    Disk Management: LVM Logical Volume
    using lsblk command to check the partitions
    Disk Management: LVM Logical Volume
  2. Create a physical volume (PV)
    created three disks are converted to their physical volume PV
    Disk Management: LVM Logical Volume
    using the pvs command to view the physical volume information
    Disk Management: LVM Logical Volume
  3. Create a volume group (VG)
    due to late amplification volume group space, where the first two disks using the volume group
    Disk Management: LVM Logical Volume

Use vgs command to view information about the volume group
Disk Management: LVM Logical Volume

  1. Creating a logical volume (LV)
    to create a logical volume test1 4G size of
    Disk Management: LVM Logical Volume
    the remaining space of the entire volume group to create a logical volume test2
    Disk Management: LVM Logical Volume
    using the logical volume created lvs command to view information
    Disk Management: LVM Logical Volume

    Create a file system

    Creates ext4 file system on / dev / vg0 / test1
    Disk Management: LVM Logical Volume
    create xfs file system on / dev / vg0 / test2
    Disk Management: LVM Logical Volume

    Mount the file system to the specified directory

    Create a directory to mount the disk mount process

Disk Management: LVM Logical Volume
Create a file on a mounted directory for viewing late expansion, reduce the impact of file system data
Disk Management: LVM Logical Volume

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
Disk Management: LVM Logical Volume

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
Disk Management: LVM Logical Volume

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
Disk Management: LVM Logical Volume
of the logical volume test2 ext file system's expansion
Disk Management: LVM Logical Volume
to see if the missing files in the file system
Disk Management: LVM Logical Volume
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
Disk Management: LVM Logical Volume
space file system will be reduced
Disk Management: LVM Logical Volume
to logic reduced volumes
using the lvs command to view the changes in the logical volume space
Disk Management: LVM Logical Volume
to mount the file system, internal data inspection
Disk Management: LVM Logical Volume

Guess you like

Origin blog.51cto.com/14234291/2444303