Categories
Linux Virtual Machines

How to Expand a Linux Virtual Machine Hard Drive

I’ve been putting off expanding the storage space on my Nextcloud VM for a couple of months now. However, a few days ago, the storage space hit less than a few hundred megabytes and I wasn’t able to login or upload any new files, so I was then forced to upgrade it and here are the steps I followed.

1. Take a Backup & Snapshot

Before we start, make sure you have a way to restore the VM if something goes wrong.

2. Boot with GParted

The first thing I had to do was reconfigure the virtual hard disk, so I booted off of the virtual CD drive with GParted mounted. The steps are kinda advanced, so I linked a video of the steps you need to follow below.

3. Check Linux Storage Space

To make sure the changes you made in GParted were saved to the virtual hard disk, reboot into your Linux OS. Then run the command df -h. The drive that was close to 100% full should now have a lot more space.

Troubleshooting

The drive won’t resize – Boot back into GParted and see if the drive is still resized. If not, you might not have committed the changes GParted made to the drive.

The drive STILL won’t resize – If the changes that GParted made are still there when you reboot, then run the commands below.

sudo lvextend /dev/mapper/(Drive Name)--vg-root -L+(Number of GB added)G

fsadm resize (Drive Name)

sudo reboot
Source: StackOverflow… I think? If you know the link, leave it in a comment below. Thanks!

And if that doesn’t work…

sudo lvextend –l +100%FREE [MOUNTPOINT]
sudo resize2fs [MOUNTPOINT]

Source: https://superuser.com/questions/917988/gparted-cannot-resize-extended-or-lvm-partition

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.