Installing Olive 12.1R1.9 under Qemu

Introduction

The article describes installation of Junos 12.1R1.9 on emulated x86 hardware. Hardware is emulated by Qemu  and Junos installed on it is known as  Olive.

As Olive does not have Packet Forwarding Engine PFE attached, packet forwarding is  exclusively depending on performance of the host CPU.  In addition, they are also configuration known not working on Olive. Considering these limits, Olive can never substitute real Juniper hardware.

In spite all of that Olive is an excellent tool for testing configurations that can be later deployed on real Juniper hardware. Thanks to GNS3 project  that offers lightweight GUI for Qemu, complex labs can be easily deployed without real need of knowing Qemu commands.

The article could not be written without help of this guide.

My goal is to rewrite these articles for actual Junos 12.1R1.9 version  and  create a guide that  helps you to install  Junos. Please use  links above if you feel that you need to clarify details or  further explanation.

Prerequisites

host system - any Linux installed on x86 with at least 2GB RAM and 5 GB HDD space dedicated for Qemu disk. Have in mind that you need to dedicate  512MB RAM for each Olive instance.
Qemu emulator - installed on Linux How to
FreeBSD 4.11 installation CD - 4.11-RELEASE-i386-miniinst.iso
the copy of the jinstall 12.1R1.9 package (M/T series install package) - jinstall-12.1R1.9-domestic-signed.tgz

 Installation Steps

1. Create Qemu Disk
2. Install FreeBSD
3. Install Junos
4. Install jweb GUI

Create Qemu Disk

/usr/local/bin/qemu-img create -f qcow2 olive-base.img 16G

Install FreeBSD

/usr/local/bin/qemu-system-i386 -m 512 -hda olive-base.img -cdrom ./4.11-RELEASE-i386-miniinst.iso -enable-kvm

The command starts Qemu disk olive-base.img with 512MB RAM with attached FreeBSD image. Omit a parameter -enable-kvm if your hardware does not support hardware virtualization.

Steps:

a) Select - Standard Installation

b) Create Disks Partitions

Press a - Use entire disk, q to confirm.

Select install a standard MBR and when you see the FreeBSD Disklabel editor, press c to create the following partitions:

ad0s1a       /         4096M
ad0s1b    swap       4096M
ad0s1e    /config    256M
ad0s1f    /var          rest

Press q to finish. Choose Minimal distribution type  and install from a FreeBSD CD/DVD.

Once files are copied, the installer program will ask you many questions. Just answer No for each of them. Set password for root account and exit. When FreeBSD start to  reboot itself, close the Qemu window.

Install Junos

We need to extract an installation archive and edit files inside archive in order to install Junos successfully. Due to the huge amount of time it would take on the guest, I suggest you to extract archive inside the host system. It is much faster than to do the same in FreeBSD. Then we can pack archive back and copy it to the guest.

Here are the steps:

a) Copy true utility from FreeBSD to the host

Checkpic is binary that is stored in the installation archive. We have to replace this binary with utility /usr/bin/true located in  FreeBSD. Start qemu disk and copy utility to the host.
Here is the command we will use:

/usr/local/bin/qemu-system-i386 -m 512 -boot c -net nic,macaddr=00:aa:00:60:01:01,model=e1000 -hda olive-base.img -enable-kvm -net user

The command tells Qemu to start Qemu disk with single network e1000 interface. After boot, configure network settings as following:

dhclient em0

The command assigns an IP address 10.0.2.15/24 to the interface em0 and create a static route 0.0.0.0/0 to the default gateway 10.0.2.2. Do not panic if you are not familiar with those strange network settings - in fact, there is NAT connection between the guest and host system. You should be able to transfer file without any difficulties.

Use scp command for secure transfer. Copy true utility to your home directory. Let's say that mine is /home/brezular/.

scp -rv /usr/bin/true brezular@10.0.2.2:/home/brezular/

b) Resolve checkpic binary and hardware check

This part consists of steps that extract archive file and modify files located inside it. After changes, archive will be repacked. Now, let's say that a file jinstall-12.1R1.9 is stored in the  host system in a directory /home/brezular/.

cd /home/brezular/

mkdir ./jinst-signed
cd jinst-signed
tar zxvf ../jinstall-12.1R1.9-domestic-signed.tgz

Once archive is changed, checksum is not valid. Delete following files:

rm *.sig *.sha1 *.md5

During installation, hw.re.model will be checked. As it is not such a option supported in FreeBSD, we have to prevent to check this parameter. To avoid it, modify the file +INSTALL file and find function check_arch_compatibility(). Comment line starting with word re_name and assign a dummy value to re_name as it is shown below.

vi ./+INSTALL

check_arch_compatibility()
{
#re_name="`/sbin/sysctl -n hw.re.name 2>/dev/null`
re_name="olive"
if [ -z "$re_name" ]; then
Error "hw.re.name sysctl not supported."
fi

mkdir ./jinst
cd jinst
tar zxvf ../jinstall-12.1R1.9-domestic.tgz

Once again, modify +INSTALL file and assign a dummy value to re_name.

vi ./+INSTALL

check_arch_compatibility()
{
#re_name="`/sbin/sysctl -n hw.re.name 2>/dev/null`
re_name="olive"
if [ -z "$re_name" ]; then
Error "hw.re.name sysctl not supported."
fi

Now modify +REQUIRE file and assign a dummy value to re_name.

vi ./+REQUIRE

check_arch_compatibility()
{
#re_name="`/sbin/sysctl -n hw.re.name 2>/dev/null`
re_name="olive"
if [ -z "$re_name" ]; then
Error "hw.re.name sysctl not supported."
fi

mkdir ./pkgtools
cd pkgtools
tar zxvf ../pkgtools.tgz
cd ./bin
cp /home/brezular/true ./checkpic
cd ..

tar zcvf ../pkgtools.tgz *
cd ..
rm -rf pkgtools

tar zcfv /home/brezular/jinstall-12.1R1.9-domestic-olive.tgz *

At this point we have an installation file - jinstall-12.1R1.9-domestic-olive.tgz ready for installation  in a home directory.

c) Copy installation file and GUI file to the guest

In case you would like to manage Olive with GUI, copy an installation package jweb-12.1R1.9-signed.tgz to /home/brezular/. Then go back to the guest. Use following commands to copy an installation file and GUI file to the guest.

scp -rv brezular@10.0.2.2:/home/brezular/jinstall-12.1R1.9-domestic-olive.tgz /var/tmp/

scp -rv brezular@10.0.2.2:/home/brezular/jweb-12.1R1.9-signed.tgz /var/tmp/

d) Install Junos package

pkg_add -f /var/tmp/jinstall-12.1R1.9-domestic-olive.tgz

Once package is installed, halt FreeBSD and close the Qemu window.

halt

Start Qemu and continue in installation with following command.

/usr/local/bin/qemu-system-i386 -m 1024M -boot c -net nic,macaddr=00:aa:00:60:01:01,model=e1000 -hda olive-base.img -enable-kvm -net user
-serial telnet:0.0.0.0:3000,server

During Junos installation, a temporary partition /tmp is allocated in RAM. If we only start Olive with 512MB RAM, installation hangs up. For this reason increasing RAM is required.
Also notice that like any other router, Juniper does not have VGA output and redirects output to the serial port. Thus we must tell Qemu to redirect a serial port to the telnet port.

Telnet to localhost and check an installation process.

telnet localhost 3000

When  installation is finished, Olive automatically reboots. After boot we will be sitting in login prompt. Login as root without password.

Install Jweb GUI

To get to Junos cli, type command cli. Package can be installed  with following command.

request system software add /var/tmp/jweb-12.1R1.9-signed.tgz

if you want to reduce size of Olive, remove installation files in directory /var/tmp/.

rm /var/tmp/jinstall-12.1R1.9-domestic-olive.tgz
rm /var/tmp/jweb-12.1R1.9-signed.tgz

20 thoughts on “Installing Olive 12.1R1.9 under Qemu

  1. For Ubuntu users out there, you might need to do two things to get this running:
    - install qemu 0.14.0 (by default universe installs 0.12.x)

  2. Hi can somebody lemme know the commands/steps on how to upgrade qemu in gns 3 from j7.3R3.6 to 10.1 r1 8 release
    . please suggest..

  3. Hello,
    I think it is a very useful learning tool. I tried before but I did not succeeded.
    I will try again!
    Did you try with SRX?

    Thank you.

  4. Hello,

    VRRP works in this version? I tried using 12.2R2.4 in VirtualBox and i received "VRRP is not running" on console.

    Thanks.

  5. Hi Team,
    I am running Olive12.1R1.9 on GNS3 and working fine but when ever i connect JUNOS with CISCO Router. ping is not happening even i changed interface card from nic6000 to i82259er.
    Please revert me back beacuse i am stucked on this from last week.

  6. Hi,
    I have installed olive 12.1 and have installed jweb I can connect to the login form but it does not seem to authenticate.
    Any idea any one ?? it's really urgent

  7. for ubuntu 13.1

    after downloading and extracting qemu and applying the patch, you need to add the following change.

    vi qemu-0.11.0/i386-softmmu/Makefile

    add (or edit ) this line. You must have -lrt etc for it to compile.

    LIBS=-lz -lm -lrt

  8. Hello Brezular,

    I am a mac user. May I know where should I run this following comment to create qemu disk and to install freebsd. I hope you will help me.

    Create Qemu Disk

    /usr/local/bin/qemu-img create -f qcow2 olive-base.img 16G

    Install FreeBSD

    /usr/local/bin/qemu-system-i386 -m 512 -hda olive-base.img -cdrom ./4.11-RELEASE-i386-miniinst.iso -enable-kvm

  9. Im trying to accomplish that right now. versio 13.3R6.5. Getting stuck on the bootloader screen after adding it installer to freebsd with pkg_add. Will let you know my findings

Leave a comment

Your email address will not be published. Required fields are marked *