Expanding VM Disk Size

eseanq

Dabbler
Joined
Mar 25, 2019
Messages
39
Apologies if this is in the wrong section..


I made a Ubuntu Server VM that originally had a disk size of 10GB. I need to increase this so shut down the VM, then went to to Storage/Pools, and then edited the Zvol to increase the size from 10GB to 50GB.

Was following along the instructions from here:
Ubuntu: Extend your default LVM space

Upon restarting the VM I still wasn't seeing the increased size
Screen Shot 2022-09-18 at 1.06.25 PM.png


cfsidk originally did show free space, so I resized /dev/sda3 to take up that space
Screen Shot 2022-09-18 at 1.10.41 PM.png


pvresize fails with:
Code:
/etc/lvm/archive: mkdir failed: No space left on device
0 physical volume(s) resized or updated / 1 physical volume(s) not resized


And pvdisplay still shows /sda3 being ~7.7GB

What am I missing?
 

vidx

Dabbler
Joined
Oct 16, 2021
Messages
40
This is a couple of months late but I was in the same situation with a Ubuntu VM getting a low disk space notice and this is what I did to expand, without shutting it down.

First go to the TrueNAS GUI->Storage and find the Zvol. Use the 3 dots to Edit Zvol and key in a larger size for it. Save

Next SSH to Ubuntu VM/VNC to open the terminal

These are the commands needed to for the system to expand the disk size.
Code:
sudo fdisk /dev/sda

use
Code:
p
to list the partitions. Make note of the start cylinder of /dev/sda3 (using sda3 in this example. Change to whichever suits your usecase)

use
Code:
d 
to delete the partition (default is 3 for me, might be different for you)

use
Code:
n
to create a new partition (default is 3 for me, might be different for you) and agree with default end cylinder size which is the expanded size

use
Code:
w
to write the new partition table to disk. Fingers crossed

Code:
sudo reboot
and you will have a filesystem inside a larger partition

Code:
sudo resize2fs /dev/sda3
(/dev/sda3 was my default, change according to your needs) to make use of all available space on the partition.
Use
Code:
df -h
to check that the space has increased.

Extend the size of the VM
Code:
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv


Finally
Code:
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
to make use of the newly added space

Hope this is useful
 
Last edited:
Top