Nextcloud server running out of space

The 50GB I provisioned to the Nextcloud HyperV VM is filling up fast. There’s less than 9% left available. I grew this from 10GB to 20GB to 50GB. Today we’re growing it to 60GB only. I could grow it even bigger but I don’t expect it to grow much larger much faster as the bulk of the storage is photos and videos from my mobile devices. Plus coming back to expand the hard drive once a few months is good practice and reminder of how to do this in Linux.

Since this is a Ubuntu server, I followed the instructions I found here: https://vander.host/knowledgebase/operating-systems/how-to-resize-an-ubuntu-18-04-lvm-disk/. It says 18.04 but it works on my 20.04 LTS as well.

Before getting into Ubuntu, I started by expanding the VHDX in Hyper V. Actually before this step, I merged the old checkpoints first. (In retrospect I probably should’ve created a new checkpoint at this stage but I have multiple backups to restore from… so YOLO!)

After this, Ubuntu needed a reboot to recognize the new disk size for some reason. I thought I remember the last time I did this I was able to do everything online without unmounting anything or rebooting anything. Need to look this one up.

Edit 5/21/2021:
To rescan disks:
echo ‘1’ > /sys/class/scsi_disk/0\:0\:0\:0/device/rescan

Once fdisk -l showed the new disk size I ran through the rest of the following commands to resize the partition/physical volume/logical volume/filesystem to recognize the new disk space.

Ubuntu Commands

  • echo ‘1’ > /sys/class/scsi_disk/0\:0\:0\:0/device/rescan
  • fdisk -l (note it’s partition 3 by looking at the current Size)
  • parted
    • resizepart, Fix, 3, 100% (type this instead), quit
  • pvresize /dev/sda3
  • lvextend -l +100%FREE /dev/mapper/ubuntu–vg-ubuntu–lv
  • resize2fs /dev/mapper/ubuntu–vg-ubuntu–lv
  • df -h

By default the system will prompt you for size in GB but you can actually type 100% and 100%FREE to use up all of the space without having to calculate down to the decimals or leaving unused space to specify a GB amount.

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.