skip to Main Content

As you can see in the below command I have assigned a total of 500 GB disk space to my VM. But I am seeing 14.4 GB actual space available to the disk and once it gets used completely. I got an error there isn’t much space to use? How to extend space for /dev/mapper/centos-root.

I am using VMware ESXi and using centOS for this VM.

[root@localhost Apr]# fdisk -l

Disk /dev/sda: 536.9 GB, 536870912000 bytes, 1048576000 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
Disk label type: dos
Disk identifier: 0x00064efd

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    33554431    15727616   8e  Linux LVM

Disk /dev/mapper/centos-root: 14.4 GB, 14382268416 bytes, 28090368 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


Disk /dev/mapper/centos-swap: 1719 MB, 1719664640 bytes, 3358720 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 byte

2

Answers


  1. Execute bellow Steps to increase your Linux Disk after adding space in VMWare :

    1. Step 1 – update partition table

    fdisk /dev/sda

    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 3 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 3 to select the newly creation partition.
    Type 8e to change the Hex Code of the partition for Linux LVM.
    Press w to write the changes to the partition table.
    
    1. Step 2 – Restart the virtual machine.

    2. Step 3 – verify that the changes were saved

    fdisk -l

    1. Step 4 – convert the new partition to a physical volume
    pvcreate /dev/sda3
    
    1. Step 5 – extend the physical volume (centos is your VG name, if not use your VG name in place of centos )

    vgextend centos /dev/sda3

    1. Step 6 – extend the Logical Volume (500G is the size you want to add , if not use the right size in place of 500G)

    lvextend -L+500G /dev/mapper/centos-root

    1. Step 7 – expand the ext filesystem online

    resize2fs /dev/mapper/centos-root

    Login or Signup to reply.
  2. extend disk without reboot

    echo 1 > /sys/block/sda/device/rescan
    echo 1 > /sys/block/sdb/device/rescan
    echo 1 > /sys/block/nvme0n1/device/rescan_controller
    
    partprobe
    
    gdisk fix warnging
    
    parted change partion size
    
    ## parted can executed as command line. but this is very dangerous
    parted -s /dev/sdb "resizepart 2 -1" quit
    parted -s /dev/sdb "resizepart 3 100%" quit
    resizepart 3 100%
    
    pvresize /dev/sda3
    
    lvextend -l +100%FREE cs/root
    
    xfs_growfs /dev/cs/root
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search