Last active
March 3, 2017 08:15
-
-
Save jolbax/be03a2ac7fe94e5eb74403b6c81a9d8e to your computer and use it in GitHub Desktop.
A complete Vagrantfile with additional hard drives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Reference: | |
# http://zacklalanne.me/using-vagrant-to-virtualize-multiple-hard-drives/ | |
Vagrant.configure(2) do |config| | |
config.vm.box = "geerlingguy/ubuntu1604" | |
# Create a private network, which allows host-only access to the machine | |
# using a specific IP. | |
config.vm.network "private_network", ip: "192.168.30.200" | |
parityDisk = './parityDisk.vdi' | |
dataDisk1 = './dataDisk1.vdi' | |
dataDisk2 = './dataDisk2.vdi' | |
config.vm.provider "virtualbox" do |vb| | |
vb.memory = "2048" | |
# Building disk files if they don't exist | |
if not File.exists?(parityDisk) | |
vb.customize ['createhd', '--filename', parityDisk, '--variant', 'Fixed', '--size', 10 * 1024] | |
end | |
if not File.exists?(dataDisk1) | |
vb.customize ['createhd', '--filename', dataDisk1, '--variant', 'Fixed', '--size', 10 * 1024] | |
end | |
if not File.exists?(dataDisk2) | |
vb.customize ['createhd', '--filename', dataDisk2, '--variant', 'Fixed', '--size', 10 * 1024] | |
# Adding a SATA controller that allows 4 hard drives | |
vb.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 4] | |
# Attaching the disks using the SATA controller | |
vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', parityDisk] | |
vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 2, '--device', 0, '--type', 'hdd', '--medium', dataDisk1] | |
vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 3, '--device', 0, '--type', 'hdd', '--medium', dataDisk2] | |
end | |
end | |
config.vm.provision "shell", inline: <<-SHELL | |
sudo mkfs.ext4 /dev/sdb | |
sudo mkfs.ext4 /dev/sdc | |
sudo mkfs.ext4 /dev/sdd | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment