How to Setup Ubuntu 20.04 LTS on your local windows machine using Vagrant
Tags: linux, vagrant, virtualbox, ubuntu
Published: 2023-05-04 10:14:32

You have a windows computer, however you need to run some resources on a Linux operating system (OS) while still maintaining your windows machine, this is where system virtualization comes in. In this  article, we will loo at how to set up Ubuntu (one of the many Linux OS distributions) on a local windows system without interrupting anything.

**Requirements**

A host machine (your physical hardware also called bare metal) which is your Laptop or desktop running on a windows operating system with at least an 8GB RAM size.

**Outline**:

- Install VirtualBox
- Install Vagrant
- Setup Vagrant Box

Let's get started.

#### A. Download and Install VirtualBox

A virtualization software is required, this is where the Linux OS will be installed. There are a few virtualization software. Most cloud service providers make use of virtualization software to spin up the virtual machines we purchase to host resources on. For this purpose, I will be using VirtualBox (VBox). 

Go to [Virtual Box](https://www.virtualbox.org/wiki/Downloads) to download VirtualBox for windows hosts and complete the installation following the guided GUI.

On completion, a VBox shortcut icon will be created on your desktop by default except you choose not to.

****

#### B. Create a new Ubuntu machine from the installed virtual box.

**1.** New Linux machine named 'AltSchool' (name yours as you wish) with version Ubuntu 64-bit.                                                                                                      

<img width="370" alt="Capture 1" src="https://user-images.githubusercontent.com/83463641/189770731-437afbf6-1723-41f4-b13a-4bad2486628f.PNG">

**2.** Allocate memory, here I allocated 4GB memory 

<img width="315" alt="Capture 2" src="https://user-images.githubusercontent.com/83463641/189770805-39e68bdb-02d3-4f71-9b3c-b5eadcf2020a.PNG">

**3.** Create a virtual hard disk with 12GB recommended size

<img width="312" alt="Capture 3" src="https://user-images.githubusercontent.com/83463641/189771688-3c305004-007b-4025-8bfa-f3e25a3a52b9.PNG">

**4.** My hard disk file type is VirtualBox Disk Image

<img width="326" alt="Capture 4" src="https://user-images.githubusercontent.com/83463641/189771810-60316494-1f9a-4c07-9a94-4a5bd0f11670.PNG">

**5.** Dynamic storage allocated on physical hard disk

<img width="322" alt="Capture 5" src="https://user-images.githubusercontent.com/83463641/189771881-b6ea94de-1fcb-4fc8-be4e-ba8da7425b17.PNG">

**6.**  My AltSchool Virtual Machine created! 💃

<img width="959" alt="Capture 6" src="https://user-images.githubusercontent.com/83463641/189771952-2dff46d8-615d-47c2-9fa9-cd13762380f5.PNG">

****

#### C. SETUP UBUNTU 20.04 LTS ON YOUR LOCAL MACHINE USING VAGRANT

**1.** Vagrant is an open-source software developed by Hashicorp. It enables the creation and configuration of lightweight, reproducible, and portable development environments. It is designed for anyone to have access to a simple and fast way to create a virtualized environment.

Download Vagrant from [Vagrant Up](https://www.vagrantup.com) and install it following the default installation prompt. 

<img width="839" alt="Capture-1" src="https://user-images.githubusercontent.com/83463641/189772175-d1d5341a-a716-482c-9ae3-9c2793883363.PNG">

**2.** Find a virtual machine image from [Vagrant](https://app.vagrantup.com/boxes/search) called boxes in this case an Ubuntu 20.04 LTS (Focal64) and take note of the name. There are other Ubuntu images available. You can select any you find suitable.

<img width="884" alt="vagrant box -focal" src="https://user-images.githubusercontent.com/83463641/189772521-656a1bc3-8df3-4f43-808f-939e85652f44.PNG">

**3.** Create a folder where you want your Ubuntu image initialized.
Switch to a terminal (I used PowerShell in this case) and change into the directory. Then to initialize ubuntu, run the following command. 

```
vagrant init ubuntu/focal64
``` 

This action creates a Vagrantfile in the current folder, you can run `ls` to confirm.

**Note:** If you chose an image different from Ubuntu 20.04 LTS, kindly change focal64 to the exact name of your preferred Vagrant box name

<img width="511" alt="Capture 2" src="https://user-images.githubusercontent.com/83463641/189772994-8f195292-807f-47db-8701-86c0df02694f.PNG">

**4** Run the next command which looks for the necessary configuration files for creating the virtual machine or downloads it if not found.

```
vagrant up
```

<img width="597" alt="Capture 3" src="https://user-images.githubusercontent.com/83463641/189773311-fdd22deb-446b-4f18-b730-ee48d9ff5dde.PNG">

**5** Then next command lets us access or log in to the ubuntu machine. When complete, your machine will be ready for use.

```
vagrant ssh
```

<img width="612" alt="Capture 4" src="https://user-images.githubusercontent.com/83463641/189773375-36fd39e2-7fef-4d11-8ec2-0639688c730d.PNG">

****

Thanks for reading my article, feel free to drop a comment to share your experience with this method. 😊