Let’s suppose you have a production VM, and for some reason you need to increase the space of one of the vDisks you are using, and then add as a physical volume for it’s usage through LVM, all of this has to happen on the fly, without a reboot.
Step 1: Go to VMware Vcenter, hit the settings for the VM, locate the vDisk and increase the space. (easy huh?)
Step 2: Re-scan your disk, for the new size to be visible:
fdisk -l /dev/sdc Disk /dev/sdc: 51.5 GB, 51539607552 bytes 255 heads, 63 sectors/track, 6266 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
echo 1 > /sys/class/scsi_device/0\:0\:2\:0/device/rescan
Note: your system device may be different.
Disk /dev/sdc: 85.8 GB, 85899345920 bytes 255 heads, 63 sectors/track, 10443 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Step 3: Create an additional primary partition on the Disk for the recently added space.
fdisk /dev/sdc The number of cylinders for this disk is set to 10443. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (6267-10443, default 6267): Using default value 6267 Last cylinder or +size or +sizeM or +sizeK (6267-10443, default 10443): Using default value 10443 Command (m for help): p Disk /dev/sdc: 85.8 GB, 85899345920 bytes 255 heads, 63 sectors/track, 10443 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc1 1 6266 50331613+ 8e Linux LVM /dev/sdc2 6267 10443 33551752+ 8e Linux LVM Note: Set the System as Linux LVM on the new partition
Step 4: Write the new partition
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks.
Step 5: As you can see in the last step, the system it’s complaining about a reboot needed for the kernel to “see” the new partition. You can avoid the unneeded reboot with this command:
[root@host ~]# partprobe [root@host ~]# [root@host ~]# ls /dev/sdc sdc sdc1 sdc2
Step 6: Now you have an additional partition in your disk, it’s just a matter of add it as a physical volume and expand your volume group with it:
[root@host ~]# pvcreate /dev/sdc2 Physical volume "/dev/sdc2" successfully created [root@host ~]# vgextend VolGroup00 /dev/sdc2 Volume group "VolGroup00" successfully extended
and you are done! now you just need to increase or add new logical volumes…