LVM扩容

显示物理卷

[root@cim-kfxt-test02 /]# pvdisplay
— Physical volume —
PV Name /dev/sda2
VG Name vg_cimtest
PV Size 19.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4994
Free PE 0
Allocated PE 4994
PV UUID ntGhhT-dmW7-1tBC-odZT-t9g1-Tce3-QnbM3a

创建物理卷

[root@cim-kfxt-test02 /]# pvcreate /dev/sdb1
Physical volume “/dev/sdb1” successfully created

显示卷组

[root@cim-kfxt-test02 /]# vgdisplay
— Volume group —
VG Name vg_cimtest
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.51 GiB
PE Size 4.00 MiB
Total PE 4994
Alloc PE / Size 4994 / 19.51 GiB
Free PE / Size 0 / 0
VG UUID 8vcv0k-uDtg-TSzu-Zdn6-Bx4W-hWHo-zQ9h6H

将新创建的物理卷加入卷组

[root@cim-kfxt-test02 /]# vgextend vg_cimtest /dev/sdb1
Volume group “vg_cimtest” successfully extended

显示逻辑卷

[root@cim-kfxt-test02 /]# lvdisplay
— Logical volume —
LV Path /dev/vg_cimtest/lv_root
LV Name lv_root
VG Name vg_cimtest
LV UUID 3iJDhT-eNO3-2W1x-DB0g-NSTj-o3Av-KJbioU
LV Write Access read/write
LV Creation host, time cim-test, 2018-08-01 15:56:05 +0800
LV Status available
# open 1
LV Size 17.51 GiB
Current LE 4482
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

— Logical volume —
LV Path /dev/vg_cimtest/lv_swap
LV Name lv_swap
VG Name vg_cimtest
LV UUID CxjHhi-JiIR-xBMW-ado3-AbVv-SCFv-UngUds
LV Write Access read/write
LV Creation host, time cim-test, 2018-08-01 15:56:07 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

增加指定逻辑卷容量
1)给swap区增加7G

[root@cim-kfxt-test02 /]# lvextend -L +7g /dev/vg_cimtest/lv_swap
Size of logical volume vg_cimtest/lv_swap changed from 2.00 GiB (512 extents) to 9.00 GiB (2304 extents).
Logical volume lv_swap successfully resized.

2)把剩下的空间全部分给root

[root@cim-kfxt-test02 /]# lvextend -l +100%FREE /dev/vg_cimtest/lv_root
Size of logical volume vg_cimtest/lv_root changed from 17.51 GiB (4482 extents) to 610.50 GiB (156289 extents).
Logical volume lv_root successfully resized.

resize文件系统分区
1) swap分区处理

[root@cim-kfxt-test02 ~]# free -m
total used free shared buffers cached
Mem: 7872 2327 5544 0 183 1904
-/+ buffers/cache: 239 7632
Swap: 2047 0 2047
[root@cim-kfxt-test02 ~]# swapoff /dev/vg_cimtest/lv_swap
[root@cim-kfxt-test02 ~]# free -m
total used free shared buffers cached
Mem: 7872 2326 5545 0 183 1904
-/+ buffers/cache: 238 7633
Swap: 0 0 0
[root@cim-kfxt-test02 ~]# mkswap /dev/vg_cimtest/lv_swap
mkswap: /dev/vg_cimtest/lv_swap: warning: don’t erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 9437180 KiB
no label, UUID=1892572a-b48e-44cc-9068-b4b3d2b34808
[root@cim-kfxt-test02 ~]# swapon /dev/vg_cimtest/lv_swap
[root@cim-kfxt-test02 ~]# free -m
total used free shared buffers cached
Mem: 7872 2332 5539 0 183 1904
-/+ buffers/cache: 245 7627
Swap: 9215 0 9215

2) ext文件系统处理

[root@cim-kfxt-test02 /]# resize2fs /dev/vg_cimtest/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_cimtest/lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 39
Performing an on-line resize of /dev/vg_cimtest/lv_root to 160039936 (4k) blocks.
The filesystem on /dev/vg_cimtest/lv_root is now 160039936 blocks long.

注意:若该逻辑卷是xfs文件系统,则不能使用resize2fs,需要使用xfs_growfs /dev/vg_cimtest/lv_root
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值