Skip to content

Resizing a VM

Resize vagrant machine

To expand virtual machine's hard drive for testing of larger files. Once the VM has started, you'll need to halt the VM, download and run the script, tell it what size (in MB) and then start the VM. The last step vagrant ssh --command "sudo resize2fs /dev/sda1" is a check. It should return there was nothing to do. If you already provisioned you VM you can skip the 2 steps with provisioning in them.

# Skip this if you VM is already provisioned.
$ vagrant up --no-provision  <-- Exclude if already running and provisioned.

$ vagrant halt

# Download and run. This will default to the correct name (just press enter) then give the size.
# Example: `350000` is equal to 350GB

$ wget https://gist.githubusercontent.com/DonRichards/6dc6c81ae9fc22cba8d7a57b90ab1509/raw/45017e07a3b93657f8822dfbbe4fc690169cdabc/expand_disk.py
$ chmod +x expand_disk.py
$ python expand_disk.py
$ vagrant up --no-provision

# This step isn't needed but acts as a check to verify it worked.
$ vagrant ssh --command "sudo resize2fs /dev/sda1"

# Skip this if you VM is already provisioned.
$ vagrant provision           <-- Exclude if already provisioned.

Troubleshooting expand_disk.py

You may need to remove the "resized" version. Assuming your VM location is ~/VirtualBox\ VMs

$ rm -rf ~/VirtualBox\ VMs/Islandora\ CLAW\ Ansible_resized


Last update: April 19, 2024