CentOS 5.X LVM 在线扩容根分区
时间:2015-05-07 03:03 来源:linux.it.net.cn 作者:IT
说明:
Linux 2.6以上内核支持ext3的在线扩容
第一种情况:直接添加一个新硬盘
# df -h 看看现在硬盘的情况
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
6.7G 5.2G 1.3G 81% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 633M 0 633M 0% /dev/shm
# fdisk -l 可以看到新添加的硬盘/dev/sdb
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1044 8281507+ 8e Linux LVM
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
# lvm
lvm>vgdisplay 可以先看卷组是否还有剩余空间可以扩展,有的话直接扩展,没有或不够的话把新的硬盘添加进去
--- Volume group ---
VG Name VolGroup00
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 7.88 GB
PE Size 32.00 MB
Total PE 252
Alloc PE / Size 252 / 7.88 GB
Free PE / Size 0 / 0
VG UUID 0U8dPB-UTJZ-Mdv5-eZJM-Xj7f-gR1M-63BcCh
lvm>pvcreate /dev/sdb 使用新的整个硬盘创建一个lvm物理卷
lvm>vgextend /dev/VolGroup00 /dev/sdb 把新的物理卷添加到卷组中
lvm>vgdisplay 可以看到已分配空间和剩余未分配空间 All PE / Size 和 Free PE / Size
--- Volume group ---
VG Name VolGroup00
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 15.84 GB
PE Size 32.00 MB
Total PE 507
Alloc PE / Size 252 / 7.88 GB
Free PE / Size 255 / 7.97 GB
VG UUID 0U8dPB-UTJZ-Mdv5-eZJM-Xj7f-gR1M-63BcCh
lvm>lvextend -L +7.9G /dev/VolGroup00/LogVol00 扩展逻辑卷大小
lvm>vgdisplay
lvm>pvdisplay
lvm>lvdisplay 可以看到已经添加了
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID QtNkTM-TeSo-WnZD-fSUr-6k1F-5aLX-zAIfSQ
LV Write Access read/write
LV Status available
# open 1
LV Size 14.78 GB
Current LE 473
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID bhTEBX-t8XK-zGku-NCzx-eolz-Anvj-jUMUER
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
lvm>quit
# resize2fs -p /dev/VolGroup00/LogVol00 修改文件系统大小以实现扩充空间
# df -h
第二种情况:只添加一个新分区
# df -h 可以看到新添加的硬盘/dev/sdb1
# lvm
lvm>pvcreate /dev/sdb1 使用新的硬盘创建一个lvm物理卷
lvm>vgextend /dev/VolGroup00 /dev/sdb1
lvm>vgdisplay 可以看到已分配空间和剩余未分配空间 All PE / Size 和 Free PE / Size
lvm>lvextend -L +5G /dev/VolGroup00/LogVol00
lvm>vgdisplay
lvm>pvdisplay
lvm>lvdisplay
lvm>quit
# resize2fs -p /dev/VolGroup00/LogVol00 扩展
# df -h (责任编辑:IT)
说明: Linux 2.6以上内核支持ext3的在线扩容 第一种情况:直接添加一个新硬盘 # df -h 看看现在硬盘的情况 Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 6.7G 5.2G 1.3G 81% / /dev/sda1 99M 12M 82M 13% /boot tmpfs 633M 0 633M 0% /dev/shm # fdisk -l 可以看到新添加的硬盘/dev/sdb Disk /dev/sda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1044 8281507+ 8e Linux LVM Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table # lvm lvm>vgdisplay 可以先看卷组是否还有剩余空间可以扩展,有的话直接扩展,没有或不够的话把新的硬盘添加进去 --- Volume group --- VG Name VolGroup00 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 7.88 GB PE Size 32.00 MB Total PE 252 Alloc PE / Size 252 / 7.88 GB Free PE / Size 0 / 0 VG UUID 0U8dPB-UTJZ-Mdv5-eZJM-Xj7f-gR1M-63BcCh lvm>pvcreate /dev/sdb 使用新的整个硬盘创建一个lvm物理卷 lvm>vgextend /dev/VolGroup00 /dev/sdb 把新的物理卷添加到卷组中 lvm>vgdisplay 可以看到已分配空间和剩余未分配空间 All PE / Size 和 Free PE / Size --- Volume group --- VG Name VolGroup00 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 15.84 GB PE Size 32.00 MB Total PE 507 Alloc PE / Size 252 / 7.88 GB Free PE / Size 255 / 7.97 GB VG UUID 0U8dPB-UTJZ-Mdv5-eZJM-Xj7f-gR1M-63BcCh lvm>lvextend -L +7.9G /dev/VolGroup00/LogVol00 扩展逻辑卷大小 lvm>vgdisplay lvm>pvdisplay lvm>lvdisplay 可以看到已经添加了 --- Logical volume --- LV Name /dev/VolGroup00/LogVol00 VG Name VolGroup00 LV UUID QtNkTM-TeSo-WnZD-fSUr-6k1F-5aLX-zAIfSQ LV Write Access read/write LV Status available # open 1 LV Size 14.78 GB Current LE 473 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Name /dev/VolGroup00/LogVol01 VG Name VolGroup00 LV UUID bhTEBX-t8XK-zGku-NCzx-eolz-Anvj-jUMUER LV Write Access read/write LV Status available # open 1 LV Size 1.00 GB Current LE 32 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 lvm>quit # resize2fs -p /dev/VolGroup00/LogVol00 修改文件系统大小以实现扩充空间 # df -h 第二种情况:只添加一个新分区 # df -h 可以看到新添加的硬盘/dev/sdb1 # lvm lvm>pvcreate /dev/sdb1 使用新的硬盘创建一个lvm物理卷 lvm>vgextend /dev/VolGroup00 /dev/sdb1 lvm>vgdisplay 可以看到已分配空间和剩余未分配空间 All PE / Size 和 Free PE / Size lvm>lvextend -L +5G /dev/VolGroup00/LogVol00 lvm>vgdisplay lvm>pvdisplay lvm>lvdisplay lvm>quit # resize2fs -p /dev/VolGroup00/LogVol00 扩展 # df -h (责任编辑:IT) |