Resizing VM Storage in Proxmox
Resizing VM Storage in Proxmox
Expanding VM Storage
From within Proxmox
- Shut down the VM.
- Resize the disk in the VM settings.
- Boot the VM.
From within the VM
Check for free space
1
sudo cfdiskIf not, rescan the disk:
1
echo 1 > /sys/class/block/sda/device/rescan # Replace 'sda' with the appropriate disk
Resize the partition
- Launch
cfdisk:1
sudo cfdisk - Select the partition to resize. Typically,
/dev/sda3. - Select “Resize” from the bottom menu.
- Press ENTER to select.
- Press ENTER to confirm.
- Select “Write” from the bottom menu.
- Type
yesand press ENTER to confirm. - Press ‘Q’ to quit.
- Launch
Resize the physical volume
- Resize the physical volume:
1
sudo pvresize /dev/sda3 - Verify the physical volume has been resized:
1
sudo pvdisplay
- Resize the physical volume:
Resize the logical volume
- Confirm Volume Group free space:
1
sudo vgdisplay - Resize the logical volume:
1
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
- Confirm Volume Group free space:
Resize the filesystem
- Resize the filesystem:
1
sudo resize2fs /dev/sda3 - Verify the filesystem has been resized:
1
df -h
- Resize the filesystem:
Reducing VM Storage
From the host console, logged in as root:
Shut down the VM
1
pct stop <vmid>
Find the storage path
1
lvdisplay | grep <vmid>Path follows “LV Path”
Resize the file system
1
resize2fs /dev/pve/vm-<vmid>-disk-0 <new_size>
New size can be specified in GB (e.g.,
10G) or MB (e.g.,10240M).Resize the logical volume
1
lvreduce -L <new_size> /dev/pve/vm-<vmid>-disk-0Edit Container Configuration
Edit the container configuration file located at
/etc/pve/lxc/<vmid>.confand adjust therootfsline to reflect the new size.Start the VM
1
pct start <vmid>
Verify the changes
Check the disk size from within the VM:
1
df -h
Related Posts
This post is licensed under CC BY 4.0 by the author.