The biggest advantage of LVM is that it can elastically adjust the file system capacity online. There is an active LV with a capacity of 100 MB. Now we are ready to resize this partition (note that the entire resizing operation is directly online without restarting) [root @ kashu ~] # Df-hT | grepkashu/dev/mapper/kashuVG-kashuLVext
The biggest advantage of LVM is yes.Online modeElastically adjusts the capacity of the file system.
There is an active LV with a capacity of 100 MB. Now we are ready to resize this partition (note that the entire resizing operation is directly online without restarting)
[Root @ kashu ~] # Df-hT | grep kashu
/Dev/mapper/kashuVG-kashuLV ext497 M5.6 M, 87 M, 7%/mnt/kashuLV
First, check the number of remaining PES in the VG where the LV is located, and find that there are many idle PES (229 idle PES ), then we can directly expand the remaining capacity of the VG to the existing LV.
[Root @ kashu ~] # Vgdisplay kashuVG
--- Volume group ---
VG Name kashuVG
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 2
VG Access read/write
VG Status resizable
Max lv 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 1016.00 MiB
PE Size 4.00 MiB
Total PE 254
Alloc PE/Size 25/100 .00 MiB
Free PE/Size 229/916 .00MiB
Vg uuid aWVKcm-2Z0m-S2d4-TDeg-m3g9-PWa8-3g7NzJ
For example, increase the original LV capacity by 100 MB.
[Root @ kashu ~] #Lvresize-L + 100 M/dev/kashuVG/kashuLV
Extending logical volume kashuLV to 200.00 MiB
Logical volume kashuLV successfully resized
After completing the above operations, we can immediately check the capacity of this LV, which has changed to 200 MB.
[Root @ kashu ~] #Lvdisplay/dev/kashuVG/kashuLV
--- Logical volume ---
LV Path/dev/kashuVG/kashuLV
LV Name kashuLV
VG Name kashuVG
Lvuuid RF3XbP-oEma-nWPE-X21d-4d9n-9spr-NYFfUq
LV Write Access read/write
LV Creation host, time kashu. localdomain, 2013-05-0700: 34: 37-0400
LV Status available
# Open 1
LV Size 200.00 MiB
Current LE 50
Segments 1
Allocation inherit
Read ahead sectors auto
-Currently sets to 256
Block device 253: 2
However, note that the available capacity of the real file system does not automatically increase. you will find that the partition is still 100 MB.
[Root @ kashu ~] #Df-hT | grep kashu
/Dev/mapper/kashuVG-kashuLV ext497 M5.6 M, 87 M, 7%/mnt/kashuLV
Therefore, we must also update the file system capacity through resize2fs:
[Root @ kashu ~] #Resize2fs/dev/kashuVG/kashuLV
Resize2fs 1.41.12 (17-May-2010)
Filesystem at/dev/kashuVG/kashuLV is mounted on/mnt/kashuLV; on-line resizing required
Old desc_blocks = 1, new_desc_blocks = 1
Ming an on-line resize of/dev/kashuVG/kashuLV to 204800 (1 k) blocks.
The filesystem on/dev/kashuVG/kashuLV is now 204800 blockslong.
Now, let's look at the partition and find that it has changed to MB. the expansion is successful!
[Root @ kashu ~] #Df-hT | grep kashu
/Dev/mapper/kashuVG-kashuLV ext4200 M5.6 M, 87 M, 7%/mnt/kashuLV
Well, the above LVM resizing is performed in the original VG with a lot of remaining PEs. what if the VG has no remaining PES? Next, let's give it a try.
The current kashuVG vg has no PE left.
[Root @ kashu ~] #Vgdisplay kashuVG
--- Volume group ---
VG Name kashuVG
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 2
VG Access read/write
VG Status resizable
Max lv 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 1016.00 MiB
PE Size 4.00 MiB
Total PE 254
Alloc PE/Size 254/1016 .00MiB
Free PE/Size 0/0
Vg uuid ZoDB2j-BygB-m4lC-0Ntd-KRRs-WGHW-Z4NFph
The VG consists of the/dev/sdb5 and/dev/sdb6 PVS.
[Root @ kashu ~] #Pvscan
PVS/dev/sdb5 VG kashuVG lvm2 [508.00 MiB/0 free]
PVS/dev/sdb6 VG kashuVG lvm2 [508.00 MiB/0 free]
PV/dev/sda2 VG VolGroup lvm2 [19.51 GiB/0 free]
Total: 3 [20.50 GiB]/in use: 3 [20.50 GiB]/in no VG: 0 [0]
Now, the partition is only 1 GB.
[Root @ kashu ~] #Df-hT | grep kashu
/Dev/mapper/kashuVG-kashuLV ext4 1001 M 18 M 932 M 2%/mnt/kashuLV
Okay. start resizing. First create a PV
[Root @ kashu ~] #Pvcreate/dev/sdb7
Writing physical volume data to disk "/dev/sdb7"
Physical volume "/dev/sdb7" successfully created
Check that a PV named/dev/sdb7 is larger than 1 GB.
[Root @ kashu ~] #Pvscan
PVS/dev/sdb5 VG kashuVG lvm2 [508.00 MiB/0 free]
PVS/dev/sdb6 VG kashuVG lvm2 [508.00 MiB/0 free]
PV/dev/sda2 VG VolGroup lvm2 [19.51 GiB/0 free]
PV/dev/sdb7 lvm2 [1.01 GiB]
Total: 4 [21.51 GiB]/in use: 3 [20.50 GiB]/in no VG: 1 [1.01 GiB]
Then, expand the new PV to the VG.
[Root @ kashu ~] #Vgextend kashuVG/dev/sdb7
Volume group "kashuVG" successfully extended
Check that the PV/dev/sdb7 has been added to the VG of kashuVG.
[Root @ kashu ~] #Pvscan
PV/dev/sdb5 VG kashuVG lvm2 [508.00MiB/0 free]
PV/dev/sdb6 VG kashuVG lvm2 [508.00MiB/0 free]
PV/dev/sdb7 VG kashuVG lvm2 [1.01GiB/1.01 GiB free]
PV/dev/sda2 VG VolGroup lvm2 [19.51 GiB/0 free]
Total: 4 [21.51 GiB]/in use: 4 [21.51 GiB]/in no VG: 0 [0]
In addition, the VG of kashuVG has changed from 1 GB to 2 GB, with 258 idle PES.
[Root @ kashu ~] #Vgdisplay kashuVG
--- Volume group ---
VG NameKashuVG
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 3
VG Access read/write
VG Status resizable
Max lv 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size 2.00 GiB
PE Size 4.00 MiB
Total PE 512
Alloc PE/Size 254/1016 .00MiB
Free PE/Size 258/1 .01GiB
Vg uuid ZoDB2j-BygB-m4lC-0Ntd-KRRs-WGHW-Z4NFph
Then resize the LV, and add 258 PES to this kashuLV (you can also use-L +NG to specify the capacity)
[Root @ kashu ~] #Lvresize-l + 258/dev/kashuVG/kashuLV
Extending logical volume kashuLV to 2.00 GiB
Logical volume kashuLV successfully resized
After the above operations, the actual file system capacity does not automatically grow! It's still 1 GB!
[Root @ kashu ~] #Df-hT | grep kashu
/Dev/mapper/kashuVG-kashuLV ext41001 M18 M 932 M 2%/mnt/kashuLV
Therefore, we must not forget to use resize2fs to fully scale up the capacity to the file system!
[Root @ kashu ~] #Resize2fs/dev/kashuVG/kashuLV
Resize2fs 1.41.12 (17-May-2010)
Filesystem at/dev/kashuVG/kashuLV is mounted on/mnt/kashuLV; on-line resizing required
Old desc_blocks = 1, new_desc_blocks = 1
Ming an on-line resize of/dev/kashuVG/kashuLV to 524288 (4 k) blocks.
The filesystem on/dev/kashuVG/kashuLV is now 524288 blockslong.
Now, let's take a look at this partition, which also increases to 2 GB. This completes the expansion!
[Root @ kashu ~] #Df-hT | grep kashu
/Dev/mapper/kashuVG-kashuLV ext42.0 GB18 M 1.9 GB 1%/mnt/kashuLV