How do I change the RAM setting in VirtualBox? - macos

I work on a MacBook Air with 4GB of RAM. For my projects, I use Ubuntu in VirtualBox (by way of Vagrant). But my VMs have insufficient RAM. VirtualBox takes up most of the RAM (2GB). I can not change the limits, the slider does not work (it is frozen?).

you can do the following in your Vagrantfile
Vagrant.configure("2") do |config|
# ... other configuration
config.vm.provider "virtualbox" do |v|
v.memory = 1024
end
end
This will allow only 1GB on the VM.

In your Virtual machine box conversationdriverlocal_default_1468940462492_81779 is running, need to be shutdown and than change the RAM from setting by sliding the slider and start the again.

Related

Vagrant over Hyper-V slow shared folder SMB

I have a vagrant box that is running on top of hyper-v. All seems to work fine except shared folder. It just incredible slow. Its like stuck on something. I run yarn install and it dint finish even after like a 18 hours of work.. ( it was working and adding new files with with incredible slow speed). I know there a lot of small files ( ~80k was created during yarn install until i cancelled it), but no way it should take 18 hours to create such amount of files, and i have a fast ssd. I tried to copy this files over smb inside windows itself and all copied withing few minutes.
I checked process load when its running, everything near zero. No cpu usage, a lot of free mem.
Host system : windows 10
Guest system : ubuntu 16.04
Here is my vagrant file:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "kmm/ubuntu-xenial64"
config.vm.provider "hyperv"
config.vm.network "public_network"
config.vm.synced_folder 'C:/Dev/PycharmProjects/scrapers', '/opt/scrapers', disabled: false, type: "smb", smb_username: "xxx", smb_password: "xxx", mount_options: ['vers=2.1']
config.vm.synced_folder '.', '/vagrant', disabled: false, type: "smb", smb_username: "xxx", smb_password: "xxx", mount_options: ['vers=2.1']
config.vm.provider "hyperv" do |h|
h.enable_virtualization_extensions = true
h.differencing_disk = true
h.ip_address_timeout = 240
h.memory = 1024
h.cpus = 4
h.vm_integration_services = {
key_value_pair_exchange: true,
}
end
end
I tried mounting with vers=3.0 with the same result.
I even tried to copy that folder on guest machine to another one and it just stuck, it copies like 20 files and then nothing happens after it for few hours.
I have noticed that SMB / CIFS shares into Vagrant Linux guests are extremely slow and unreliable using the "Default Switch" provided with the Windows 10 upgrade to "Fall Creator's Edition" 1709 (Version 10.0.16299 Build 16299.)
If you just upgraded to the latest build of Windows, then you could try using an External Switch instead of the "Default Switch" NAT network. I changed my Vagrant Files back to using an External Switch and it solved* my CIFS performance problems.
* Even with an External Switch, the maximum file transfer speeds I see using
local-to-local rsync from a Linux guest internal filesystem to a CIFS mount from the host is around 10MB/s and typically much slower, so it is still terrible. Just not completely unusable like it is with "Default Switch".

Vagrant cannot vagrant up the box packaged from ubuntu xenial64 16.04

I have a custom vagrant box based on the offcial box ubuntu 16.04.
I simplly run like this to get the packaged box.
vagrant init ubuntu/xenial64; vagrant up --provider virtualbox
vagrant up
vagrant ssh # enter the virtual machine and do some custom change on it
vagrant halt
vagrant package --vagrantfile Vagrantfile --output custom_ubuntu1604.box
and then i copy the file custom_ubuntu1604.box to another directory, i use the box like this:
vagrant box add ubuntu1604base custom_ubuntu1604.box
vagrant init ubuntu1604base
vagrant up # at this point the machine will be stopped at "Started Journal Servie"
my new virtualbox machine base on the new packaged box will stop at:
the screenshot
And finally it timed out:
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within the
configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that Vagrant
had when attempting to connect to the machine. These errors are
usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes. Verify
that authentication configurations are also setup properly, as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
Try to set config.vm.boot_timeout in Vagrantfile more than default e.x.600. From my experience I found out it take a long time at the first time to connecting guest machine.
For example
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox"
config.vm.boot_timeout = 600
end

Made changes to Vagrantfile - now my vagrant will not start

I made some changes to my Vagrantfile. All I did was to add more processors and ram to the config.
Before (and commented out):
....
#config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# vb.cpus = "2"
#end
....
After:
....
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
vb.gui = true
#
# # Customize the amount of memory on the VM:
vb.memory = "1024"
vb.cpus = "2"
end
....
I rebooted the machine and got this error:
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.
If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, runvagrant upwhile the
VirtualBox GUI is open.
The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.
So I changed my Vagrantfile back to how it was originally (as above).
I still can't boot the machine with vagrant up. What have I done wrong?
When I do have the UI enabled. It just opens and closes without me being able to see it.

Vagrant: how to reload VM memory settings

I need to increase my memory settings which are now:
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
end
The problem is that even increasing the vb.memory, when I issue a "free -m" from the virtual machine, I don't see any change in available memory.
Tried with:
vagrant reload
without luck. Is there a non-destructive way to change the memory settings of the VM ?
Thanks

Running Vagrant Inside VMWare VM

I realize this is essentially OSCeption (Operating System Inception), but I think it might make the most sense for me (please tell me if there's a better option, this seems really awful).
Here's the situation:
I have a windows 8 machine. I like it - it works great for everything but development. For development, I've been using a VMWare virtual machine running Ubuntu. I've dabbled with using Cygwin, but it just didn't feel right.
I'm now joining a project where they've been using Vagrant to manage development environments so I need to be able to use Vagrant. But, from what I've seen, Vagrant is mainly used to run code within a consistent environment, but not necessarily to write it. And if I wanted to write code by SSH'ing into my vagrant boxes, then I would have to re-configure my preferences like my .vimrc file and what not for every machine.
Does it then make sense to install Vagrant within my Ubuntu VirtualMachine? I feel like at some point VMs within VMs will get out of hand and cause problems. Is there any better way to do this?
Edit: So I tried it out - as I expected I hit some errors. When I try and boot the machine, I get the following error message:
Failed to open a session for the virtual machine vagranttest_1371583212.
VT-x is not available. (VERR_VMX_NO_VMX).
Result Code: NS_ERROR_FAILURE (0x80004005)
Component: Console
Interface: IConsole {db7ab4ca-2a3f-4183-9243-c1208da92392}
Looks like my vmware virtual machine can't run another virtual machine. Any ideas on the best way to go about doing this?
I've run into the same issue today. The solution is quite simple.
Power off vmware vitrual machine.
Go to "edit virtual machine settings"
Go to processors. There are three checkboxes there.
Check second checkbox (enable VT-x/AMD-V)
Power on machine.
After this virtualbox should work inside vmware.
To answer the original question as well as #blong's Vagrant forum post, this is what I've done to make this work.
I was trying to do something similar myself (actually Vagrant/VMware hosting Vagrant/Vbox) and I have performed all the optimizations I can think of, giving my "host" VM a large amount of RAM (24GB) and 6 cores, disabling swapping VMs to disk (this KILLS things on Windows when it happens) by setting "Fit all VM memory into reserved host memory", and allowing per VM page files (otherwise they live in the system page file which limits how many VMs you can run at once).
What I am doing has been working perfectly, the networking issues I've had were due to the corporate proxy I'm behind. Once I configured that my VM got internet access and all was right with the world.
I did have to manually set --natbindip1 and --natnet1 via the Vagrantfile in addition to the natdnsproxy1 and naddnshostresolver1 that were already set in my example (Virtualbox) Vagrantfile. These settings can be found in the Virtualbox documentation for the correct usage.
To sum it up, use the VT-x passthrough/"virtualize" option in your VM CPU settings, give the VM adequate memory, don't allow that memory to be swapped on the "root" host machine, and try to make sure your network ranges don't overlap or you'll have routing trouble.
Here is the Vagrantfile I was working from, it is based almost entirely on andreptb's gist for the modern.ie vagrant setup. https://gist.github.com/andreptb/57e388df5e881937e62a
# -*- mode: ruby -*-
# vi: set ft=ruby :
# box name into env var, same script can be used with different boxes. Defaults to win7-ie11.
box_name = box_name = ENV['box_name'] != nil ? ENV['box_name'].strip : 'win7-ie11'
# box repo into env var, so private repos/cache can be used. Defaults to http://aka.ms
box_repo = ENV['box_repo'] != nil ? ENV['box_repo'].strip : 'http://aka.ms'
Vagrant.configure("2") do |config|
# If the box is win7-ie11, the convention for the box name is modern.ie/win7-ie11
config.vm.box = "modern.ie/" + box_name
# If the box is win7-ie11, the convention for the box url is http://aka.ms/vagrant-win7-ie11
config.vm.box_url = box_repo + "/vagrant-" + box_name
# big timeout since windows boot is very slow
config.vm.boot_timeout = 500
# rdp forward
config.vm.network "forwarded_port", guest: 3389, host: 3389, id: "rdp", auto_correct: true
# winrm config, uses modern.ie default user/password. If other credentials are used must be changed here
config.vm.communicator = "winrm"
config.winrm.username = "IEUser"
config.winrm.password = "Passw0rd!"
config.vm.provider "virtualbox" do |vb|
# first setup requires gui to be enabled so scripts can be executed in virtualbox guest screen
#vb.gui = true
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--vram", "128"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000]
end
end
My additional changes:
# Need the WinRM gem for managing from Linux
$ sudo gem install winrm
config.vm.communicator = "winrm"
+ config.winrm.host = "localhost"
config.winrm.username = "IEUser"
config.winrm.password = "Passw0rd!"
# This one may not be necessary, I added it for completeness
+ config.vm.guest = :windows
# In order to USE the two CPUs you need the ioapic
# Virtualbox gives an error in the GUI and only shows 1 CPU in the VM otherwise
vb.customize ["modifyvm", :id, "--cpus", "2"]
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
# We had to modify the network range because we are running Virtualbox inside VMware
+ vb.customize ["modifyvm", :id, "--natnet1", "192.168.199.0/24"]
Remove the + signs and add those lines into the Vagrantfile above and you should have an equivalent working system to what I've been using.
If you are running virualbox in a VM in vsphere, you have to ssh to the ESXi to update a configuration.
Steps:
ssh to ESXi server.
find the vmx file which belong to your VM find / -name *.vmx
poweroff your VM.(very important, or your change will be overwrite)
edit that vmx, append a new configuration at the bottom of the file: vhv.enable = "TRUE"
power on your VM
enjoy the Vagrant. :)
I have tried this in two VMware products. Right-click on the VM:
In vCloud Director 5.5 VM properties on the Hardware tab there's an "Expose hardware-assisted CPU virtualization to guest OS" checkbox, but it's grayed out for me. YMMV.
In vSphere Version 5.5.0 Edit Settings > Virtual Hardware > CPU the checkbox is called "Expose hardware assisted virtualization to the guest OS," and that worked for me.

Resources