Often times I’ve created Virtual Machines using Vagrant, but simply forgot to associate an additional disk/volume for storing information. This is a quick process to attach a volume to an already-created VM that was created using Vagrant and lives in the VirtualBox hypervisor.
Process
These steps provide one way to attach an external volume to an existing virtual machine created using Vagrant and running inside VirtualBox, and format it for use. Note that these instructions will likely work for non-Vagrant created VMs as well, assuming you switch the technologies specified.
Stop the running VM using Vagrant commands:
In VirtualBox, add a new disk image to the VM. Follow the instructions on the VirtualBox site to perform this activity.
Start the VM using Vagrant commands:
Log in to the VM and look for the new disk image:
Create the file system on the partition (assuming the drive is /dev/sdb). This command initializes the drive with an EXT3 file system - swap out the file system type for your desired configuration:
Add the partition as a permanent mount point - note that this step mounts the drive to the /opt partition:
Reboot the VM.
Once the VM has finished booting, inspect to ensure that the new drive is mounted and accessible for use: