أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
As this method focuses on working with LVM, we will first confirm that our partition type is actually Linux LVM by lvdisplay
We now need to partition the disk so that it can be used, this is done by using fdisk.
fdisk /dev/<disk name>
Then we need to create the physical volume by using the command
pvcreate <disk name>
Once the Physical volume created we need to verify that by using pvdisplay
Now we need to identify the volume group and volume that we need to extend by using the command vgdisplay and lvdisplay
Once the group is identified we need to extend the VG (volume group) by vgextend <Group Name> <disk name or partition>
Using the pvscan command we scan all disks for physical volumes, this should confirm the original partition and the newly created physical volume
Next we need to increase the logical volume (rather than the physical volume) which basically means we will be taking our original logical volume and extending it over our new partition/physical volume.
Firstly confirm the name of the logical volume using lvdisplay and extend that disk by using lvextend <Logical volume name> <disk or partition name>
There is then one final step which is to resize the file system so that it can take advantage of this additional space, this is done using the resize2fs command. Note that this may take some time to complete, it took about30 seconds for my additional space.
Go through below steps might be helpful in this regards :
# df -hTo see the current disk usage# fdisk -lTo see the current partitioning# poweroffTurn the VM off so we can extend the disk on the VM side. For physical servers you would just be adding a new SAS/SATA disk to the chassis or adding a LUN on a SAN and presenting it which does *not* necessarily require a poweroffIntermission to add new disk and power on if necessary# fdisk -lTo see the new disk size on /dev/sda which we just extended, or to see new disks we just presented (/dev/sdb, /dev/sdc, etc.)# fdisk /dev/sdaTo create new partitions for the OS to use. These new partitions will be added to the VG so we can extend the LV that the “/” partition is on. My newly created partition in the example is /dev/sda3. For new disks you would use /dev/sdb, or /dev/sdc. If you are using an extended /dev/sda like in my case, you will need to reboot for the changes to be seen# fdisk -lTo see the new partitions# pvdisplayView current physical volumes a.k.a. pv# pvcreate /dev/sda3Allow Linux OS to use the new partition in LVM# pvdisplaySee the new pv /dev/sda3# vgdisplayView the current volume groups# vgextend vg_cents6364bit /dev/sda3Add the new PV /dev/sda3 to the existing VG vg_cents6364bit# vgdisplayNow you can see the new size of the VG vg_cents6364bit. Note the new amount of free PE’s (physical extents)# lvdisplayView the current LV. In my example, /dev/vg_cents6364bit/lv_root which is the root partition# lvextend -l +2559 /dev/vg_cents6364bit/lv_rootNow make the LV larger. Growing the LV /dev/vg_cents6364bit/lv_root by2559 PEs# lvdisplayNow you can see the larger size of the LV# resize2fs /dev/vg_cents6364bit/lv_rootOnline resize of the actual filesystem now on that LV# df -h
LVM extension through lvextend command. Before expanding, we need to identify the free space from physcial hard disk through pvs command. Eg: /dev/sda1 have disk space then identify the logical volume group name from lvs command.
lvextend +SizeG LogicalVolume DiskName
Eg: lvextend -L +6G /dev/VolGroup00/LogVol04 /dev/sda5
This will expand disk space from physical disk