First, what is LVM :
LVM (Logical Volume Manager)
LVM is the short name of the Logical Disk volume management (Logical Volume Manager), which is a mechanism for managing disk partitions in a Linux environment, and LVM is a logical layer on top of hard disks and partitions to improve the flexibility of disk partition management. LVM is a logical layer that is added between the disk partition and the file system to mask the underlying disk partition layout for the file system, providing an abstract disk volume, and creating a file system on the disk volume.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6B/F5/wKiom1U7XEPw8cAmAACde6q2Nyg291.jpg "title=" Lvm.png "alt=" Wkiom1u7xepw8camaacde6q2nyg291.jpg "/>
Several concepts:
PV (physical volume ): Physical volume refers to the hard disk partition or a device that logically has the same functionality as a disk partition (such as RAID) , is the basic storage logic block of LVM.
PE (physical extent): The disk area, each physical volume is divided into a basic unit called PE, with a unique number of PE is can be LVM the smallest unit. The size of the PE is configurable addressing, which defaults to 4MB.
VG (Volume Group): Volume group, multiple physical volumes are mapped into storage spaces that cannot be used directly and need to be divided into logical storage spaces at a time.
LV (Logical volume): A logical volume, equivalent to a non-LVM system disk partition, on which a file system can be created.
Ii. Logical volume creation (including physical volumes, volume groups, creation of logical volumes)
Basic process: Prepare the disk partition, use the Pvcreate command to create the physical volume, then use the vgcreate command to create the volume group, and finally use the Lvcreate command to create the logical volume.
A detailed example describes:
1. Preparing partitions
Prepare two partitions/dev/sdb1 and/DEV/SDB2, type tuning to Linux LVM, capacity size 3GB and 5GB, respectively, create partition procedure omitted.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6B/F6/wKiom1U7eRSQ6iGdAABhqF1eLUE425.jpg "title=" 192013.png "alt=" Wkiom1u7ersq6igdaabhqf1elue425.jpg "/>
2. Create a physical volume
Create code: pvcreate/dev/sdb{1,2}
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6B/F2/wKioL1U7fJbw8_fDAABxHyYqEl4706.jpg "title=" 193120.png "alt=" Wkiol1u7fjbw8_fdaabxhyyqel4706.jpg "/>
Use the PVS command to view the physical volumes that were created, and you can see that the physical volumes are not assigned
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6B/F6/wKiom1U7fPSyQ75jAABsoe-mkQY313.jpg "title=" 193720.png "alt=" Wkiom1u7fpsyq75jaabsoe-mkqy313.jpg "/>
3. Create a volume group
Create code: Vgcreate-s 8M MYVG/DEV/SDB1
Explanation: The size of the specified PE is 8M and the volume group is named MYVG
You can expand the volume group space at this time
Extension code: Vgextend MYVG/DEV/SDB2
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6B/F6/wKiom1U7gQWjZs8GAACNoCyTKGA523.jpg "title=" 195619.png "alt=" Wkiom1u7gqwjzs8gaacnocytkga523.jpg "/>
With Vgdisplay, you can see that the volume group is about 10GB and the size of the extents is 8M
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6B/F2/wKioL1U7hJayfW7BAAAfNhb1pY0789.jpg "title=" 200528.png "alt=" Wkiol1u7hjayfw7baaafnhb1py0789.jpg "/>
4. Creating a logical Volume
Create code: Lvcreate-l 2g-n mylv MYVG
Explanation: Specifies that the size of the created logical volume is 2GB, created on the volume group MYVG, and The logical volume name is MYLV
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6B/F6/wKiom1U7hzKhZ01gAACsVym9A0c829.jpg "title=" 202237.png "alt=" Wkiom1u7hzkhz01gaacsvym9a0c829.jpg "/>
Here, the logical volume has been created and can be formatted for use!
Format code: MKE2FS-T EXT4/DEV/MYV/MYLV
Explanation: The filesystem type of the specified logical volume for mylv This logical volume creation file system is EXT4
Note: The logical volume creation is complete with a device file that has two access paths:
(1)/dev/mapper/myvg-mylv
(2)/dev/myvg/mylv
Both are symbolic connections, all pointing to/dev/dm-2 this device file
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6B/F6/wKiom1U7i0iRr2M5AACbQWMy5Lo577.jpg "title=" 203746.png "alt=" Wkiom1u7i0irr2m5aacbqwmy5lo577.jpg "/>
Iii. Extending and shrinking logical volumes
Extended reduction logical volumes follow a sequential sequence:
Extension: Extend the physical boundary first, and then extend the logical boundary
Shrink: Reduce logical boundaries first, then shrink physical boundaries
To extend the logical volume basic process:
1. Determine the target size of the extension and ensure that sufficient free space is available in the corresponding volume group
Use VGs to view:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6B/F3/wKioL1U7mTuxo5NaAABaGFEGFSA890.jpg "title=" 213335.png "alt=" Wkiol1u7mtuxo5naaabagfegfsa890.jpg "/>
The volume group is also idle about 8GB, feasible.
2. Extending physical boundaries
Extension code: Lvextend-l 4g/dev/myvg/mylv
Explanation: Extending physical boundaries to 4GB
3. Extending logical boundaries
Extension code: RESIZE2FS/MYVG/MYLV
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6B/F7/wKiom1U7mNHgQ0UHAAEdsJpjbB8751.jpg "title=" 213749.png "alt=" Wkiom1u7mnhgq0uhaaedsjpjbb8751.jpg "/>
LVS View Extended results:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6B/F3/wKioL1U7mz3zBx6pAACjnnsx03I452.jpg "title=" 214219.png "alt=" Wkiol1u7mz3zbx6paacjnnsx03i452.jpg "/>
To reduce the logical volume basic process:
1. determine the reduced target size, and ensure that there is enough space in the corresponding target logical volume to accommodate all of the original data
2. Unmount the mounted logical volume first and force the detection
Detection code: E2FSCK-F/DEV/MYVG/MYLV
3. Reducing logical boundaries
Reduced code: RESIZE2FS 3G/DEV/MYVG/MYLV
Explanation: Reducing logical boundaries to 3GB
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6B/F7/wKiom1U7ne2j0nxxAAEpKnK9dOs475.jpg "title=" 215933.png "alt=" Wkiom1u7ne2j0nxxaaepknk9dos475.jpg "/>
LVS View the results of the reduction:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6B/F7/wKiom1U7noHxdozkAACfHkI43vU872.jpg "title=" 220200.png "alt=" Wkiom1u7nohxdozkaacfhki43vu872.jpg "/>
Four: Removing logical and physical volumes
1. unmount The mounted logical volume first
2. Delete all logical volumes within the volume group
Code: Lvremove MYVG
3. Deleting a volume group
Code: Vgremove MYVG
3. Deleting physical volumes
Code: pvremove/dev/sdb{1,2}
Conclusion: first knowledge of LVM, detailed records, errors and omissions, please the great God to criticize, thank you.
This article is from the "6127098" blog, please be sure to keep this source http://xugen.blog.51cto.com/6117098/1638376
Linux LVM Detailed