One: Introduction to LVM
LVM is logicalvolume Manager ( Logical Volume Management ). LVM is the organization of one or more underlying block devices into a logical
Tool that can dynamically add limitations when hard disk space is insufficient or redundant, with great flexibility.
It is to divide the underlying physical volume into multiple PE, which is again divided into logical volumes
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3E/D2/wKiom1PHy2PQ6pH_AAB4YhFa2s8671.jpg "title=" Image 2. PNG "alt=" wkiom1phy2pq6ph_aab4yhfa2s8671.jpg "/>
Physical Volume: This refers to the storage device: hard disk, such as:/DEV/SDA,/dev/sdb and other underlying units.
PE: The physical volume is divided into a unit of PE, the size is configurable, the default is 4MB
Volume Group: is a logical physical disk that can consist of multiple physical hard disks that can be created on top of a partition.
logical volumes: similar to partitions on a physical hard disk, created on a volume group.
Two: Create LVM Partitioning
1, create an LVM partition the same way you would create a generic partition, but be aware that the LVM partition number is 8e.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3E/D3/wKiom1PHy7Sh4pfXAAIotZrl7uw540.jpg "title=" Image 3. PNG "alt=" wkiom1phy7sh4pfxaaiotzrl7uw540.jpg "/>
To see if the creation was successful
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/3E/D3/wKioL1PHzQnDxKIeAAHw2dc94UA193.jpg "title=" Image 4. PNG "alt=" wkiol1phzqndxkieaahw2dc94ua193.jpg "/>
2, create PV
Before you create PV tools to create PV
Pvcreate: Creating PV
PVS: view PV equivalent to pvdisplay
Pvremove: Remove
Pvmove: Mobile
Pvscan: What PV is scanned
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/3E/D3/wKiom1PHzIeDh55DAABzjf84mzg738.jpg "title=" image 5. PNG "alt=" wkiom1phziedh55daabzjf84mzg738.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3E/D3/wKioL1PHzcnTP6foAABjqbUPpqY656.jpg "title=" image 6. PNG "alt=" wkiol1phzcntp6foaabjqbuppqy656.jpg "/>
3, create VG
Vgcreate: Create VG
-S specifies the PE size
VGS: view VG equivalent to vgdisplay
Vgremove: Remove VG
Vgmove: Moving VG
Vgextend: Extended VG
Vgreduce: Reduced VG
Vgscan: scanning an existing VG
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3E/D3/wKiom1PHzPSg-NhRAAGCdtoGbcs166.jpg "title=" Image 7. PNG "alt=" wkiom1phzpsg-nhraagcdtogbcs166.jpg "/>
3, creating the LV
Lvcreate: creating the LV
-nlv_name: Logical Volume name
-l#unit {MMGGTT}: specifying the logical volume size
Vg_name Volume Group name
LVS: view LV equivalent to lvdisplay
Lvremove: Remove LV
Lvmove: Moving LV
Lvextend: extended LV
Lvreduce: reducing LV
Lvscan: View LV
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3E/D3/wKioL1PHzrnCaahUAAC70UQppaU101.jpg "title=" Image 8. PNG "alt=" wkiol1phzrncaahuaac70uqppau101.jpg "/>
access Path to Lv:
1,/etc/vg_name/lv_name
/etc/myvg/mylv
2,/etc/mapper/vg_name-lv_name
/etc/mapper/myvg-mylv
path 1 and Path 2 are symbolic links, pointing to the file /dev/dm-#
Three: extending logical volumes
Create a file system for the logical volume to be created before extending the logical volume and mount it in a free directory
steps to extend a logical volume
1, First determine the size of the expansion target, and ensure that the corresponding volume group has sufficient space available
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3E/D3/wKioL1PHzz3QztkHAAC9-M7K_hs680.jpg "title=" Image 9. PNG "alt=" wkiol1phzz3qztkhaac9-m7k_hs680.jpg "/>
2, extend the physical boundary first
Lvextend–l [+] size has a plus sign for how much to extend, no to how much
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3E/D3/wKioL1PHz3SA85FOAAEefZ5oGaA017.jpg "title=" image 10. PNG "alt=" wkiol1phz3sa85foaaeefz5ogaa017.jpg "/>
at this point, only physical boundaries have been extended, and logical boundaries have not been extended .
3, extending logical Boundaries
RESIZE2FS [ can specify the size of the extension, do not specify the extension to maximum ]/dev/vg_name/lv_name
RESIZE2FS/DEV/MYVG/MYLV: logical size expands to maximum bounds
The result is:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3E/D3/wKioL1PHz7nxR8SVAADbl6EIrTs661.jpg "title=" image 11. PNG "alt=" wkiol1phz7nxr8svaadbl6eirts661.jpg "/>
Four: Reducing logical volumes
Note: The logical volume reduction is offline and the reduced space is able to accommodate the existing data
1, the first step umount unmount The mounted logical volume
2, determine the reduction target size, and ensure that the corresponding logical volume size space is sufficient
3, e2fsck–f Mandatory detection /DEV/MYVG/MYLV
4, First reduce the logical boundary
RESIZE2FS DEVICE size (reduced to how large)
5, reducing physical boundaries
Lvreduce–l [+] size /dev/myvg/mylv
reduction is dangerous, and operation takes care
V: Create a Snapshot volume
Lvcreate
-lsize: Specify Snapshot size
-n:name The name of the snapshot volume
-S: description is snapshot volume
-P: Specifies the access rights of the snapshot volume {r|rw}, the snapshot volume generally requires read-only, do not let the write operation
* The snapshot volume is on a logical volume and must be in the same volume group as the destination logical volume without specifying the volume group
ensure that the destination volume has sufficient space to accommodate the size of the snapshot volume
Example:lvreate–l512m–n mylv-snap–p r–s/dev/myvg/mylv
also ensure that directories mounted by/DEV/MYVG/MYLV are not modified by process access
method: Re-mount read-only
Mount–o REMOUNT,RO/DEV/MYVG/MYLV
Create a snapshot
re-mount for read-write
Mount–o REMOUNT,RW/DEV/MYVG/MYLV
Snapshot volume created successfully!
This article is from the "Aolens blocks until those" blog, be sure to keep this source http://aolens.blog.51cto.com/7021142/1439697