Increasing VM disk size: Final edition
This post merges both A little follow up on this post and Increasing Disk Size on Existing VM and fixes a couple of mistakes.
First off, go to your Proxmox host. Run the resize command:
qm resize <vmid> <disk> <size>
vmid
is the ID in your VM ID, disk
is the identifier of the disk inside the VM, it’s most likely to be scsi0
.
size
is the size you want to add or remove, something like +100G
or +1T
is both valid.Now go into your VM, run the following command to check if the system has notices a disk resize:
dmesg | grep sda
sda
is the disk, it could be vda or sdb.Run the following command to get your disk and display the partitions, remember to change sda
if required.
fdisk -l /dev/sda | grep ^/dev
Run the following command to open parted with the drive:
parted /dev/sda
Run a list
to check if everything is recognized correctly and run the following command:
resizepart <partition number, integer only> 100%
If it asks to fix the unused space type F
to fix it, if it asks for a partition number and
size; just put in the values like above.
Ctrl-C out of Parted and run df -h
, you’ll notice that you still do not have your extra space!
Run pvresize /dev/<block>
to start resizing, remember to subsitute <block>
with your partition
like sda3
.
Now run lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
and resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
to actually resize your LVM partition. Remember to replace /dev/mapper/ubuntu--vg-ubuntu--lv
with your LVM partition, you can find it by running df -h
and looking for the one mounted on /
.
That’s it! The drive has been expanded and readily available, no need to reboot!