Skip to content

Instantly share code, notes, and snippets.

@SWBSanjeewa
Last active July 30, 2018 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SWBSanjeewa/aeb32f0c92f009d2d55af204cfb7e76a to your computer and use it in GitHub Desktop.
Save SWBSanjeewa/aeb32f0c92f009d2d55af204cfb7e76a to your computer and use it in GitHub Desktop.
linux extend volume

Increase disk in vmware using vcenter

enter image description here

You need to reboot the host after extending the volume, Once reboot you can see the extended volume with fdisk -l command

Create physical volume

>fdisk /dev/sda
root@csl-jsl-04-prod:~# fdisk /dev/sda  
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n   // *add a new partition*
Partition type
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): p
Partition number (3,4, default 3):
First sector (999424-73400319, default 999424):
Last sector, +sectors or +size{K,M,G,T,P} (999424-1001469, default 1001469):
Created a new partition 3 of type 'Linux' and of size 1023 KiB.
Command (m for help): t    // *Change partition type of the partition just created from Linux to Linux LVM*
Partition number (1-3,5, default 5): 3    // *Be careful with suggested default, it may not be what you just created*
Partition type (type L to list all types): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): w

After physical volume add, you can see the total volume with pvscan command

Display volume group details

vdisplay

Volume group extend

vgextend cambio-system-vg /dev/sda4

Logical volume extend

lvextend -L+12G /dev/mapper/cambio--system--vg-root

Get volume information

pvs, pvscan, pvdisplay
vgs, vgscan, vgdisplay
lvs, lvscan, lvdisplay

Extend disk

resize2fs /dev/mapper/cambio--system--vg-root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment