1. basic concept: physical volume (pv): a physical volume can be a hard disk or a partition on the hard disk. create a physical volume using pvcreate/dev/sdb1. volume Group (vg): a volume group consists of physical volumes. you can add or delete physical volumes to change the volume group size, A volume group can be regarded as a hard disk that can change the size in the traditional sense. logical volume (lv): logical volume is added to the volume group. basic concept: physical volume (pv): a physical volume can be a hard disk or a partition on the hard disk. create a physical volume using pvcreate/dev/sdb1.
Volume Group (vg): a volume group consists of physical volumes. you can add or delete physical volumes to change the volume group size, A volume group can be regarded as a hard disk that can change the size in the traditional sense.
Logical volume (lv): repartitioning a logical volume group is equivalent to a hard disk partition that can be freely changed in the traditional sense.
2. Basic operations
Create pv
# Pvcreate/dev/sdb2/dev/sdb3
Physical volume "/dev/sdb2" successfully created
Physical volume "/dev/sdb3" successfully created
Create vg
# Vgcreate vg1/dev/sdb1/dev/sdb2/dev/sdb3
Volume group "vg1" successfully created
Activate vg
# Vgchange-a y vg1
0 logical volume (s) in volume group "vg1" now active
Append pv to vg
# Vgextend vg1/dev/sdb5
Volume group "vg1" successfully extended
Remove pv from vg (not recommended)
View pv usage
# Pvdisplay/dev/sdb1
--- Physical volume ---
PV Name/dev/sdb1
VG Name vg1
PV Size 48.00 MB/not usable 0
Allocatable yes
PE Size (KByte) 40Array6
Total PE 12
Free PE 12
Allocated PE 0
Pvuuid ncdQHn-wRWW-pCJR-2siv-SXSY-vCxq-FBfWrw
View the vg status
# Vgdisplay vg1
--- Volume group ---
VG Name vg1
System ID Format lvm2
Metadata Areas 4
Metadata Sequence No 2
VG Access read/write
VG Status resizable
Max lv 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 4
Act PV 4
VG Size 1Array2. 00 MB
PE Size 4.00 MB
Total PE 48
Alloc PE/Size 0/0 Free PE/Size 48/1 Array2. 00 MB
Vg uuid QzdArrayqI-5oeA-23bArray-FLls-W2Ra-73Arrayg-vw36XW
Create LV
# Lvcreate-L100M-nlv1 vg1
Logical volume "lv1" created to view the created LV
Lvdisplay
--- Logical volume ---
LV Name/dev/vg1/lv1
VG Name vg1
Lvuuid ezmFx2-svKD-EVNV-rZxY-HS6P-vnd3-QArrayKKOR
LV Write Access read/write
LV Status available
# Open 0
LV Size 100.00 MB
Current LE 25
Segments 3
Allocation inherit
Read ahead sectors 0
Block device 253: 2
Format LV
# Mkfs. ext3-B 40Array6/dev/vg1/lv1
Mke2fs 1.35 (28-Feb-2004)
Filesystem label =
OS type: Linux
Block size = 40Array6 (log = 2)
Fragment size = 40Array6 (log = 2)
25600 inodes, 25600 blocks
1280 blocks (5.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks = 2Array360128
Block group
32768 blocks per group, 32768 fragments per group
25600 inodes per groupWriting inode tables: done Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mountsor
180 days, whichever comes first. Use tune2fs-c or-I tooverride.
Mount LV
# Mount/dev/vg1/lv1/mnt
Check the current system partition. we can see that the current lv1 size is 100 MB.
[Root @ ha1 ~] # Df
Filesystem 1K-blocks Used AvailableUse % Mounted on
/Dev/mapper/VolGroup00-LogVol00
3451040 2644664 631068 81%/
/Dev/sda1 101086 Array181 86686 10%/boot
None required array88 0 required array88 0%/dev/shm
/Dev/mapper/vg1-lv1 ArrayArray184 4152 8ArrayArray12 5%/mnt
Expand the LV size
# Lvextend-L50M/dev/vg1/lv1
Rounding up size to full physical extent 52.00 MB
New size given (13 extents) not larger than existingsize (25 extents)
Lvextend: Add space to a logical volume
This error indicates that the new size is smaller than the previous one, and the index cannot be extended. The new size we specified must be greater than the original size, or we can use + 50 m to increase the size.
For example
# Lvextend-L120M/dev/vg1/lv1
Extending logical volume lv1 to 120.00 MB
Logical volume lv1 successfully resized or
# Lvextend-L + 20 M/dev/vg1/lv1
Extending logical volume lv1 to 120.00 MB
When Logical volume lv1 successfullyresized is used, we can see the size of each partition, which is the same as before and has not increased.
# Df
Filesystem 1K-blocks Used AvailableUse % Mounted on
/Dev/mapper/VolGroup00-LogVol00
3451040 2644668 631064 81%/
/Dev/sda1 101086 Array181 86686 10%/boot
None required array88 0 required array88 0%/dev/shm
/Dev/mapper/vg1-lv1 ArrayArray184 4152 8ArrayArray12 5%/mnt in LVM2, the most convenient place is that with ext2online, we can change its size without uninstalling the original LVM.
# Ext2online/dev/vg1/lv1
Ext2online v1.1.18-2001/03/18 for EXT2FS0.5b then check the partition size. you can see that lv1 has changed to 120M.
# Df
Filesystem 1K-blocks Used AvailableUse % Mounted on
/Dev/mapper/VolGroup00-LogVol00
3451040 2644668 631064 81%/
/Dev/sda1 101086 Array181 86686 10%/boot
None required array88 0 required array88 0%/dev/shm
/Dev/mapper/vg1-lv1 11Array664 4152 1103Array2 4%/mnt
If the VG space of the LV is not enough, it will not be displayed during lvextend. the prompt is displayed only during ext2online:
Ext2online/dev/vg1/lv1
Ext2online v1.1.18-2001/03/18 for EXT2FS 0.5b
Ext2online: ext2_ioctl: No space left on deviceext2online: unableto resize/dev/mapper/vg1-lv1
LV reduction
We have mentioned that the LV can be dynamically adjusted. since it can be expanded, it can be reduced. you can use lvreduce to perform this operation.
Lvreduce-L-50M/dev/vg1/lv1
Rounding up size to full physical extent 48.00 MB
WARNING: switching active and open logical volume toArray2.00 MB
This may destroy your data (filesystem etc .)
Do you really want to reduce lv1? [Y/n]: y
Elastic Cing logical volume lv1 to Array2.00 MB
Logical volume lv1 successfully resized
Similarly, you also need to use ext2online to make the change take effect.
It is risky to reduce the lv. generally, do not reduce the lv.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service