|
通常情况下都是在已有硬盘建立卷组和逻辑卷,并且用掉硬盘的全部空间,然后,当要扩容时,都是添加一块新硬盘,用 vgextend 把新硬盘的空间添加进已有的卷组,然后再用 lvextend 扩展逻辑卷的大小。问题是,如果不是添加新硬盘,而是把已有硬盘容量扩大,怎么扩大在这个已有硬盘上卷组的大小呢?似乎不能用 vgextend 命令扩展已所在磁盘卷组的大小。
比如原有磁盘上有两个分区
/dev/sda1 挂载为 /boot 分区
/dev/sda2 上建立卷组,在卷组中建立两个逻辑卷,一个挂载为 / 分区,一个挂载为 /swap 分区。
现在扩大了 /dev/sda 整个磁盘的容量,怎么扩大 /dev/sda2 所在的卷组大小呢?
如
/dev/sda1 0x83
/dev/sda2 0x8e
现在扩大了整个 /dev/sda 磁盘的容量
但用 pvresize /dev/sda2 命令后
再用 pvs /dev/sda2 查看,发觉容量并没有增加。
原来整个磁盘大小为10G,后扩大到16G
# fdisk -l
Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a93d4
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 20971519 9436160 8e Linux LVM
Disk /dev/mapper/centos-root: 8585 MB, 8585740288 bytes, 16769024 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <9.00g 0
# pvresize -v /dev/sda2
Archiving volume group "centos" metadata (seqno 6).
Resizing volume "/dev/sda2" to 18872320 sectors.
No change to size of physical volume /dev/sda2.
Updating physical volume "/dev/sda2"
Creating volume group backup "/etc/lvm/backup/centos" (seqno 7).
Physical volume "/dev/sda2" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
再用 pvs 和 vgs 查看仍然没有 free 空间
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <9.00g 0
# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <9.00g 0
|
|