Resize VM Disk: Difference between revisions

From Delft Solutions
Jump to navigation Jump to search
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Draft =
= Draft =
This article is a draft. It only tells you how to increase a disk, and only if the disk is partitioned in a certain way. Also not tested by anyone else yet. (other then by the author of this article: Wouter)
= Intro =
= Intro =
This is for increasing a disk's size.
When a virtual machine (VM) needs more disk space, you can expand its storage by resizing the disk in the Proxmox GUI and then adjusting the partition inside the VM using Linux commands.
These steps only work if the root partition is at the end of the disk. (The automated install config/preseed ensures this)
These steps only work if the root partition is at the end of the disk. (The automated install config/preseed ensures this)
== Step 1 ==
== Step 1 ==
To increase the disk 'physical' size:
Before making any changes, you can confirm the current size of your disk.
* On Proxmox web gui: select disk, click the 'Disk Action' dropdown and select 'Resize'
running `fdisk -l /dev/sda`, this lists partition table details of /dev/sda, showing its total size and partitions.
* Fill in the size to increase the disk with
 
output should look something like this:
[[File:Screenshot 2025-03-19 at 15.29.14.png|thumb|center|`fdisk -l /dev/sda`]]
 
Next, to increase the disk 'physical' size:
* On Proxmox web gui: Select your VM then Hardware > Hard Disk > Disk Action > Resize
[[File:Screenshot 2025-03-19 at 14.54.13.png|thumb|center|Hardware > Hard Disk > Disk Action > Resize]]
* Enter the new disk size and click OK
 
After resizing in Proxmox, check if the disk size change is recognized by the system by running `fdisk -l /dev/sda` again
The total disk size should reflect the increased value. However, partitions remain unchanged. This means the top layer is aware of the size increase
now we need to inform the other layers.
 
If the total disk size does not show an increase as expected, you may need to run `partprobe` to force the system to re-read the partition table without requiring a reboot.
 
== Step 2 ==
== Step 2 ==
To increase the disk partition:
Resize the Partition to Use the Extra Space:
* In the VM, first get the partition table for info (Assuming the disk is /dev/sda) with `fdisk -l /dev/sda | grep ^/dev`
 
Output should something like this:
[[File:Fdisk-output.png|thumb]]
* Resize using 'parted':
* Resize using 'parted':
   * parted /dev/sda
This is assuming that you need to resize /dev/sda2 (which the 'print' command will help you determine)
   * print
   * `parted /dev/sda`, opens the partition table editor for /dev/sda
   * resizepart 2 100%
   * `print`, double-checks the disk layout
   * quit
   * `resizepart 2 100%`, choose partition you want to resize, here partition 2 is resized to use all available space
This is assuming that you need to resize /dev/sda2 (which the 'print' will help you determine)
   * `quit`, exit parted
 
You can verify the updated partition table running `lsblk`, this lists all storage devices, showing partitions and their sizes.
[[File:Screenshot 2025-03-19 at 15.49.02.png|thumb|center|`lsblk`]]
 
== Step 3 ==
== Step 3 ==
To increase file system's size:
To increase file system's size:
* 'resize2fs /dev/sda2' (Assuming you need to increase /dev/sda2)
* 'resize2fs /dev/sda2' (Assuming you need to increase /dev/sda2), this expands the filesystem on /dev/sda2 to use the full partition
[[File:Screenshot 2025-03-19 at 15.53.12.png|thumb|center|`resize2fs /dev/sda2`]]
 
Verify available space running `df -h`, displays disk usage in a human-readable format
[[File:Screenshot 2025-03-19 at 15.55.56.png|thumb|center|`df -h`]]
 
As a final check you can also check Zabbix for Latest Data > Total Space for your vm

Latest revision as of 06:59, 19 March 2025

Draft

This article is a draft. It only tells you how to increase a disk, and only if the disk is partitioned in a certain way. Also not tested by anyone else yet. (other then by the author of this article: Wouter)

Intro

When a virtual machine (VM) needs more disk space, you can expand its storage by resizing the disk in the Proxmox GUI and then adjusting the partition inside the VM using Linux commands. These steps only work if the root partition is at the end of the disk. (The automated install config/preseed ensures this)

Step 1

Before making any changes, you can confirm the current size of your disk. running `fdisk -l /dev/sda`, this lists partition table details of /dev/sda, showing its total size and partitions.

output should look something like this:

 
`fdisk -l /dev/sda`

Next, to increase the disk 'physical' size:

  • On Proxmox web gui: Select your VM then Hardware > Hard Disk > Disk Action > Resize
 
Hardware > Hard Disk > Disk Action > Resize
  • Enter the new disk size and click OK

After resizing in Proxmox, check if the disk size change is recognized by the system by running `fdisk -l /dev/sda` again The total disk size should reflect the increased value. However, partitions remain unchanged. This means the top layer is aware of the size increase now we need to inform the other layers.

If the total disk size does not show an increase as expected, you may need to run `partprobe` to force the system to re-read the partition table without requiring a reboot.

Step 2

Resize the Partition to Use the Extra Space:

  • Resize using 'parted':

This is assuming that you need to resize /dev/sda2 (which the 'print' command will help you determine)

 * `parted /dev/sda`, opens the partition table editor for /dev/sda
 * `print`, double-checks the disk layout
 * `resizepart 2 100%`, choose partition you want to resize, here partition 2 is resized to use all available space
 * `quit`, exit parted

You can verify the updated partition table running `lsblk`, this lists all storage devices, showing partitions and their sizes.

 
`lsblk`

Step 3

To increase file system's size:

  • 'resize2fs /dev/sda2' (Assuming you need to increase /dev/sda2), this expands the filesystem on /dev/sda2 to use the full partition
 
`resize2fs /dev/sda2`

Verify available space running `df -h`, displays disk usage in a human-readable format

 
`df -h`

As a final check you can also check Zabbix for Latest Data > Total Space for your vm