Saturday, May 30, 2015

linux - Resizing LVM partition for KVM guest

I've created LVM partition for the KVM guest. The KVM guest is also using LVM partitions itself.




The initial size of the guest's LVM partition was 160GB on the hypervisor. I've extended to 200GB.



I've rebooted the guest and it recognized the new size:



    # fdisk -l

Disk /dev/vda: **214.7 GB**, 214748364800 bytes
16 heads, 63 sectors/track, 416101 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c1b11

Device Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 332882 167259136 8e Linux LVM
Partition 2 does not end on cylinder boundary.

Disk /dev/mapper/vg_main-lv_root: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_main-lv_root doesn't contain a valid partition table

Disk /dev/mapper/vg_main-lv_swap: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_main-lv_swap doesn't contain a valid partition table

Disk /dev/mapper/vg_main-lv_mysql: 158.4 GB, 158385307648 bytes
255 heads, 63 sectors/track, 19255 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_main-lv_mysql doesn't contain a valid partition table


However I'm not able to extend the physical volume to allocate the new space for LVM on the guest machine (/dev/mapper/vg_main-lv_mysql):



# pvresize -v /dev/vda2

Using physical volume(s) on command line
Archiving volume group "vg_main" metadata (seqno 17).
Resizing volume "/dev/vda2" to 334516224 sectors.
No change to size of physical volume /dev/vda2.
Updating physical volume "/dev/vda2"
Creating volume group backup "/etc/lvm/backup/vg_main" (seqno 18).
Physical volume "/dev/vda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...