DEV Community

Abby Nduta
Abby Nduta

Posted on • Edited on

How To Set Up a VM With VirtualBox

The first time I had to set up a VM, I was preparing for my first ever OpenStack Horizon contribution. After trying it a couple of times of trying and failing, I gave up and did a local installation.

I contributed fine, but OpenStack is quite heavy. I crashed my laptop and had to reinstall it. By the time I was done, I was a “local installation” expert” (check out some devstack debugging tips, btw)

I then decided to try and install it in a VM, and when I finally had it working it literally felt like I had a “small computer” inside my desktop.

Jokes aside, I genuinely think that installing a VM successfully should be somewhere on a techie’s hall of fame, or a huge step to "growing up in tech."

I hope this guide saves you some considerable time.

Prerequisites

Create a new VM in VirtualBox

We are now ready to start creating our VM.

  • Open VirtualBox and click "New."

Image description

  • Name your VM.
  • Choose the folder for the VirtualBox directory location (which is where you installed VirtualBox).
  • Choose the previously downloaded Ubuntu desktop ISO image.
  • Select "Linux" as the type, “Ubuntu” as the subtype, and "Ubuntu (64-bit)" as the version.
  • Allocate at least 8GB of RAM (8192MB). I have 16 GB of RAM; this is me living dangerously.
  • Create a new virtual hard disk (VDI) with at least 40GB of space (preferably 60 GB+).

A note on unattended install

This part helps with automatic OS installations.

Image description

  • Add your username and password (leave the password as the default one as changing it causes errors)
  • Hostname (I used DevStack-VM)
  • Domain name (you can use the default)

A word on the "install in background" option

If you check the "install in background" box, you won’t be able to see the installation process, as it’ll be running in the background. I’ll not check it for now, so that if there are any issues, you can see them.

Image description

Another note: Guest additions

The “Guest additions” checkbox allows further configuration between your host and VM. We’ll leave it unchecked for now.

Hardware configurations

Base Memory: 8192 MB (8 GB)—perfect for DevStack requirements
Processors: 4 CPUs

Hard Disk Configurations

  • We’ll create a new virtual hard disk with a size of 25 GB.
  • File type: VDI

Image description

  • You can now click “finish” to create the VM.
  • Wait for a few minutes for the Ubuntu installation and setup and other configurations to complete.
  • You can power the VM off.

Successful installation

If everything works well, you should be greeted with a “normal” Ubuntu login.

Input your password, and voila!

Image description

Set up the host network

We need to shut down the VM again to create a host-only network.

  • To safely shut down the VM:
sudo shutdown -h now
Enter fullscreen mode Exit fullscreen mode
  • Once the VM is shut down, we need to create a host-only network.
  • Open VirtualBox and go to File > Tools > Network Manager.

Image description

  • Click "Create."
  • The network name should be "vboxnet0."

Configure the network adapters

  • Select your VM and click on "Settings."
  • Go to the "Network" tab.

Image description

  • Under "Adapter 1," check "Enable Network Adapter."
  • Choose Attached to NAT (this gives your VM internet access).

Image description

  • Under "Adapter 2," check "Enable Network Adapter."
  • Choose Set to Host-Only Adapter.
  • Select the network you just created from the dropdown menu.
  • Click OK to save the settings.
  • Start your VM again.

Find the VM’s IP address on the host-only network

  • Run ip addr

This should show you your network interfaces and IP addresses. Check that you have IP addresses under enp0s3 and enp0s8.

You’ll need the host-only network interface IP (enp0s8), as you’ll add it to your local.conf file when setting up DevStack.

Configure a static IP

DevStack will use a static IP to give you access to the Horizon dashboard.

sudo ip addr add 192.168.56.x/24 dev enp0s8 
sudo ip link set enp0s8 up
Enter fullscreen mode Exit fullscreen mode

After doing this, run ip addr again to verify that enp0s8 has an IP address.

Forging Forward

You are now one step closer to your DevStack installation. I will discuss this in a separate post. I hope this works for you and you have a smooth install time.

Happy VMing!

Resources

https://medium.com/@ollste/openstack-local-development-how-to-install-test-and-use-openstack-in-virtualbox-b60b667886c4

Top comments (0)