Extend CentOS partition with no reboot
(Additional 5GB disk in this example)
First create a new disk in VMware and attach it to the server, then on the server run the following commands:
df – find the partition you want to increase in size.
lvdisplay – locate the partition, underneath should be the volume group, make a note of it.
run fdisk -l and find the disk you just added, it should be the one with no partitions (If it is not showing run the following)
which should return hostX (usually host0) followed by
echo “- – -” > /sys/class/scsi_host/hostX/scan
where hostX is the host from the previous command, usually host0
(You might see multiple entries even if you just have one controller, but you’re safe to scan all of them, it will usually just be host0 that picks it up.)
You should now see the additional disk when running the command: fdisk –l
These commands should be run after adding the new disk but before the rest of the commands.
run fdisk /dev/sdX, (it may be hdX or vdX depending on your system) where X is the new disk.
Create a new partition on it pressing the following:
This should have created the partition, now do the following:
This should have set the partition type to Linux LVM, now the following:
This should have written it out
Now to make it ready for LVM
pvcreate /dev/sdX1, (it may be hdX1 or vdX1 again depending on your system)
To add it to the volume group (which you should know from earlier)
vgextend yourvolumegroupname /dev/sdX1
Once this is done, you’ll then see the additional space when using df