Cluster 24. Resizing LVM image of the Virtual Machine.
On guest:
fdisk -l /dev/vda
Resize LV to be 20GB:
lvresize -L 21474836480b /dev/agrp-c01n02_vg0/vm-test
Size of logical volume agrp-c01n02_vg0/vm-test changed from 15.00 GiB (3840 extents) to 20.00 GiB (5120 extents).
Logical volume agrp-c01n02_vg0/vm-test successfully resized.
fdisk -l /dev/vda
Resize LV to be 20GB:
lvresize -L 21474836480b /dev/agrp-c01n02_vg0/vm-test
Size of logical volume agrp-c01n02_vg0/vm-test changed from 15.00 GiB (3840 extents) to 20.00 GiB (5120 extents).
Logical volume agrp-c01n02_vg0/vm-test successfully resized.
Find domain ID:
virsh list
Id Name State
----------------------------------------------------
1 vm-test running
Resize vda of the guest:
virsh blockresize --path /dev/agrp-c01n02_vg0/vm-test --size 21474836480b 1
Block device '/dev/agrp-c01n02_vg0/vm-test' is resized
On guest - check that vda is resized to the needed size:
lsblk -a | grep ^vda
vda 252:0 0 20G 0 disk
View last partition index (here it's 2 because of vda2) on the guest:
lsblk -a | grep vda
vda 252:0 0 20G 0 disk
├─vda1 252:1 0 500M 0 part /boot
└─vda2 252:2 0 14.5G 0 part
Find end of the last partition (text in bold is end - 31208) on the guest:
fdisk -l
Disk /dev/vda: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 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: 0x000a4595
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 31208 15215616 8e Linux LVM
Create new partition vda3 on the guest:
fdisk /dev/vda
input n letter # for creating new partition
input p # for primary partition
input 3 # for new partition index
input 31208 # for "First cylinder (1-41610, default 1):"
enter # to accept "Last cylinder, +cylinders or +size{K,M,G} (31208-41610, default 41610):"
input w # to save
View current partition table on the guest:
partx -l /dev/vda
Re-read partition table:
partx -a /dev/vda # this will give "BLKPG: Device or resource busy" for already added partition
Check that we have device nodes for /dev/sdb itself and the partitions on it:
ls /dev/vda*
/dev/vda /dev/vda1 /dev/vda2 /dev/vda3
Create PV and verify on the guest:
pvcreate /dev/vda3
Physical volume "/dev/vda3" successfully created
pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 VolGroup lvm2 a-- 14.51g 0
/dev/vda3 lvm2 --- 5.00g 5.00g
Extend VG with new PV nad verify:
vgextend VolGroup /dev/vda3
Volume group "VolGroup" successfully extended
pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 VolGroup lvm2 a-- 14.51g 0
/dev/vda3 VolGroup lvm2 a-- 5.00g 5.00g
Extend LV size to the all available free space on the guest:
lvextend -l +100%FREE /dev/VolGroup/lv_root
Size of logical volume VolGroup/lv_root changed from 13.01 GiB (3330 extents) to 18.00 GiB (4609 extents).
Logical volume lv_root successfully resized
Verify on the guest:
lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_root VolGroup -wi-ao---- 18.00g
lv_swap VolGroup -wi-ao---- 1.50g
Resize file system on the guest:
For ext type filesystem:
For ext type filesystem:
resize2fs /dev/VolGroup/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/VolGroup/lv_root to 4719616 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 4719616 blocks long.
For xfs filesystem:
xfs_growfs /dev/VolGroup/lv_root
For xfs filesystem:
xfs_growfs /dev/VolGroup/lv_root
Verify on guest:
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 18G 9.3G 7.5G 56% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/vda1 477M 48M 405M 11% /boot
No comments:
Post a Comment