Howto build VyOS 1.2 ISO image and VMWare .OVF

From VyOS Wiki
Revision as of 15:49, 1 July 2017 by Max1e6 (talk | contribs)
Jump to: navigation, search

Background

I have been interested in getting VyOS to run as a Google Cloud Compete instance for quite sometime. Unfortunately, the current version of VyOS 1.1.x is based upon Debian 6 which just does not work (unless you jump through many more hoops then I am willing to jump through), so I became curious to see if this would be possible with VyOS 1.2. As I began my investigation into what it would take to compile VyOS 1.2 I noticed that all the documentation was present, but it was not that easy to use (IMHO) and I discovered several "gotchas". The purpose of this HowTo is provide a complete set of instructions on how to compile VyOS 1.2 and point out some of the issues I encounter so that others can do what I did easier and faster.

This HowTo assumes you are familiar with installing Linux and are comfortable working in the Linux shell/command line.

Enjoy.

--Max Abramowitz.

Building VyOS 1.2

Create Build Machine

The first step is to download and build a Debian 8 build machine. You can download Debian 8 "Jesse" from:

WARNING
Most of the build process can be done from the Linux shell. However, troubleshooting the qemu build process requires vncviewer which requires a graphical desktop environment. The screenshot below show the settings using in my testing.
VyOS build machine initial software configuration

Preliminary Build Machine Configuration

Before installing software you will want to perform some basic configuration of your build machine. Install sudo, add your user account to the sudo group, install open-vm-tools (if your build machine is a VMware virtual machine and install your preferred text editor). Below are the configuration commands I used (these commands were run as root user):

apt-get install sudo
adduser <username> sudo
apt-get install open-vm-tools
apt-get install emacs
WARNING
For some reason the left mouse button does not work with Debian under VMware (at least out of the box). There are a couple of articles on the Internet about this. I was able to login and get a terminal window open using a combination of the keyboard and the right mouse button. Once open-vm-tools was installed the left mouse started working.

Installing sudo and adding your user account to the sudo group is not strictly necessary and it does mean that you can do the build process from a non-root / non-priviledged account, which is a security best practice

Installing Required Software Components

Install the basic softare needed:

sudo apt-get install git autoconf automake dpkg-dev syslinux genisoimage qemu jq libz-dev zip python3 live-build pbuilder devscripts python3-pystache

There are a few components you will have to download from the Internet in order to build VyOS 1.2:

  • HashiCorp Packer - tool to build automated machine images (www.packer.io)
  • VMWare open-vmdk
  • VMWare ovftool

Packer

Download Packer. Upload to server. Unzip. Copy to a bin directory.

unzip packer_1.0.2_linux_amd64.zip
sudo cp packer /usr/local/bin/

VMWare open-vmdk

git clone https://github.com/vmware/open-vmdk
cd open-vmdk/
make
sudo make install

VMWare ovftool

You will need a VMWare account to download VMWare ovftool. Goto https://www.vmware.com/support/developer/ovf/. Click Software Download. Download the VMware OVF tool for Linux 64-bit. Upload the bundle to your build machine.

chmod 755 VMware-ovftool-4.2.0-4586971-lin.x86_64.bundle
sudo ./VMware-ovftool-4.2.0-4586971-lin.x86_64.bundle
Follow the prompts to complete the installation
=== Building ISO image ===
At this point all the software for building an ISO image should be installed on your build system and you can proceed with downloading the source code and building an ISO image
 git clone https://github.com/vyos/vyos-build.git
 cd vyos-build
 ./configure
 sudo make iso
Go get a cup of coffee. Once the build process is complete the .iso file will be in the build folder
=== Building qemu image ===
At this point we have a working .iso image and we can proceed with building the qemu image. Before we build the qemu image you will need to create a private ssl key and while not strictly necessary installing vnc (vncviewer specifically) is helpful to monitor the build process.

Build privatekey.pem

mkdir key
cd key
openssl genrsa -des3 -out privatekey.pem 2048
cd ..

Install VNC Viewer

I installed Tight VNC Viwer using the synaptic package manager.

packer.json

One of the steps in building the qemu image is to configure the vyos install. This process boots the .iso image, installs it as a virtual machine and then configures the image to work in a virtualization environment. Basically, it sets the ethernet interface to use dhcp, deletes the hardware id and enables ssh. Part of the packer.json file sends the key commands to Packer to do this. My experuience was that this did not work out of the box. I needed to modify the "boot_command" section of the packer.json file to adjust the wait times such that there was enough delay between keypresses and commands for the process to work.

Actually building qemu image

Open vnc viewer on your build machine

sudo make qemu

You will see:

qemu-image: Starting VM, booting from CD-ROM
qemu-image: The VM will be run headless, without a GUI. If you want to
qemu-image: view the screen of the VM, connect via VNC without a password to
qemu-image: vnc://127.0.0.1:59xx

Type 127.0.0.1:59xx in your vnc viewer client (replace xx with whatever shows up on your build. It changes each time.) This will allow you to monitor the Packer boot commands and determine if you need to make any modifications.

This will take a while.





Executive Summary

This HowTo describes how to build VyOS 1.2 from source. It assumes you are familiar with installing Linux and are comfortable working in a Unix shell/command line. The HowTo is based upon the readme file from the VyOS github site and adds some details and other observations which might not be that obvious.

Step 1: Create Build Machine Setup

For my testing I created a Debian 8 "jesse" virtual machine for building VyOS 1.2. You could use VMWare Workstation, VMWare Fusion, Virtual Box, HyperV or similar. For my testing I used an ESXi server in my lab environment.

  1. Download Debian 8 "jesse" (https://www.debian.org/releases/jessie/)
  2. Install Debian either on a dedicated machine or as a virtual machines.



Note: Install Gnome, KDE or your favorite windowing system. Most of the build process can be done via the command line. However, troubleshooting the qemu build process requires vncview, so it is recommended that you install a windowing system when you install Debian. I think I used Cinnamon.



Once Debian was installed I logged and ran the following commands as root:

apt-get install sudo
apt-get install open-vm-tools
apt-get install emacs

Comments

  • sudo is not strictly necessary, but is useful.
  • open-vm-tools was needed for running my build machine under ESXi.
  • emacs any text editor will do. I think nano is installed by default with Debian. Install your editor of choice.

At this point you should have a pretty clean install of Debian. If you are running a virtual machine and your environment allows for snapshooting now might be a good time to take a snapshot in case you make a mistake and need to revert.

Install Required Software

In addition to all the "standard" tools required to build VyOS there are a few others which are required to build VyOS 1.2:

  • Packer
  • VMWare open-vmdk
  • VMWare ovftool

First install the git and all the other linux tools needed:

sudo apt-get install git autoconf automake dpkg-dev syslinux genisoimage qemu jq libz-dev zip python3 live-build pbuilder devscripts python3-pystache

Download & Install Packer

Never heard of Packer before, neither had I...it is a pretty cool tool. You can download it here form https://www.packer.io/

  • Transfer .zip to your build machine
  • unzip
  • copy to /usr/local/bin



Download & Compile VMWare open-vmdk

Download & Install VMWare ovftool

Download VyOS Source

Generate Private Key

Build VyOS