[i=s] 本帖最后由 chenyx 于 2011-11-01 09:16 编辑 [/i]
试验环境:
vmware下,centos6,64位版本,原来系统默认分区,/dev/sda3是LogVol01,挂载到/上.新添加一个30G的硬盘sdb,将新加的硬盘容量扩充到原来的/上去.
试验步骤:
1.sdb分区,只分一个sdb1
2.在sdb1上创建pv
pvcreate /dev/sdb1
显示下pv的情况
[quote][root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name VolGroup
PV Size 18.80 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4813
Free PE 0
Allocated PE 4813
PV UUID r3DcdH-tavS-z0dy-bTcg-F5fz-F8MF-dpAjW3
\"/dev/sdb1\" is a new physical volume of \"30.00 GiB\"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 30.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 1Ynxmw-JblF-XAeE-ZKGD-0BSV-s7BL-SU1mql[/quote]
3.查看系统现在vg的情况
[quote][root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
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 18.80 GiB
PE Size 4.00 MiB
Total PE 4813
Alloc PE / Size 4813 / 18.80 GiB
Free PE / Size 0 / 0
VG UUID Xdh5kq-vKjk-nroE-Dssd-mi1h-SQGK-R07tOn[/quote]
4.扩容vg
vgextend VolGroup /dev/sdb1
正常会提示:Volume group \"VolGroup\" successfully extended
5.检查下扩容后vg的情况
[quote][root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 48.80 GiB
PE Size 4.00 MiB
Total PE 12492
Alloc PE / Size 4813 / 18.80 GiB
Free PE / Size 7679 / 30.00 GiB
VG UUID Xdh5kq-vKjk-nroE-Dssd-mi1h-SQGK-R07tOn[/quote]
6.查看下系统lv的情况
[quote][root@localhost ~]# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup/LogVol01
VG Name VolGroup
LV UUID IUVeUw-2bmN-mm3H-Gh16-fKaR-choS-IfSosr
LV Write Access read/write
LV Status available
# open 1
LV Size 16.80 GiB
Current LE 4301
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/VolGroup/LogVol00
VG Name VolGroup
LV UUID U9WYdb-xAdg-tCe1-FPxo-UyVe-v5Gp-a8UlZR
LV Write Access read/write
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[/quote]
7.扩容lv
[quote][root@localhost ~]# lvextend /dev/VolGroup/LogVol01 /dev/sdb1
Extending logical volume LogVol01 to 46.80 GiB
Logical volume LogVol01 successfully resized[/quote]
8.检查下扩容后的lv
[quote][root@localhost ~]# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup/LogVol01
VG Name VolGroup
LV UUID IUVeUw-2bmN-mm3H-Gh16-fKaR-choS-IfSosr
LV Write Access read/write
LV Status available
# open 1
LV Size 46.80 GiB
Current LE 11980
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/VolGroup/LogVol00
VG Name VolGroup
LV UUID U9WYdb-xAdg-tCe1-FPxo-UyVe-v5Gp-a8UlZR
LV Write Access read/write
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[/quote]
9.现在系统的分区情况如下,/没有扩容
[quote][root@localhost ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-LogVol01
17G 8.3G 7.5G 53% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/sda1 194M 25M 159M 14% /boot[/quote]
10.将/扩容
[quote][root@localhost ~]# resize2fs /dev/mapper/VolGroup-LogVol01
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-LogVol01 is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/VolGroup-LogVol01 to 12267520 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-LogVol01 is now 12267520 blocks long.[/quote]
11.扩容后分区的情况
[quote][root@localhost ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-LogVol01
47G 8.3G 36G 19% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/sda1 194M 25M 159M 14% /boot[/quote]
可以看到 /分区已经成功的从18G+,扩充到了47G