Linux workstation

Friday, Apr 30, 2021

Being application developer usually I take the hardware and networking for granted, Something which is just there. I knew it’s a world in it’s own right, thus wanted to foray into it and slowly work my way to understanding it a bit better.

Vagrant being the first of the many tools that I wanted to explore, it is an easy to use and setup. Also it turned out to be a good alternative to play around with differnt linux distros and use anyone without commiting any hardware to it upfront. I guess I’ll use my current setup (ubuntu 20.10 with xfce4 desktop) as my workstation to try out different technologies while using windows for other entertainment stuff.


Getting Started

Starting slow I setup the necessary softwares with below links :

Next just used below commands :

vagrant init
vagrant up

This created a very basic Vagrantfile which was up and ready to be run, no issues there.

Next was time to do something a bit more real : Wrote a basic vagrant file to use the bento boxes

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-18.04"
end

saved the above in the Vagrantfile and tried to run with vagrant up, but this threw error in windows :

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'bento/ubuntu-18.04' could not be found. Attempting to find and
 install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
The box 'bento/ubuntu-18.04' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Vagrant Cloud, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:

URL: ["https://vagrantcloud.com/bento/ubuntu-18.04"]
Error: schannel: next InitializeSecurityContext failed: Unknown error (0x8009201
2) - The revocation function was unable to check revocation for the certificate.

Apprantely after google for a while found this is an issue with Vagrant and a way to solve this is by disabling your antivirus. This wasn’t really a way I was happy with so tried to find a different way :

What one can do is just download the box manually from vagrant-cloud and add to your own vagrant setup, below links helped to get what I wanted to do :

So I downloaded the bento-ubuntu box from vagrant-cloud. Renamed the file to bento-ubuntu-1804.box and added to vagrant using below command :

vagrant box add base-box .\bento-ubuntu-1804.box

This took a while to have the correct box added but everything went smoothly.

Next I moved to gitbash as I needed to ssh into the box and powershell doesnot have it setup by default :

vagrant ssh

Vagrantfiles

These files usually have a very defined structure. One can alter the machine settings by changing section :

config.vm.box

And change the virtualbox setup with changing section :

config.vm.provider

Also one can add scripts to be run at start up using inline :

config.vm.provision "shell", inline: 

Or run a big script by adding the script to variable and running that variable :

config.vm.provision "shell", inline: $script, privileged: false

More details about these settings can be found here.

Also to search for the different vagrant boxes head up to vagrantcloud and prefer to download the boxes manually instead of downloading at run time via Vagrantfile that way antivirus won’t get in the middle.

An update :

I had issues with setting up a desktop environment right from Vagrantfile thus followed below to set it up after setting up the virtual machine. I used the Vagrantfile here. then used below commands to have one time setup of xfce4 desktop :

sudo apt-get install -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
sudo VBoxClient --clipboard
sudo VBoxClient --draganddrop
sudo VBoxClient --checkhostversion
sudo VBoxClient --seamless


startxfce4&

And here we go …