Resize the Disk from Proxmox

Romi197

New member
Points
6
I have resized the disk size of a VM, cPanel / WHM is installed but when I check the size from my WHM interface the size is not increased

Code:
[root@server~]# lsblk
NAME               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0                7:0    0  1.5G  0 loop /var/tmp
                                            /tmp
sda                  8:0    0  756G  0 disk
├─sda1               8:1    0    1G  0 part /boot
└─sda2               8:2    0   55G  0 part
  ├─almalinux-root 253:0    0 33.2G  0 lvm  /usr/local/cpanel/cpanel.lisc
  │                                         /usr/local/cpanel/cpsanitycheck.so
  │                                         /
  ├─almalinux-swap 253:1    0  5.6G  0 lvm  [SWAP]
  └─almalinux-home 253:2    0 16.2G  0 lvm  /home
sr0                 11:0    1  1.9G  0 rom
[root@server~]#
 

Helposoft Staff

Administrator
Staff member
Points
178
The disk size has been increased to 756GB, but the partitions and logical volumes have not been adjusted to use the new space. The next steps involve expanding the existing partition, adjusting the physical volume, and extending the logical volumes.

Step-by-Step Guide to Resize the Disk​

1. Resize the Partition Using parted​

Since your partition /dev/sda2 is using LVM, we'll need to resize it to occupy the full disk space.
Code:
parted /dev/sda
Within parted:
  • Select your disk and print the current partition table:
    Code:
    (parted) select /dev/sda
    (parted) print
  • Resize the partition:
    Code:
    (parted) resizepart 2 100%
  • Quit parted:
    Code:
    (parted) quit

2. Resize the Physical Volume (PV)​

Now, you need to resize the physical volume to use the new partition size.

Code:
pvresize /dev/sda2

3. Extend the Logical Volume (LV)​

Identify the logical volumes using lvdisplay, then extend them.

Code:
lvextend -l +100%FREE /dev/mapper/almalinux-home

4. Resize the Filesystem​

Finally, resize the filesystem on the logical volume to use the newly available space.
For xfs filesystem:

Code:
xfs_growfs /home

For ext4 filesystem:


Code:
resize2fs /dev/mapper/almalinux-home

Example Commands​

Here’s a summary of the commands you need to run:

Code:
# Resize the partition
parted /dev/sda
(parted) resizepart 2 100%
(parted) quit

# Resize the physical volume
pvresize /dev/sda2

# Extend the logical volume
lvextend -l +100%FREE /dev/mapper/almalinux-root

# Resize the filesystem (assuming XFS)
xfs_growfs /

# If using ext4
# resize2fs /dev/mapper/almalinux-root

Verify the Changes​

After completing these steps, verify the changes by running df -h again to see the increased available space.

Code:
df -h

This should reflect the new size you configured in Proxmox.

Troubleshooting​

  • Ensure there are no running processes using the disk excessively during the resize operation.
  • Backup critical data before performing these operations.
  • If any step fails, refer to the specific error message for more details or consult relevant documentation for parted, pvresize, lvextend, and filesystem resize commands.
By following these steps, you should be able to resize your disk partitions and logical volumes to fully utilize the increased disk space from Proxmox.
 
Top