1

I have extended a thick virtual hard disk to 80 GB under vSphere for a CentOS virtual server.

I need to extend the logical volume to maximum allowed. The physical sda2 is currently only recognizing 63.25 GB.

LV       VG          Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
LogVol00 vg_cpanel02 -wi-ao----  4.00g
LogVol01 vg_cpanel02 -wi-ao---- 59.25g


PV         VG          Fmt  Attr PSize  PFree
/dev/sda2  vg_cpanel02 lvm2 a--u 63.25g    0
1

In short, the steps are:

Reboot or rescan the scsi bus:

echo '1' > /sys/class/scsi_disk/0\:0\:0\:0/device/rescan

Identify the correct disk:

fdisk -l

This will be something like /dev/sda or /dev/vda.

Create a new partition with fdisk and label it as LVM (replace sdx with the correct disk):

fdisk /dev/[sdx]
Press p to print the partition table to identify the number of partitions.
Press n to create a new primary partition.
Press p for primary.
Press a number for the partition number, depending on the output of the partition table print.
Press Enter two times.
Press t to change the system's partition ID.
Press the number of the just created partition.
Type 8e to change the Hex Code of the partition for Linux LVM.
Press w to write the changes to the partition table.

Create a new PV (replace sdx and 0 with the correct disk and partition):

pvcreate /dev/[sdx][0]

Extend the VG with the new PV:

vgextend vg_cpanel02 /dev/[sdx][0]

Extend the correct LV with all the available size (make sure this is the correct LV!):

lvextend -l +100%FREE /dev/vg_cpanel02/LogVol00

Now, the LV will be resized, the only thing left is to resize the filesystem. You can use xfs_grow or resize2fs for this operation, depending on your used filesystem.

Expanding disks is shortly explained in the VMWare documentation:

https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006371

The full documentation for LVM in CentOS is here:

https://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/index.html

Please, be careful. Reread your commands before pressing enter and test in a test environment if you are not sure you are doing the right thing!

  • The existing disk is /dev/sda2 which has live data on it. Will running pvcreate on /dev/sda2 cause it harm? – Ash Jul 19 '16 at 5:29
  • Then sda2 is already a pv, so no need to pvcreate this partition. You have to make a new partition with fdisk first to make use of the added free space. This will probably become sda3, then you can pvcreate that partition. The vmware documentation explains these steps in detail. – Martin Pas Jul 19 '16 at 7:07
  • Thank you for your help. Your steps + youtu.be/KW1ScgdCIfs worked. – Ash Jul 20 '16 at 4:34
0

Sometimes you need do difrent scans for detect new r resized disk without reboot

Scan device

#list devices
ls /sys/class/scsi_device/
#rescan device 
echo 1 > /sys/class/scsi_device/0\:0\:0\:0/device/rescan
#another type rescan device 
echo "- - -" > /sys/class/scsi_host/host#/scan

ps rebbot is the best if you can reboot machine .

after scan dmesg schouls show you infromation about change

resize disk

after scan column PFree schould schow free space

# and you now schoul have option resize lvm 
 lvextend -l +100%FREE /dev/vg_cpanel02/LogVol01
#  and resize file system
 resize2fs /dev/vg_cpanel02/LogVol01
  • I tried the scan device commands but without luck. pvs is still indicating that /dev/sda2 is 63.25 GB in size. – Ash Jul 19 '16 at 5:25
  • could you check you clscc scsi_device ls /sys/class/scsi_device/ – Dzaczek Jul 19 '16 at 18:42
  • and make rescan echo 1 > /sys/class/scsi_device/<on all you devices :)>/device/rescan – Dzaczek Jul 20 '16 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.