In this lab you’ll set up your own local environment you’ll use in later labs to set up Ethereum and Hyperledger Fabric development and deployment environments. When you finish this lab, you’ll have t

BLCN631 Lab 1

Set up Vagrant/VirtualBox

V2.0

Introduction

This course introduces students to implementing blockchain applications. Before you can implement any software application, you need to ensue your development and deployment environment is in place. That means you’ll need all the tools and infrastructure installed and configured to support blockchain software development and deployment projects.

In this lab you’ll set up your own local environment you’ll use in later labs to set up Ethereum and Hyperledger Fabric development and deployment environments. When you finish this lab, you’ll have the infrastructure in place to build many different types of virtual environments on your own computer.

The instructions in this course’s labs assume that your computer runs the Windows operating system. If you run MacOS or Linux, you can get Vagrant and VirtualBox for those operating systems and follow the gist of the “Initial setup for Windows computers”.

Lab Deliverables:

To complete this lab, you must create a Lab Report file and submit the file in iLearn. The Lab Report file must be a Microsoft Word format (.docx), and have the filename with the following format:

BLCN631_SECTION_STUDENTID_LASTNAME_FIRSTNAME_Lab01.docx

  • SECTION is the section number of your current course (2 digits)

  • STUDENTID is your student ID number (with leading zeros)

  • LASTNAME is your last name, FIRSTNAME is your first name

To get started, create a Microsoft Word document (.docx) with the correct filename for this lab. You’ll be asked to enter text and paste screenshots into the lab report file.

NOTE: All screenshots MUST be readable. Use the Ubuntu Screen Capture utility (see the lab video.) Make sure that you label each screenshot (i.e. Step 2.1.3) and provide screenshots in order. For commands that produce lots of output, I only want to see the last full screen when the command finishes. Provide FULL screenshots, NOT cropped images.



SECTION 1: Initial setup for Windows computers Step 1.1: Install Oracle Virtualbox (Windows, Linux, MacOS)

Oracle Virtualbox is an open source virtualization environment that allows you to run multiple virtual machines and containers on a single personal computer. Virtualbox is free and it is easy to install.

In your favorite web browser, navigate to: https://www.virtualbox.org/ and click the “Download Virtualbox” button. Click the “Windows hosts” link to download the main installation executable. You should also click the “All supported platforms” under the “Extension Pack” heading to download extra software support for devices.

After you download the two files, double click each one to run the install procedure.

Step 1.2: Install Vagrant (Windows, Linux, MacOS)

Vagrant is a free virtual environment management utility. It makes the process of starting, stopping, and managing virtual machines easier. In your web browser, navigate to https://www.vagrantup.com/ then click the “Download” button, and click the version of the Windows executable you’d like to install. (Most of you should select the “64-bit” version.)

Once you download the install program, double-click the file you just downloaded to install Vagrant.

If you want more information on Vagrant and tips on getting the most out of the software, navigate to:

https://www.sitepoint.com/getting-started-vagrant-windows/ .

Step 1.3: Set up your first Vagrant project

After installing all the pre-requisite pieces, you need to set up your Vagrant project. A Vagrant project defines your virtual machine environment and helps you organize your collection of VMs into a group that is easy to manage.

We’ll use the Windows PowerShell as our Windows command prompt environment. PowerShell is a very powerful command line interface that is available on all Windows computers.

To launch PowerShell, click the Windows key, type PowerShell, then click the Windows PowerShell menu entry. The figure below shows a portion of the Windows PowerShell command prompt window.

In this lab you’ll set up your own local environment you’ll use in later labs to set up Ethereum and Hyperledger Fabric development and deployment environments. When you finish this lab, you’ll have t 1

PowerShell uses your user’s home directory as its starting directory. In my case, C:\Users\micha is my home directory. For the rest of the lab, I’ll refer to this a %HOME%. Your %HOME% will be different.

1.3.1: Create a new Vagrant project for Ethereum

Launch PowerShell and enter the following commands: (Don’t type ‘PS %HOME%>’, that’s just the PowerShell prompt. Just type the characters in bold.)

  1. PS %HOME%> mkdir vagrant

  2. PS %HOME%> cd vagrant

  3. PS %HOME%\vagrant> mkdir BLCN631eth

  4. PS %HOME%\vagrant> cd BLCN631eth

  5. PS %HOME%\vagrant\BLCN631eth> vagrant init kelly219design/ubuntu-xenial-16.04-gui-desktop-base

Make sure that you enter the line above as ONE LINE at the PowerShell prompt

  1. Go to the Blackboard site (ucumberlands.blackboard.com) and login.

  2. Navigate to this course (BLCN631) -> Content for this week, Lab01.

    1. Download the Vagrantfile file and copy it to the %HOME%\vagrant\ BLCN631eth directory. (This will overwrite the Vagrantfile that was already there.)

  3. PS %HOME%\vagrant\ BLCN631eth> vagrant up

NOTE: To stop your VM type vagrant halt in PowerShell


1.3.2: If you ever want to remove an existing Vagrant project, here’s how you do that:

Follow these steps ONLY if you already have a previous Vagrant project AND you want to remove it:

  1. PS %HOME%\vagrant> vagrant global-status

Note the id of the listed VM(s). You’ll use this id in the next command, in place of xxxxxxx.

  1. PS %HOME%\vagrant> vagrant destroy xxxxxxx

  2. PS %HOME%\vagrant> vagrant box remove ubuntu/xenial64


Section 2: Logging into your VM

Once you have an operating Linux VM, you can login and look around. If you’re new to Linux, don’t worry. The GUI desktop should be just enough like your preferred operating system that it won’t take long to be comfortable.

Here is a pretty good intro to Ubuntu: https://www.lifewire.com/beginners-guide-to-ubuntu-2205722


  1. If you haven’t started your VM, do the following:

    1. Open Windows PowerShell, then navigate to your Ethereum project directory.

    2. PS %HOME%\vagrant\BLCN631eth> vagrant up

  2. Login to your VM using the username: vagrant and password: vagrant

  3. Click “Search your computer” (upper left corner icon), then type terminal.

  4. Click on the Terminal icon to launch a terminal with a shell prompt.

You type all the following commands in your Linux VM (at the Terminal command prompt.)

Don’t type the ‘$’ character. That is the prompt character of a regular user to remind you that this is a command you should enter in Linux. When you see a ‘#’ character, that indicates you are in an elevated privilege shell. And the ‘>’ character indicates you’re in PowerShell. Pay attention to the prompt characters - they give you valuable information about your current context.

  1. $ sudo apt-get update

When you boot your VM for the first time, the operating system automatically tries to download and install important patches. Until this background process finishes the command in step 5 will give you errors. If you get errors in step 5, just wait for 10 minutes or so, and try it again.

  1. $ date

  2. Create a screenshot of the results of steps 5 - 6 and paste it into your Lab Report File

Use the Ubuntu Screenshot application and save it in the /vagrant directory. (Or you can use LibreOffice to create your Lab Report docx file in your VM.)


Section 3: Wrapping up

Once you have your VM up and running, the only step to complete is to learn how to properly shutdown your lab.

  1. Exit from your Linux Terminal command prompt(s) (i.e. close any open Terminal windows.)

  2. $ exit

  3. In Windows PowerShell, shut down your Ubuntu virtual machine:

  4. PS %HOME%\vagrant\BLCN631eth> vagrant halt

  5. Create a screenshot of the results of step 4 and paste it into your Lab Report File

  6. Create a snapshot (NOT A SCREENSHOT) of your Ubuntu VM in VirtualBox. This allows you to easily restore to this point if you ever need to “undo” subsequent steps and return to a known point.

    1. PS %HOME%\vagrant\BLCN631eth> vagrant snapshot save EndOfLab01

You should have 2 screenshots in your Lab Report File (make sure you label the screen shots - all I need is the step for each screenshot). Save your file (using the naming convention described in the lab introduction) and submit it in iLearn as a file attachment for the Lab 1 assignment.

Congratulations! You have complete lab 1.