LVM
The full name of LVM is logical volume manager. The reason for becoming a volume is that it can stretch or shorten the file system like a volume. LVM combines several physical partitions or disks into a large independent disk (VG) through software, and then partitions the disk, it is divided into usable partitions (LV) and can be mounted and used.
PV physical volume
We need to adjust the system identifier (System ID) to 8E (LVM identifier) for our actual partitions ), the PV can be exploited only after the pvcreate command converts it to the physical volume (PV) at the bottom of the LVM.
VG volume User Group
The so-called LVM large disk is to integrate many PVS into this VG, so VG is a large disk combined by LVM. What is the maximum capacity of a large disk? This is related to PES because each VG can contain only 65534 PES at most. If you use the default LVM parameter, a VG can have up to GB capacity.
Fast physical expansion of PE
By default, LVM uses 4 mb pe blocks, while lvm vg can contain up to 65535 PES, which is the smallest storage block in the entire LVM. That is to say, in fact, all our file data is processed by writing PE. Simply put, this PE is a bit like the block size in the file system.
LV logical volume
The VG will be cut into Lv, which is the similar partition that can be formatted and used. The LV size cannot be specified at will. The LV size is related to the total number of PES in the LV, for example:
650) This. width = 650; "Title =" 37w4pnnl6av} ~ W0mt3n1_qp.jpg "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKioL1PGmFfzdTt9AAEj6yKa3D4292.jpg "alt =" wkiol1pgmffzdtt9aaej6yka3d4292.jpg "/>
LVM can elastically change the capacity of the file system by exchanging PES for data conversion. Transfer the PES in the original LV to other devices to reduce the LV capacity, or add the PES of other devices to the LV to Increase the capacity.
If the VG is to be expanded, add other PVS. In the end, if the LV is to be expanded, it is also extended by adding the pe that is not used in the VG.
Command and example
First, partition the disk and set the disk type to 8E. In fact, it does not matter if it is not set to 8E. However, some Linux commands may not detect this partition.
650) This. width = 650; "Title =" w_ckx] tz3w7p8ks] % ~ V9 ~ Ri.jpg "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKiom1PGl-niV7f5AAFzSbTEPXY936.jpg "alt =" wKiom1PGl-niV7f5AAFzSbTEPXY936.jpg "/>
PV stage
Pvcreate: create a physical partition as PV.
Pvscan: view any disk with PV in the current system
Pvdisplay: displays the current PV status on the system.
Pvremove: Delete the PV attribute so that the partition does not have the PV attribute.
# Pvcreate/dev/SDB {1, 2}
650) This. width = 650; "Title =" dlk1_71_81__ceksvc798m1ey2.jpg "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKiom1PGmGOBbkaAAACGoVT8Vv0761.jpg "alt =" wkiom1pgmgobbkaaaacgovt8vv0761.jpg "/>
# Pvscan
650) This. width = 650; "Title =" 'w9tzup (_ 10 ~ Vs000000002performance0000ii.jpg "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKiom1PGmMPC-mRWAACZfWa74J4134.jpg "alt =" wKiom1PGmMPC-mRWAACZfWa74J4134.jpg "/>
# Pvdisplay
650) This. width = 650; "Title =" G (I4 ~ 10q1_q1_1_cw5gk1_9x1tl.jpg "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKioL1PGmhXyJe0ZAAG_t9A7ViY142.jpg "alt =" wkiol1pgmhxyje0zaag_t9a7viy142.jpg "/>
VG stage
Vswitchrete: The command used to create the VG.
Vgscan: Check whether VG exists in the system.
Vgdisplay: displays the VG status on the current system.
Vgextend: add additional PV in VG
Vgreduce: delete PV in VG
Vgchange: sets whether VG is started.
Vgremove: delete a VG
# Vgcreate-S 8 m kyvg/dev/sdb1 create a new VG and specify the PE size as 8 m. The exam name is kyvg. Here I add sdb1 first.
650) This. width = 650; "Title =" [3 $ c26e1od % {@ 9z43c2b ~ 62. jpg "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKioL1PGmw-z4CBgAABRXSQ1mK0086.jpg "alt =" wKioL1PGmw-z4CBgAABRXSQ1mK0086.jpg "/>
# View the current information of VG in vgs. One PV is displayed, and the size is 5 GB.
650) This. width = 650; "Title =" 0qgi74kya8h%7@cxpu%1lxc.jpg "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKiom1PGmjKQChwgAABh5EhwbE0485.jpg "alt =" wkiom1pgmjkqchwgaabh5ehwbe0485.jpg "/>
# Vgxtend kyvg/dev/sdb2 now I will add sdb2 TO THE kyvg group and check it
# Vgs: you can confirm that sdb2 has been added to the volume group.
650) This. width = 650; "Title =" 2h1y7 ['t % (~ Kihon dkj9rw.o.jpg "src =" http://s3.51cto.com/wyfs02/M02/3E/3D/wKioL1PGm7DzSYdQAACUuMCPj-o037.jpg "alt =" wKioL1PGm7DzSYdQAACUuMCPj-o037.jpg "/>
# Pvdisplay from here we can see that sdb1 and sdb2 have been added to the volume group. when creating the volume group (VG), the specified PE size is 8 Mb. It is equivalent to storing files of GB in this volume group.
650) This. width = 650; "Title ="] 1cf29m0my $ 7due_nkihu ~ Y.jpg "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKioL1PGnC6AHvvDAAG7L54Wix4062.jpg "alt =" wkiol1pgnc6ahvvdaag7l54wix4062.jpg "/>
LV stage
After creating VG, you can create a new partition. This partition is called LV.
Lvcreate: Create an LV
Lvscan: view the LV ON THE SYSTEM
Lvdisplay: displays the LV status on the system.
Lvextend: Increase the capacity in the LV
Lvreduce: reduce the capacity in the LV
Lvremove: delete an LV
# Lvcreate-L 2G-N mylv/dev/kyvg create a new LV in the volume group. The name is mylv and the size is 2G.
650) This. width = 650; "Title =" c0000t7(%w_ca'icueurcdklbl.jpg "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKioL1PGnW2ytoj4AABJIkWqjtY838.jpg "alt =" wkiol1pgnw2ytoj4aabjikwqjty838.jpg "/>
# Lvdisplay
650) This. width = 650; "Title = "~ A5xglfbn%o0(%kg%f7%ere.jpg "src =" http://s3.51cto.com/wyfs02/M02/3E/3D/wKiom1PGnIzBburZAAFYczPzsLU780.jpg "alt =" wkiom1pgnizbburzaafyczpzslu780.jpg "/>
LV access path
1./dev/vg_name/lv_name
/Dev/kyvg/mylv
2./dev/mapper/VG_NAME-LV_NAME
/Dev/mapper/kyvg-mylv
Both are symbolic links and point to/dev/DM -#
650) This. width = 650; "Title =" pno9gt13w3164ejuajxsa410k3y.jpg "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKiom1PGnhKyDKvoAAD_CjEZnt8825.jpg "alt =" wkiom1pgnhkydkvoaad_cjeznt8825.jpg "/>
Now that the partition is created, You Can format and mount it.
# Mke2fs-T ext4/dev/kyvg/mylv format mylv Partition
# Mount/dev/kyvg/mylv/tmp/KY mount the mylv partition to the/tmp/KY directory
# DF-H view the disk information and find that the disk is successfully created
650) This. width = 650; "Title =" fuk'%k%xnwhb'%r5lt@t25.jpg "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKioL1PGn6PShJgQAAEo_K3g2NQ156.jpg "alt =" wkiol1pgn6pshjgqaaeo_k%2nq156.jpg "/>
650) This. width = 650; "Title =" g862'cokim%5@7f%7e2r%e0.jpg "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKioL1PGn9ahMKyjAAEdotsJhIE307.jpg "alt =" wkiol1pgn9ahmkyjaaedotsjhie307.jpg "/>
LV Extension
To expand the LV space, first check the VG space and whether there is any idle space (new PE. If no free space is available, add PV to the kyvg exam.
I can see that there is free space and 8 GB space for expansion. I am doing an experiment here and extending it to 3G space to 5 GB.
650) This. width = 650; "Title =" fq1jdp4r ~ B1_2_4r0dc1_xgsi.jpg "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKioL1PGoO_Tkmr2AABhKViXFQs039.jpg "alt =" wkiol1pgoo_tkmr2aabhkvixfqs039.jpg "/>
First, we need to expand the border for the LV to add 3G space for the LV.
650) This. width = 650; "Title =" @ B (m {z ~ Gw.$cs'h(%9'yzvdw.jpg "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKioL1PGoYbyWgGPAABQnFNV29A056.jpg "alt =" wkiol1pgoybywggpaabqnfnv29a056.jpg "/>
Check the logical volume information. At this time, we can see that the LV actually increases by 3 GB to 5 GB, but let's check the disk space information.
650) This. width = 650; "Title =" 3wjsmolfgz5p5tzh1_v8cqiq.jpg "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKiom1PGoLnQkxCHAACaSFWj9ao177.jpg "alt =" wkiom1pgolnqkxchaacasfwj9ao177.jpg "/>
650) This. width = 650; "Title =" 26g5w'%0uy(tt1e%obt2t8k.jpg "src =" http://s3.51cto.com/wyfs02/M02/3E/3D/wKioL1PGohqjmkLfAADn1Olu_2U476.jpg "alt =" wkiol1pgohqjmklfaadn1olu_2u476.jpg "/>
This is still 2 GB. This is because the file system is not relatively increased, so we need to directly process it online without umount.
650) This. width = 650; "Title =" 7acvt1__h1_bdth1_6p0u79yy6.jpg "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKioL1PGomOADc7HAADRyiLO0TQ250.jpg "alt =" wkiol1pgomoadc7haadryilo0tq250.jpg "/>
Check LVS to complete online processing. The extension ends here.
650) This. width = 650; "Title =" o468x@6hrmd2b_exe%i0%39.jpg "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKiom1PGoYnCUNWwAAD0-zDkHa4147.jpg "alt =" wKiom1PGoYnCUNWwAAD0-zDkHa4147.jpg "/>
LV reduction
If the LV score is too high and space is wasted, we can also reduce the LV space. Note that the LV space must be reduced offline. Therefore, umount is required first
# Umount/tmp/KY
First, force detection of the file system to ensure that there is no problem and the file system is being reduced.
Determine the target size after the reduction. Make sure that the target logical volume has enough space to accommodate all the original data. It is dangerous to reduce the size! Proceed with caution!
650) This. width = 650; "Title =" 4qiq?vjwb= I 'm9ot%e4a%a4.jpg "src =" http://s3.51cto.com/wyfs02/M02/3E/3D/wKioL1PGo2WzA_I1AADwkzRJOpg529.jpg "alt =" wkiol1pgo2wza_i1aadwkzrjopg529.jpg "/>
After the problem persists, scale down the space from 5 GB to 3 GB.
650) This. width = 650; "Title =" e_k1_77jp1_p1_1_1rtryrm@vbh.jpg "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKiom1PGoofzNNK0AACUvvl8TZI065.jpg "alt =" wkiom1pgoofznnk0aacuvvl8tzi065.jpg "/>
Mount the file first, and check again. The reduction ends now. The reduction is very dangerous and the consequences are very serious.
650) This. width = 650; "Title =" 52%7%i23%7%(%f%9hqy'3%n.jpg "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKioL1PGo-XwRyRJAADxHNTsM-s999.jpg "alt =" wKioL1PGo-XwRyRJAADxHNTsM-s999.jpg "/>
This article from the fish blog, please be sure to keep this source http://kyfish.blog.51cto.com/1570421/1439234