LVM最大的特性就是可以弹性调整磁盘容量
下面扩展一个已经存在的LV
[root@ol6-121-rac1 mnt]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_ol6121rac1/lv_root
LV Name lv_root
VG Name vg_ol6121rac1
LV UUID dahhMU-zPic-pKVq-3fan-YPCb-PlA6-JeWqe2
LV Write Access read/write
LV Creation host, time ol6-121-rac1.localdomain, 2014-03-17 12:00:59 +0800
LV Status available
# open 1
LV Size 9.54 GiB
Current LE 2442
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
--- Logical volume ---
LV Path /dev/vg_ol6121rac1/lv_swap
LV Name lv_swap
VG Name vg_ol6121rac1
LV UUID W3DHZp-o2wE-e49m-VJy0-4CYh-ZcMn-CRrtPf
LV Write Access read/write
LV Creation host, time ol6-121-rac1.localdomain, 2014-03-17 12:01:01 +0800
LV Status available
# open 2
LV Size 1.97 GiB
Current LE 504
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1
[root@ol6-121-rac1 mnt]#
扩展VG
[root@ol6-121-rac1 mnt]# vgextend vg_ol6121rac1 /dev/sdb{1,2}
Volume group "vg_ol6121rac1" successfully extended
[root@ol6-121-rac1 mnt]# vgdisplay
--- Volume group ---
VG Name vg_ol6121rac1
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 21.50 GiB
PE Size 4.00 MiB
Total PE 5504
Alloc PE / Size 2946 / 11.51 GiB
Free PE / Size 2558 / 9.99 GiB
VG UUID 5S3HpA-qT3U-ZSt7-AUZf-DUVs-oTAf-xByhje
[root@ol6-121-rac1 mnt]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_ol6121rac1
PV Size 11.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 2946
Free PE 0
Allocated PE 2946
PV UUID YEG40A-wEWW-9F8Z-bgcL-PWvA-7sef-FP12my
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg_ol6121rac1
PV Size 5.01 GiB / not usable 2.10 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 1282
Free PE 1282
Allocated PE 0
PV UUID p2nXS7-MmpX-Pawj-ThU3-k1NQ-t5Rc-hqKtb4
--- Physical volume ---
PV Name /dev/sdb2
VG Name vg_ol6121rac1
PV Size 4.99 GiB / not usable 2.60 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 1276
Free PE 1276
Allocated PE 0
PV UUID M31k1o-JGJx-3OrN-DmNf-W8uJ-SXBB-JdSviW
[root@ol6-121-rac1 mnt]#
扩展LV
[root@ol6-121-rac1 mnt]# lvresize -L +9.99G /dev/
Display all 183 possibilities? (y or n)
[root@ol6-121-rac1 mnt]# lvresize -L +9.99G /dev/vg
vga_arbiter vg_ol6121rac1/
[root@ol6-121-rac1 mnt]# lvresize -L +9.99G /dev/vg_ol6121rac1/lv_root
Rounding size to boundary between physical extents: 9.99 GiB
Extending logical volume lv_root to 19.53 GiB
Logical volume lv_root successfully resized
[root@ol6-121-rac1 mnt]#
[root@ol6-121-rac1 mnt]#
[root@ol6-121-rac1 mnt]#
[root@ol6-121-rac1 mnt]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_ol6121rac1-lv_root
9.4G 3.9G 5.1G 44% /
tmpfs 499M 100K 499M 1% /dev/shm
/dev/sda1 485M 55M 405M 12% /boot
/dev/sr0 3.5G 3.5G 0 100% /media/OL6.4 x86_64 Disc 1 20130225
[root@ol6-121-rac1 mnt]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_ol6121rac1/lv_root
LV Name lv_root
VG Name vg_ol6121rac1
LV UUID dahhMU-zPic-pKVq-3fan-YPCb-PlA6-JeWqe2
LV Write Access read/write
LV Creation host, time ol6-121-rac1.localdomain, 2014-03-17 12:00:59 +0800
LV Status available
# open 1
LV Size 19.53 GiB
Current LE 5000
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
--- Logical volume ---
LV Path /dev/vg_ol6121rac1/lv_swap
LV Name lv_swap
VG Name vg_ol6121rac1
LV UUID W3DHZp-o2wE-e49m-VJy0-4CYh-ZcMn-CRrtPf
LV Write Access read/write
LV Creation host, time ol6-121-rac1.localdomain, 2014-03-17 12:01:01 +0800
LV Status available
# open 2
LV Size 1.97 GiB
Current LE 504
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1
完整的讲LV扩充到整个文件系统
[root@ol6-121-rac1 mnt]# resize2fs /dev/vg_ol6121rac1/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_ol6121rac1/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/vg_ol6121rac1/lv_root to 5120000 (4k) blocks.
The filesystem on /dev/vg_ol6121rac1/lv_root is now 5120000 blocks long.
[root@ol6-121-rac1 mnt]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_ol6121rac1-lv_root
20G 3.9G 15G 22% /
tmpfs 499M 100K 499M 1% /dev/shm
/dev/sda1 485M 55M 405M 12% /boot
/dev/sr0 3.5G 3.5G 0 100% /media/OL6.4 x86_64 Disc 1 20130225