LVM: Logical volumn manager logical volume manager, an open-source software. It has two versions: LVM and lvm2. currently, lvm2 is commonly used, in essence, LVM uses the DM (device Mapper) module to organize one or more underlying Block devices into one logical device.
Physical Volume-PV
The physical volume is the lowest layer in the logical volume manager. any logical volume and volume group must be created by the physical volume. The physical volume can be a complete hard disk, it can also be a partition in the hard disk.
2 volume group-VG
A volume group is built on a physical volume. A volume group can contain one or more physical volume groups.
3 logical volume-LV
Logical volumes are created on a volume group. Multiple logical volumes can be created for the space in the volume group, and the logical volumes can be freely increased or decreased from the free space of the volume group, logical volumes can belong to one or multiple volume groups.
4 physical region-PE
The physical area is the smallest allocable storage unit in the physical volume. The minimum LVM addressing unit created by LVM commands on the physical volume can be specified when creating the physical volume, the default value is 4 m, or PE for short.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/3F/77/wKioL1PJTmGRlUdLAACM7_U4m6o286.jpg "Title =" 1.png" alt = "wkiol1pjtmgrludlaacm7_u4m6o286.jpg"/>
Bucket boundaries:
Physical boundaries:
Logical boundary
Expansion and reduction of logical Volume LV:
Extension: Expand the physical volume and then expand the logical volume.
Reduction: the logical volume is reduced first and then the physical volume is reduced.
Do not scale down to a smaller size than the data stored in it, which may cause data loss.
LVM:
PV --> VG --> LV usage
PV:
Pvcreate, PVS, pvdisplay, pvremove, pvmove, pvscan
VG:
Vgcreate, vgs, vgdisplay, vgremove, vgextend, vgreduce, vgscan
LV:
Lvcreate, LVS, lvdisplay, lvremove, lvextend, lvreduce, and lvscan
For example, create a 10 Gb logical volume.
First, create 2 partitions 4G + 6G in the SDB Disk
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3F/77/wKiom1PJTVyCzmeDAAJbiy6fpn8027.jpg "Title =" 2.png" alt = "wkiom1pjtvyczmedaajbiy6fpn8027.jpg"/>
Next we will make sdb1 and sdb2 physical volume 650) This. length = 650; "src =" http://s3.51cto.com/wyfs02/M02/3F/77/wKiom1PJTK7xu7IdAAAft7oW0Zc536.jpg "Title =" 3.png" width = "220" Height = "32" border = "0" hspace = "0" vspace = "0" style = "width: 220px; Height: 32px; "alt =" wkiom1pjtk7xu7idaaaft7ow0zc536.jpg "/> after creating a PV, let's take a look at the created PV.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/3F/77/wKioL1PJTbTBp6pAAABuyhtuha4205.jpg "Title =" 4.png" alt = "wkiol1pjtbp6paaabuyhtuha4205.jpg"/>
Create VG
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3F/77/wKiom1PJTMPy0lUDAACEQWtUB7c624.jpg "Title =" 5.png" alt = "wkiom1pjtmpy0ludaaceqwtub7c624.jpg"/>
Add another VG.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3F/77/wKioL1PJTfzj70feAACWb4CSKcI500.jpg "Title =" 6.png" alt = "wkiol1pjtfzj70feaacwb4cskci500.jpg"/>
Create 10 Gb LV
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/3F/77/wKiom1PJTPXTtPdhAADRw07dh8c070.jpg "Title =" 7.png" alt = "wkiom1pjtpxttpdhaadrw07dh8c070.jpg"/>
Create logical volume:
Lvcreate
-N lv_name
-L # unit {mmggtt}
Vg_name
LV access path:
1./dev/vg_name/lv_name
/Dev/myvg/mylv
2./dev/mapper/VG_NAME-LV_NAME
/Dev/mapper/myvg-mylv
Both are symbolic links and point to/dev/DM -#
Reducing is dangerous !!!!
Reduce to offline
1. Determine the target size after the reduction, and make sure that the target logical volume has enough space to accommodate all the original data;
2. First, sanction the file system and perform forced detection.
E2fsck-F
3. Reduce logical boundaries
Resize2fs Device
4. Reduce physical boundaries
Lvreduce
Snapshot: snapshot: when it comes to snapshot, you may want to restore the system with one click. the snapshot and data backup are a bit similar but different. It is similar to taking a photo and taking a photo of the data in the shortest time. We create a snapshot volume for the logical volume. After the snapshot volume is created, there is no data in it. It is actually another access portal for the original data. Only when the original data changes, it will cp the part of the data that is about to be changed to its disk.
Create a snapshot volume:
Lvcreate
-L
-N
-S
-P R
Note: The snapshot volume is a logical volume. Therefore, it must be in the same volume group as the target logical volume. You do not need to specify a volume group;
LVM logical volume manager