Set Name, Number of CPUs, Memory and GUI Mode for Vagrant Virtual Machines

This quick tutorial is going to illustrate how to set name, number of CPUs, memory and GUI mode for Vagrant virtual machines.

1. Set Name for Virtual Machines

We can set name for virtual machines that appear in the VirtualBox GUI by changing the value of the name property. Let’s see an example:

Let’s see how the name of virtual machine appears in VirtualBox before and after we set the name for virtual machine.

Before:

Set name for virtual machines - Default Name

Default VM name appears in VirtualBox

After:

Set name for virtual machines - Customized Name

Customized VM name appears in VirtualBox

The displayed name is the one configured in the Vagrantfile file.

2. Set Number of CPUs for Virtual Machines

If we work on a multiprocessor machine, we can set number of CPUs for virtual machines using the cpus property. Let’s see an below example which we set 2 CPUs for the above virtual machine:

Let’s verify the number of CPUs of the virtual machine in VirtualBox:

Set number of CPUs for Vagrant virtual machine

Set number of CPUs for virtual machine

We can see that there was two CPUs set for the virtual machine.

3. Set Amount of Memory for Virtual Machines

We can set amount of memory for virtual machines using the memory property. Let’s see an example which we set 2048 MB memory for a virtual machine:

Now let’s verify the amount of memory set for the VM in the VirtualBox:

Set amount of Memory for Vagrant Virtual Machine

Set amount of Memory for Vagrant Virtual Machine

We can see that there was 2048 MB of memory was set for the virtual machine.

4. Set GUI Mode for Virtual Machines

By default, VirtualBox starts the machines in headless mode, which means that there is no UI to access
the guest OS. And in this case, the only one way we can access the virtual machines is using SSH. If we want to have a UI, we can set the GUI mode for virtual machines using the gui property. Let’ see an example which we set the GUI mode for the above virtual machine:

5. Conclusion

The tutorial has illustrated how to set name, number of CPUs, memory and GUI mode for Vagrant virtual machines. We can see that those properties are very essential when we work with virtual machines and we often have to modify those properties to fit with our desired environment. And with Vagrant, it’s easy for us to achieve that by just defining in the Vagrant configuration file.

Here are other related tutorials for your references:

Vagrant Tutorial

Uninstall Vagrant on Ubuntu 16.04

Basic Vagrant Commands

How to Add a Vagrant Box from Local or Remote