Outline:
- Brief introduction
- Version
- Basic terminology for LVM
- LVM Module
- Specific operation
Partitioning the added hard drive (Fdisk/dev/[hs]d[a-z])
Create a physical volume (pvcreate) on the created partition
To create a logical container (volume group) for a logical volume
Create logical volumes of different sizes on volume groups (lvcreate)
Expand capacity to existing volume groups
Enable online expansion of LVM capacity
Achieve reduced LVM capacity (online reduction not supported)
Reduce volume group capacity
Take advantage of creating snapshots for LVM and complete backups and restores
- Introduction:
LVM is a shorthand for the Logical Volume Manager (Logical Volume manager) and is translated into logical File Manager, logical Sector Manager, and Logical Disk Manager . Is the logical volume management (Logical Volume Management) feature provided by the Linux core. It is above the hard disk partition of the hard disk, and creates a logical layer to facilitate the system management of the hard disk partition system.
Originally developed by IBM and implemented on AIX systems, the OS/2 operating system and HP-UX also support this capability;
In 1998, Heinz Mauelshagen wrote the first Linux version of the logical Volume Manager based on the logical Volume manager on HP-UX, and published it to the Linux community, which allows users to manage a complete logical volume management environment on a Linux system with a simple command line.
Advantages of LVM:
It is an abstraction layer built on a physical storage device, allowing users to generate logical storage volumes, providing greater flexibility than using physical storage directly in management;
LVM stores virtualization, uses logical volumes, users are not limited to the size of physical disks, and hardware-related storage settings are hidden, and users can reduce the cost of operations by not having to stop applying or uninstalling the file system to adjust volume size or data migration.
LVM has the following advantages over the direct use of physical storage:
- Flexible capacity
When using logical volumes, the file system can be extended to multiple disks, and you can aggregate multiple disks or partitions into a single logical volume.
- A scalable storage pool;
You can use simple commands to enlarge or reduce the size of the logical volume without reformatting or partitioning the disk device.
- Online Redistribution of data
You can move data online, and the data can be reassigned on-disk. For example, you can replace hot-swappable disks online.
- Convenient naming of equipment;
A logical volume can be any name that you feel is convenient.
- Disk fragmentation
You can generate a logical disk whose data can be stored on 2 or more disks. This can significantly improve data throughput.
- Mirrored volumes
Logical volumes provide a convenient way to mirror your data.
- Volume snapshot
With logical volumes, you can get device snapshots for consistent backups or test data updates without impacting real data.
- Version:
LVM1 's initial LVM, released in 1998, is available only on the Linux kernel version 2.4, providing the most basic logical volume management.
The newer version of LVM2 LVM-1, available in Linux kernel 2.6, provides additional functionality outside of the standard LVM-1 functionality.
View version:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/7D/wKiom1XkZzvCPHu4AAEv5jyJu2s503.jpg "/>
- Basic LVM Terminology:
- Physical storage media (the physical media):
This refers to the system's storage devices, such as:/DEV/HDA1,/DEV/SDA, etc., is the storage system at the lowest level of storage units.
- Physical volume (PV, physical Volume):
A physical volume refers to a disk, a disk partition, or a device that logically has the same function as a disk partition (such as RAID), which is the basic storage logic block of LVM, but it contains management parameters related to LVM, compared to basic physical storage media such as partitions, disks, and so on. The current LVM allows you to save 0 to 2 copies of the metadata for this physical volume on each physical volume. The default is 1, which guarantees the beginning of the device. For 2 o'clock, save the second backup at the end of the device.
- Volume group (VG, Volume Group):
LVM volume groups are similar to physical hard disks in non-LVM systems, which consist of physical volumes. You can create one or more LVM partitions on a volume group (logical
volumes), the LVM volume group consists of one or more physical volumes.
- Logical volumes (LV, Logical Volume):
- LVM logical volumes are similar to hard disk partitions in non- LVM Systems, and file systems (such as/home or/usr) can be created on top of logical volumes.
- Linear logical volumes (Linear Volumes):
A linear logical volume aggregates multiple physical volumes into a single logical volume. For example, if you have two 60GB hard disks, you can generate 120GB of logical volumes.
- A striped logical volume (striped Logical Volumes)
When you write data into this logical volume, the file system can place data on multiple physical volumes. It can improve data I/O efficiency for a large number of connection read and write operations.
- Mirrored logical volumes (mirrored Logical Volumes)
Mirroring stores consistent data on different devices. The data is also written to both the original device and the mirror device. It provides fault tolerance between devices.
- Snapshot volume (Snapshot Volumes)
A snapshot volume provides a virtual image of a device at a given moment, and when the snapshot begins, it copies a change to the current data region, which allows it to refactor the state of the current device because it takes precedence over these changes.
- PE (physical extent)
Each physical volume is divided into a basic unit called the PE (physical extents), with a uniquely numbered PE being the smallest unit that can be addressed by LVM. The size of the PE is configurable and defaults to 4MB.
- LE (logical extent)
Logical volumes are also divided into addressable basic units called LE (Logical extents). In the same volume group, the size of Le is the same as the PE, and one by one corresponds.
and non-LVM systems The metadata that contains the partition information is saved in the partition table at the beginning of the partition, and the metadata related to the logical volume and volume group is also stored in the Vgda (Volume Group descriptor area) at the beginning of the physical volume. Vgda includes the following: PV descriptors, VG descriptors, LV descriptors, and some PE descriptors. When the system initiates LVM, the VG is activated and the Vgda is loaded into memory to identify the actual physical storage location of the LV. When the system does an I/O operation, the actual physical location is accessed based on the mapping mechanism established by VGDA.
- Module:
Physical volume (PV), Volume Group (VG), Logical volume (LV), physical extent (PE), we use a simple
The diagram illustrates the relationship between physical volumes, volume groups, and logical volumes: (The figure comes from the network)
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/79/wKioL1XkaVrR6ELiAAG6Ad5qsDA007.jpg "/>
A logical volume is created by creating physical volumes of multiple hard disks, and then assembling the physical volumes in a logical form, and then creating partitions of different sizes from within the container, which is called a volume group (VG), and a partition file of different sizes is created from this container, which is called the logical volume.
- action:
- partition:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/79/wKioL1XkaVqhIhDPAAFmXNazGK8416.jpg "/>
650) this.width=650;" Src= "http://s3.51cto.com/wyfs02/M01/72/7D/ Wkiom1xkzzzazcrkaaqdkvm_ebe307.jpg "/>
650) this.width=650;" Src= " Http://s3.51cto.com/wyfs02/M02/72/7A/wKioL1XkaVujzCOvAAFCRK4POiY709.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wy
Linux Learning Summary LVM2 detailed