Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xarmengol/3f37b9ee13d639cd03f60ba713af8ec8 to your computer and use it in GitHub Desktop.
Save xarmengol/3f37b9ee13d639cd03f60ba713af8ec8 to your computer and use it in GitHub Desktop.
How to increase partition disk on vmware CentOS 8

Steps to increase the disk for a vmware centos 8 server

1. Increase the virtual machine disk by using vCenter

Increase the disk space of the machine, using vCenter. If there is any existing snapshot, this could not be done. So any existing snapshot have to be deleted previously.

Not sure if needed, but once the disk space is increased, reboot the machine.

2. Create a new partition disk by using fdisk

# fdisk /dev/sda
    press 'n', to create a new partition
    choose number 4, as the name of the new partition (I've already created number 1, 2 and 3). 
    press 't', to change the partition type, to create the new one as 'Linux LVM' type. 
    press 'w', to apply and consolidate the changes. 

After another reboot, by using fdisk we can check that the new space is on the disk:

# fdisk -l
Disk /dev/sda: 1 TiB, 1099511627776 bytes, 2147483648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 14AC28B9-20EB-490A-A256-F025825039C7

Device         Start        End    Sectors   Size Type
/dev/sda1       2048    1230847    1228800   600M EFI System
/dev/sda2    1230848    3327999    2097152     1G Linux filesystem
/dev/sda3    3328000  838858751  835530752 398.4G Linux LVM
/dev/sda4  838858752 2147483614 1308624863   624G Linux LVM

3. Extend the logical volume with the recently created partition

# pvcreate /dev/sda4
  Physical volume "/dev/sda4" successfully created.

4. Extend the Volume group with the new physical volume

# vgextend cl /dev/sda4
  Volume group "cl" successfully extended
# pvscan
  PV /dev/sda3   VG cl              lvm2 [398.41 GiB / 0    free]
  PV /dev/sda4   VG cl              lvm2 [<624.00 GiB / <624.00 GiB free]
  Total: 2 [<1022.41 GiB] / in use: 2 [<1022.41 GiB] / in no VG: 0 [0   ]  

5. Extend the logical volume

In our case, we want to increase the logical volume home, so:

# lvextend /dev/cl/home /dev/sda4
  Size of logical volume cl/home changed from <336.58 GiB (86164 extents) to 960.57 GiB (245907 extents).
  Logical volume cl/home successfully resized.

6. Resize the filesystem to the volume group to use the new space

# xfs_growfs /home
meta-data=/dev/mapper/cl-home    isize=512    agcount=4, agsize=22057984 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=88231936, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=43082, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 88231936 to 251808768

If we check the new partition space:

# df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs              12G     0   12G   0% /dev
tmpfs                 12G     0   12G   0% /dev/shm
tmpfs                 12G  9.6M   12G   1% /run
tmpfs                 12G     0   12G   0% /sys/fs/cgroup
/dev/mapper/cl-root   50G   14G   37G  27% /
/dev/mapper/cl-home  961G  7.9G  953G   1% /home
/dev/sda2            976M  138M  772M  16% /boot
/dev/sda1            599M  6.8M  593M   2% /boot/efi

Fonts used

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