使用LVM对硬盘在线扩容

初始状态:

root@control:/dev/nova-volumes# vgdisplay
  --- Volume group ---
  VG Name               nova-volumes
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  62
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                9
  Open LV               7
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               5.44 TiB
  PE Size               4.00 MiB
  Total PE              1426108
  Alloc PE / Size       1361920 / 5.20 TiB
  Free  PE / Size       64188 / 250.73 GiB
  VG UUID               S0iZeL-0L6o-4Lbu-x2qZ-30bT-nGQ0-i9a8X1
root@control:/var/lib/glance/images# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/nova-volumes/novadata
  LV Name                novadata
  VG Name                nova-volumes
  LV UUID                ykTcoP-0Y0o-lGZe-LWZV-RX7n-lnnO-zpLPXp
  LV Write Access        read/write
  LV Creation host, time debian, 2013-07-03 10:42:31 +0800
  LV Status              available
  # open                 1
  LV Size                3.91 TiB
  Current LE             1024000
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0

 

 

首先通过lvresize命令将所有Free PE使用完:

lvresize -l +64188 /dev/nova-volumes/novadata

 

再对硬盘实现在线扩容(风险自负):

root@control:/dev/nova-volumes# resize2fs -p /dev/nova-volumes/novadata
resize2fs 1.42.5 (29-Jul-2012)
Filesystem at /dev/nova-volumes/novadata is mounted on /nova; on-line resizing required
old_desc_blocks = 250, new_desc_blocks = 266
Performing an on-line resize of /dev/nova-volumes/novadata to 1114304512 (4k) blocks.
The filesystem on /dev/nova-volumes/novadata is now 1114304512 blocks long.

 

结束状态:

root@control:/dev/nova-volumes# vgdisplay 
  --- Volume group ---
  VG Name               nova-volumes
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  77
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                9
  Open LV               7
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               5.44 TiB
  PE Size               4.00 MiB
  Total PE              1426108
  Alloc PE / Size       1426108 / 5.44 TiB
  Free  PE / Size       0 / 0   
  VG UUID               S0iZeL-0L6o-4Lbu-x2qZ-30bT-nGQ0-i9a8X1
root@control:/dev/nova-volumes# lvdisplay   
  --- Logical volume ---
  LV Path                /dev/nova-volumes/novadata
  LV Name                novadata
  VG Name                nova-volumes
  LV UUID                ykTcoP-0Y0o-lGZe-LWZV-RX7n-lnnO-zpLPXp
  LV Write Access        read/write
  LV Creation host, time debian, 2013-07-03 10:42:31 +0800
  LV Status              available
  # open                 1
  LV Size                4.15 TiB
  Current LE             1088188
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0

 

posted @ 2016-01-08 10:46  dongdonggeorge  阅读(440)  评论(0编辑  收藏  举报