If you ever need to resize a device on a Unix like system and are using LVM as the underlying mediator and ext2/3/4 as the file system, it can be done without a reboot. This is quite handy for ESX and other virtual machines.
Before doing all that comes, please resize the “physical” device – in our case the virtual disk in ESX
Mind you, this only works if and when the “physical” disk is used by LVM as RAW device. You have to resize the partition (e.g. /dev/sda2), if the LVM resides on a partition. You can check this by issuing
# fdisk -l Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000f06be Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 104857599 51379200 8e Linux LVM
-
First, we need to identify the resized disk. In our case, this is /dev/sdb
echo 1 > /sys/class/block/sdb/device/rescan
-
If you omit any flags, the LVM partition will fill the whole device
pvresize /dev/sdb
-
Here, the boundaries for the LV need to be set explicitly
lvresize -L 35000 /dev/vg_appl/lv_storage
-
File system resize can be once again done without any flags and it will fill the whole LV.
resize2fs /dev/vg_appl/lv_storage