Vagrant VirtualBox second disk path

This can be done if you define a name for virtual machine:

# Try to make it work on both Windows and Linux
if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
  vboxmanage_path = "C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe"
else
  vboxmanage_path = "VBoxManage" # Assume it's in the path on Linux
end

Vagrant.configure(2) do |config|
  config.vm.box = "debian/wheezy64"

  config.vm.provider "virtualbox" do |vb|
    vb.name = "VM Name"

    # Get disk path
    line = `"#{vboxmanage_path}" list systemproperties`.split(/\n/).grep(/Default machine folder/).first
    vb_machine_folder = line.split(':', 2)[1].strip()
    second_disk = File.join(vb_machine_folder, vb.name, 'disk2.vdi')

    # Create and attach disk
    unless File.exist?(second_disk)
      vb.customize ['createhd', '--filename', second_disk, '--format', 'VDI', '--size', 60 * 1024]
    end
    vb.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 0, '--device', 1, '--type', 'hdd', '--medium', second_disk]
  end
end

You need to use something like this in your Vagrantfile:

For Vagrant API v1:

# Where to store the disk file
disk = 'C:\Users\jma47\VirtualBox VMs\bin_build_1389371691\extra_disk.vdi'

Vagrant::Config.run do |config|
  config.vm.box = 'base'

  config.vm.provider "virtualbox" do | v |
    unless File.exist?(disk)
      config.vm.customize ['createhd', '--filename', disk, '--size', 500 * 1024]
    end
    config.vm.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk]
  end
end

For Vagrant API v2:

# Where to store the disk file
disk = 'C:\Users\jma47\VirtualBox VMs\bin_build_1389371691\extra_disk.vdi'

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = 'base'

  config.vm.provider "virtualbox" do | p |
    unless File.exist?(disk)
      p.customize ['createhd', '--filename', disk, '--size', 1 * 1024]
    end
    p.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk]
  end
end