Setting up a Linux CentOS virtual image with Vagrant

Introduction

In this post, I’m going to create a new CentOS Linux image using Vagrant, tweak a couple of settings and make sure it has all the latest and greatest packages ready for Hyperledger.

 

Assumptions

  • You have followed all the steps to install Vagrant and Cygwin as described in this older post, right up to and including the section “Test Go in Cygwin”;
  • You are comfortable using a Linux command prompt.

 

Steps we will take

  • Build a 64bit Linux CentOs 7 virtual image using Vagrant
  • Change the Spanish language of the vm to English
  • Make sure Num lock is on at session start
  • Fix vi
  • Update from CentOS version 7.2 to 7.3

 

Build a 64bit Linux CentOs 7 virtual image using Vagrant

To start off, I open a Cygwin prompt in my Windows 7 host:

04.png

I am going to use a CentOs 7 Vagrant box that comes with a GUI. I enter the following commands:

cd /cygdrive/c/gocode

mkdir cent

cd cent

vagrant init kane_project/centos7x64GUIpuppet; vagrant up –provider virtualbox

After just a few minutes, I have a brand new virtual machine to play with:

05.png

Next, I set the Linux password for the vagrant user first by connecting to Centos via SSH and running the passwd command as a privileged user:

vagrant ssh

sudo passwd vagrant

That went well, except… my Linux talks Spanish instead of English:

06.png

 

Change the Spanish language of the vm to English

Let’s fix that, rapidamente. I do the following commands in Cygwin:

sudo yum install system-config-language

# confirm:

y

The result is successful, instalado !

07.png

Next we run the command to change the terminal language:

sudo system-config-language

This brings up the Wordperfect 5.1 interface to change languages:

08.png

We change the selection with the Up arrow to “English (USA)“, hit the TAB key to jump to the Yes button and hit the ENTER key:

09.png

Back in the Cygwin prompt, I disconnect from Centos with command:

exit

Then I log back in with:

vagrant ssh

This time, my prompt is in English:

10.png

The next step is to get a GUI. Log out again with:

 exit

We need to edit the file C:\gocode\cent\Vagrantfile in a text editor and edit out a few pound “#” characters to enable our GUI. You could do it using vi in Cygwin but I’m lazy and I’m going to do it in Notepad++ on Windows 7.

Here is the section of the Vagrantfile contents before I make the change:

11.png

Here is the same thing after I have saved my changes:

12.png

All right, let’s launch our graphical user interface with command:

vagrant reload

Hola! The result is promising,  but we still have some Spanish language artifacts we will need to get rid of:

13.png

Worth noting that when the CentOS GUI session times out and locks the screen, there is no login field in the window. You need to click on the screen and drag it up with the mouse to reveal the above login screen.

Anyhow, I click on the “vagrant” button:

14.png

I enter the password I set earlier with the passwd terminal command and click the Sign In button. I get a “sort-of” Spanish UI:

15.png

I click on menu Aplicaciones > Herramientas del ssistema > Configuracion

17.png

Next, click on Region e idioma :

19.png

Change the following:

20.png

To:

21.png

When prompted, click the “Reiniciar ahora” button, then the “Cerrar la sesion” button to accept to restart the session:

22.png

Log in to CentOS again. This time you are prompted to update the standard folders:

23.png

Click the “Update Names” button.  Log out once more to apply the changes to the session:

24.png

Log back in. This time if you click on places, there is no longer any Spanish visible:

25.png

Pretty good. Let’s move on.

 

Make sure Num lock is on at session start

This is a quick fix. In a terminal, do the command:

sudo yum install numlockx

That will take care of it, your num lock will be on on next session start.

 

Fix vi

I start editing in vi and every time I hit ENTER, the letter “B” appears. Annoyance. To fix this, you have to create new file /home/vagrant/.vimrc and add one line to it with the commands:

cd

echo “set nocompatible” > ./.vimrc

If you are used to the .bashrc file in your home folder to add an alias because you use Ubuntu or Linux Mint, then beware. On Centos and RHEL, the file used is different, it’s .bash_profile

Now that vi is working, like me you could tediously add the following command shortcut in that .bash_profile file:

alias ll=’ls -la’

 

Update from CentOS version 7.2 to version 7.3

After some struggles with Hyperledger 1.0, it turns out gRPC requires the very latest Linux kernel and C libraries. In other words, CentOs need to be updated from version 7.2 to 7.3.

Here are the instructions.

Don’t forget to restart, while still keeping your vm up, with command:

sudo reboot

(end of post)

 

Bertrand Szoghy,

Updated July 2017

 

 

 

 

 

Advertisements

One thought on “Setting up a Linux CentOS virtual image with Vagrant

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s