LVM Introduction:
LVM is a logical mechanism for managing disk partitions in a Linux system, which can dynamically adjust disk capacity while keeping existing data intact, thereby increasing disk flexibility.
To create a process:
PV (physical volume, physical volume) →VG (volume Group, Volume Group) →LV (logical volume, logical volume)
Create a logical volume by first creating a physical volume, forming a volume group of physical volumes, and extracting space from the volume group!
LVM Common management Commands
Function |
PV Management Commands |
VG Management Command |
LV Management Commands |
Scan scanning |
Pvscan |
Vgscan |
Lvscan |
Create Create |
Pvcreate |
Vgcreate |
Lvcreate |
Display Displays |
Pvdisplay |
Vgdisplay |
Lvdisplay |
Remove Delete |
Pvremove |
Vgremove |
Lvremove |
Extend extension |
Pvextend |
Vgextend |
Lvextend |
Reduce reduction |
Pvreduce |
Vgreduce |
Lvreduce |
Lab Environment:
In adding 3 hard drives, 2 blocks do the logical volume, 1 blocks do the expansion!
Experimental steps:
Perform the "fdisk-l" command first to view the disk number
Create physical volume, format "pvcreate Disk absolute path"
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/CB/wKiom1XtRErAQ1zcAAEECP5O35Y415.jpg "title=" BYS817 } @N8}7}c${qwg[s[4.png "alt=" Wkiom1xtreraq1zcaaeecp5o35y415.jpg "/>
Using "Pvscan" to display all physical volume information in the system, "pvdisplay" details all physical volume information in the system:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/CB/wKiom1XtRdqQ2IJkAAD3ydvN0H8550.jpg "title=" X3XIC32KJ35Y]W[0A9) h8t7.png "alt=" Wkiom1xtrdqq2ijkaad3ydvn0h8550.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/C8/wKioL1XtSDLgTGTTAAM2Wg7Xtf8351.jpg "title=" 547er0a5$~j2$y2@lz_k (mg.png "alt=" Wkiol1xtsdlgtgttaam2wg7xtf8351.jpg "/>
Delete physical volume, format "Pvremove disk path"
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/C8/wKioL1XtSXPj7VG0AABNw4XPwZY760.jpg "title=" x3u~$ Yn]w0_f0l877@kft%1.png "alt=" Wkiol1xtsxpj7vg0aabnw4xpwzy760.jpg "/>
Create Volume group, format "Vgcreate volume group Name Physical volume path"
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/C8/wKioL1XtSjqx_UT7AAGMk4yMPjo073.jpg "title=" 0@ Cszdxs7iq}53229y8]0gi.png "alt=" Wkiol1xtsjqx_ut7aagmk4ympjo073.jpg "/>
Create a logical volume, format "lvcreate-l capacity Size-N Logical Volume name volume group name"
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/CB/wKiom1XtSb6CudqCAAB5uhmdg1Q602.jpg "title=" X4ITVMPZ4}BC1 ([ab77}{sb.png "alt=" Wkiom1xtsb6cudqcaab5uhmdg1q602.jpg "/>
After the creation is complete, you need to format it before you can mount the
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/CC/wKiom1XtT3LAiX2BAABQuGI2wVs745.jpg "title=" NY ' 4_ C1ZIL7I9BJ}MR ($L 9u.png "alt=" Wkiom1xtt3laix2baabqugi2wvs745.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/CC/wKiom1XtT9vRZy70AAByb2DQZFg505.jpg "title=" 1uyr[3 }6697uaer) pj6t14g.png "alt=" Wkiom1xtt9vrzy70aabyb2dqzfg505.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/C9/wKioL1XtUmnDbJfOAAHyWXSB6ls921.jpg "title="%50{5] _ ' 9_5p[grvo0}x8u9.png ' alt= "wkiol1xtumndbjfoaahywxsb6ls921.jpg"/>
Expanding logical volumes
The expansion format is "Lvextend-l + size/dev/Volume group name/Logical volume name"
Logical volume expansion, from which volume group to take the space can only from which volume group capacity non-spanned volume group
Because there is no space in my volume group, you can only create a new physical volume and then expand the volume group to scale the logical volume
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/CC/wKiom1XtTMDzMAYhAAJWYbUozAY963.jpg "title=" [(xb$ Gmlva[9l~blwon8830.png "alt=" Wkiom1xttmdzmayhaajwybuozay963.jpg "/>
To view the logical volume size using "Lvdisplay"
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/CC/wKiom1XtTfqwxtLhAAKbu_c9ZhM741.jpg "title=" 4fzb@2qk]]t9p_@0wa () 1o9.png "alt=" Wkiom1xttfqwxtlhaakbu_c9zhm741.jpg "/>
Use "Df-ht" to discover available space or only 19G
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/C9/wKioL1XtVALwTM1DAAHzFvZV_BU508.jpg "title=" w$s{a8 $Y 2njl7p9g ' ($42p2.png "alt=" Wkiol1xtvalwtm1daahzfvzv_bu508.jpg "/>
Use the resize2fs/dev/volume group name/logical volume name to adjust the file system size online.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/CD/wKiom1XtUmHDIQgyAAPzh9V_EG4115.jpg "title=" Ln9sk6tllf24kp7i_kmim5j.png "alt=" Wkiom1xtumhdiqgyaapzh9v_eg4115.jpg "/>
Note: 1. After the system restarts, the disk will be re-mounted, and you can modify the/etc/fstab file for automatic mounting.
2. The logical volume has been mounted do not use the "lvreduce" command to reduce the space capacity, reduce the need for formatting before it can be used normally. All data is lost!
This article from "Sunj" blog, declined reprint!
"Red Hat Linux" LVM Logical Volume management