Skip to content

How to Increase Harddisk Size In Linux VM On Proxmox?

increase harddisk size in linux VM on proxmox

Proxmox has a disk resize feature where if we have a VM in proxmox and find that the HDD size on the VM is about to run out, then we can use this feature to increase the HDD size as long as the proxmox server HDD size is still sufficient.

 

Problem

How to increase hard disk size in Linux VM on proxmox?

 

Solution

Before you use resize disk feature in Proxmox, you need to know that in Linux 2 partitions are often used, namely the standard partition and the LVM partition. To find out what partition type you are using on the Linux server, then try typing the command below:

pvdisplay

If typing the above command has the result as shown below:

The pvdisplay command

then your server uses the LVM partition, but if the results are not or produce error results, your server uses the standard partition. After that, here are the steps to resize the disk in Proxmox:

A. Using LVM partition

First, check the size of the VM HDD. Use the commands below:

df -h
fdisk -l

df command

 

fdisk command

After that type the command below (adjust to the partition on your server):

parted /dev/sda

then use the command below:

print

 

parted commands

Type the command below to see the condition of the LVM partition:

pvdisplay

The pvdisplay command

Turn off the server and then we resize the VM HDD in VM > Hardware > Hard Disk > Resize Disk

Resize disk feature in Proxmox

there will be a pop-up like in the image below and I add 20 GB to my VM HDD:

Increase HDD size

If so, then start your VM and then we type the following command:

parted /dev/sda
print

After adding HDD size

From the picture above, we can see that the HDD size is increased by 20 GB. I want to increase the LVM partition so I type the command below (adjust to your partition):

resizepart 2 100%

 

After that exit the parted command by typing the quit command. Type the command below (adjust to your partition):

pvresize /dev/sda2

pvresize command

Then we see the changes in the LVM partition by typing the command pvdisplay:

The pvdisplay command

You can see that our HDD size is increased by 20 GB. Now, type the below command (adjust to your partition):

lvresize --extents +100%FREE --resizefs /dev/mapper/rl-root

The lvresize command

Finally, type the command below and the size of the / partition HDD should increase by 20 GB as shown in the image below:

After using resize disk feature

You can see that the size of the hard disk is now increased by 20 GB from before.

B. Using the standard partition

The method of resizing a disk on a Linux server using a standard partition is almost the same as resizing a disk on a Linux server using an lvm partition. Turn off the Linux server first, then increase the HDD size as in the above method then restart the server. After that type the command parted /dev/sda and type the print command as shown below:

parted command

Look at the picture above and it can be seen that the / partition is at number 3 so I type the following command:

resizepart 3 100%

resizepart command

after that type the print command again and see the partition / increase by 20 GB:

After executing resizepart command

Then exit the parted application by typing the quit command. Then we type the command df -h to see the size of the HDD and it looks like the / partition hasn’t changed in size. Therefore, type the following command if your / partition is in xfs format:

xfs_growfs /dev/sda3

But if you use ext4 type then type the following command:

resize2fs /dev/sda3

 

For more details, look at the image below:

Before and after resizing the disk

 

Note

In my experience, if we use a standard partition and want to use the disk resizing feature in Proxmox, then you have to pay attention to the position of the partition you want to resize. For example, we want to increase the size of the / partition, then put the / partition at the end of the sector. Look at the image below:

Position of partition / is at the end of the sector

You see that the / partition (/dev/sda3) is in the last sector. If the situation is like that, then you can resize the partition. However, if your server has conditions like in the image below:

Position of partition / is not at the end of the sector

You see that the / partition (/dev/sda2) is not in the last sector so you cannot resize the / partition.

 

References

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *