Another take on Dynamic Volume Resize in RHEL 6
Being able to resize an LVM volume without reboot is quite handy. I had described one way here. This is a slightly different take on the same topic, this time on RHEL 6.
I had resized /dev/sdb from 48GB to 140GB in vCenter. However, the operating system is still seeing the old size:
[root@build ~]# fdisk -l /dev/sdb Disk /dev/sdb: 48.3 GB, 48318382080 bytes 64 heads, 32 sectors/track, 46080 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000a
To get RHEL to see the new size, device rescan is needed:
[root@build ~]# cd /sys/class/block/sdb/device [root@build ~]# echo "- - -" > rescan
The difference this time is that you do not need to look for the correct HBA and LUN number. You can just go by the device name. Now the operating system should see the correct disk size:
[root@build device]# fdisk -l /dev/sdb Disk /dev/sdb: 198.6 GB, 198642237440 bytes 255 heads, 63 sectors/track, 24150 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
Now you can proceed with resizing the physical volume and the logical volume. You can throw in -t switch to do a dry run:
[root@build device]# pvresize /dev/sdb Physical volume "/dev/sdb" changed 1 physical volume(s) resized / 0 physical volume(s) not resized [root@build device]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 system lvm2 a-- 19.47g 3.00g /dev/sdb vg_app lvm2 a-- 185.00g 140.00g
The size is correct now. Finally, resize the logical volume. Again, you can throw in -t switch to do a dry run:
[root@build device]# lvresize -r -l+100%FREE /dev/mapper/vg_app-lv_app Size of logical volume vg_app/lv_app changed from 45.00 GiB (11519 extents) to 140.00 GiB (35840 extents). Logical volume lv_app successfully resized resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/mapper/vg_app-lv_app is mounted on /var/www/html/repo; on-line resizing required old desc_blocks = 3, new_desc_blocks = 9 Performing an on-line resize of /dev/mapper/vg_app-lv_app to 36700160 (4k) blocks. The filesystem on /dev/mapper/vg_app-lv_app is now 36700160 blocks long.