Simple Guide to Creating Virtual Machines
Published: 2023-11-25 17:12:25

---
title: Simple Guide to Creating Virtual Machines
published: true
date: 2023-11-25 10:33:57 UTC
tags: 
canonical_url: https://abhishes.hashnode.dev/simple-guide-to-creating-virtual-machines
---

![Blog Cover Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vu5pjeo85ikuihleuhfh.jpg)

## What are VMs?

When I was a child, I had a toy box in which I stored all my toys, whether it was a shiny Hot Wheels car or a well-worn metal Beyblade from my epic imaginary battles. There were days when I spent countless hours searching for a specific toy. But what if this toy box could be a magical one that sorted similar toys into separate smaller boxes?

Now that I've grown up, my toys have changed, and my laptop has become my favorite playground. However, the habit of embarking on adventures with different toys hasn't changed; it's just that the toys have been replaced with tools and packages.

Virtual machines are akin to the magical toy box, assisting me in sorting and organizing various tools and packages while keeping me from getting lost as I attempt to create something new.

![VM Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v3dwzmmu0qeem0zrftmg.png)

## Let's Get Started!

So here we will go through two methods of creating VMs on your local setup.

### Using Oracle VirtualBox and OSBoxes

- Download the setup file for your machine and install VirtualBox from the [**VirtualBox Download**](https://www.virtualbox.org/wiki/Downloads) page

- Download an OS image for the virtual machine you want to create. Extract the contents of the zip file, which should contain a VDI file, to be used in later steps - [**CentOS Image for VirtualBox**](https://www.osboxes.org/centos/).

- Launch the Oracle VM VirtualBox app from the startup menu.

- Click the "New" button on the application interface to start creating a new VM.

![VirtualBox New Button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7wcj48thdat3t62zq32d.png)

- Enter details like Name, Folder location, Type (according to the OS image you downloaded), and Version. Click "Next" to proceed.

![New VM Details Screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9dck35qou442luddhdt.png)

- Allocate hardware resources to the virtual machine by adjusting the slider to set base memory and CPUs. Click "Next" - it's recommended to allocate at least 2GB memory and 2 CPUs for smooth running.

![New VM Hardware Allocation Screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lkde9l5brw2qemijjfn7.png)

- Select "Use an existing Virtual Hard Disk File" and browse to the location where you extracted the image file from OSBoxes. Click "Next".

![Load VDI Image GIF](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ma43wams1g63f7i814lf.gif)

- On the final screen, confirm the virtual machine configuration and click "Finish". Your new VM should appear in the VirtualBox application window.

![VM Details Confirm Screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ytp45kzi8rs97ql9ruv.png)

- To start your virtual machine, click the "Start" button, and your VM is up and running.

![Start New VM Screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91kazk00xadbuugd1sm7.png)

Note: All OSBoxes images have the below username and password.

```
Username: osboxes
Password: osboxes.org
Root Account Password: osboxes.org

```

## Using Vagrant and Oracle VirtualBox

Vagrant is a command-line utility tool for managing virtual machines and their entire lifecycles in a single workflow.

- Download and install Vagrant from the [**Vagrant Setup**](https://developer.hashicorp.com/vagrant/install) page.

- Download the Oracle VirtualBox setup from the [**VirtualBox Download**](https://www.virtualbox.org/wiki/Downloads) page and install it on your machine.

- Launch a terminal and navigate to the location where you want to initialize Vagrant virtual machines.

Use the following commands:

1. `cd "your-folder-location"` to navigate to the folder.

2. `vagrant` to check the Vagrant installation and display common command options.

![Vagrant Check Installation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oc1pi4a2wcj6o45wtrh7.png)

- Initialize a virtual machine using the command `vagrant init "virtual-box-name"`. Find the list of virtual box names and commands on the Vagrant Cloud boxes page - [**CentOS**](https://app.vagrantup.com/centos/boxes/7).

![Vagrant Init](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/shl8x2w6xuh4bghlz7mq.png)

- Run the command `vagrant up`. This downloads the necessary files, creates the virtual machine, and configures its basic settings.

![Vagrant Up](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ukq9hmpxp6hg876n21ei.png)

Once the `vagrant up` command finishes, your virtual machine is ready and booted up! You can customize the VagrantFile to configure and change the default settings of the virtual machine.

## Conclusion

In conclusion, virtual machines provide an efficient way to create isolated environments for your development projects. By using tools like Oracle VirtualBox and Vagrant, you can easily set up and manage VMs, ensuring a smooth and consistent workflow across different platforms. Embrace the power of VMs and enhance your development experience by creating customized local work environments.

Enjoy creating your local dev environments with different virtual machines 🧑💻