Skip to main content

Extend disk with vsphere

Add disk space to the vm on vsphere first then run:

fdisk –l

Enter then follow the instruction bellow to format the newly space added:

[root@ubuntu ~]# fdisk /dev/sda
 Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
 Be careful before using the write command.

Command (m for help): n
 Partition type:
    p   primary (3 primary, 0 extended, 1 free)
    e   extended
 Select (default e): p
 Selected partition 4
 First sector (62914560-104857599, default 62914560):
 Using default value 62914560
 Last sector, +sectors or +size{K,M,G} (62914560-104857599, default 104857599):
 Using default value 104857599
 Partition 4 of type Linux and of size 20 GiB is set
 
 Command (m for help): t
 Partition number (1-4, default 4):
 Hex code (type L to list all codes): 8e
 Changed type of partition 'Linux' to 'Linux LVM'

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 or after you run partprobe(8) or kpartx(8)
 Syncing disks.

Then add this new space to the partition

fdisk -l
partprobe
vgdisplay
vgextend <vg> <partition>
pvscan
lvextend /dev/mapper/<lv> <partition>