go into the workshiop folder named vagrantvm
cd vagrantvm
now we will assign cpu and memory limit to vagrant box or VM
CPU: 2
RAM: 1024MB or 1GB
open Vagrantfile
notepad Vagrantfile
and add following lines
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 1024]
vb.customize ["modifyvm", :id, "--cpus", 2]
end
final content should look like
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.hostname = "vm1"
config.vm.network "private_network", ip: "172.16.1.10"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--cpus", 2]
vb.customize ["modifyvm", :id, "--memory", 1024]
end
end
finally save file
validate Vagrantfile config
vagrant validate
Start VM
vagrant up
Goto VirtualBox, and verify CPU and RAM changed accordingly for vagrant managed VM
Stop VM
vagrant halt
go to workshop folder and create new folder named data
create new file named syncedfile.txt inside data folder and create some content in this file
go into vagrantvm folder and create new file named copiedfile.txt and create some content in this file
modify Vagrantfile to add following lines
config.vm.synced_folder "../data", "/home/vagrant/data"
config.vm.provision "file", source: "./copiedfile.txt", destination: "/home/vagrant/copiedfile.txt"
final content should look like
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.hostname = "vm1"
config.vm.network "private_network", ip: "172.16.1.10"
config.vm.synced_folder "../data", "/home/vagrant/data"
config.vm.provision "file", source: "./copiedfile.txt", destination: "/home/vagrant/copiedfile.txt"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--cpus", 2]
vb.customize ["modifyvm", :id, "--memory", 1024]
end
end
finally save file
validate Vagrantfile config
vagrant validate
Start VM
vagrant up
SSH into VM and verify if copiedfile.txt and data folder exist and syncedfile.txt inside data exist and contents of both file same as in host.
Try updating both file on host and on VM and see if changes get synced
Stop VM
vagrant halt