Saturday 13 March 2010

Preparing VirtualBox and FreeBSD for Juniper Olive


You can run JunOS software on a FreeBSD box with no major problems it’s called a Juniper Olive and it’s a great way of studying for your JNCIx exams, this post aims to improve on a the basic installation method you see elsewhere on the web.

Basic disclaimer I stole from Sid Smokes site:
A note about the JUNOS software: I will not send anyone Juniper software. Don't ask. If you don't know how to get it, then you're probably not supposed to have it anyway. You can download it from the Juniper site if you have an account. Don't bug Juniper JTAC about olives either. They are not supported.”

The improvements here are two fold, firstly this is a fresh install of JunOS 14.2R8.4 without having to install a previous version and upgrade from there. Secondly I like the idea of having a lab running on a single box so I prefer my Juniper Olives to be virtualised – I know it can be done with VMWare but the way it handles serial ports, HDD (SCSI instead of IDE) and so on means that VirtualBox is my VM platform of choice for a hassle free installation.

Previously this guide only supported JunOS 32bit version, but I've since tested with 64bit and it works just fine. I'll provide notes where needed for the version you want to use.

Requirements (Software versions I’ve used are in brackets).
  • Windows (Windows 10).
  • Oracle VirtualBox (Version 5.2.4 r119785)
  • FreeBSD 6.4 - Either:
  • JunOS jinstall package.
    • 32bit procedure tested on 8.4, 8.5, 9.4, 10.0 and 12.3
    • 64bit procedure tested on 14.2
VirtualBox Step-By-Step
First thing you want to do is install Oracle VirtualBox – the default install options will be just fine.

Once done create a new VM as follows:

Create VM
  • Select New VM
    • Name: “JunOS64” (Original yes?)
    • O/S: BSD
    • Version: FreeBSD 32bit or 64bit.
  • Memory: 2048Mb (You can reduce this down depending on your version - but start with 2G)
  • Hard Disk - You’ll need to create a new hard disk using the wizard in this window. Create a dynamically expanding disk of about 50Gb.
  • Finish
You now need to edit the settings of the newly created VM, right click on the VM and select “settings”. Yes I know I’m teaching you to suck eggs.

Verify your settings are as follows:
  • System
    • Motherboard
      • Disable Floppy from Boot Order
      • Extended Features: IO APIC & EFI both disabled.
    • Processor
      • One CPU
      • Extended Features: PAE/NX enabled.
    • Acceleration
      • VT-x/AMD-V: Enabled - If you do not have the option then you may not be able to run JunOS in VirtualBox, some people report success but I've never been able to make it work. The only workaround is to install JunOS on another computer with virtualisation technology and move the VM over to this computer – I may tutorial this later but it’s a terrible pain in the arse.
      • Nested Paging: Enabled.
    • Display: Defaults
    • Storage
      • IDE Primary: Juniper Olive 1.vdi
      • IDE Secondary: FreeBSD CD ISO
      • Floppy: Empty.
    • Audio: Disabled.
    • Network:
      • Adaptor 1 – Enabled.
      • Attached to: Bridged Adaptor (You can also use NAT, this adaptor will enable you to share your internet connection so you can access your FTP server. If your PC is connected to a router for your DSL/Cable then select bridged. If your computer connects directly to the internet with a USB dongle or DSL/Cable card then select NAT).
      • Name: Whatever your current local network card is called.
    • Serial Ports
      • Port 1 Enabled
      • Port Number: COM1
      • Port Mode: Disconnected
    • USB: Disabled
    • Shared Folders: None.
That’s a bit of a long list of stuff and we’re not done yet but basically once you’re done your settings should look a little bit like this:



FreeBSD Install
Go ahead and fire up your VM, it should boot up and load the FreeBSD installer. Once you have chosen your language and keymap you will get to the main menu, you should select “Express - Quick installation (for experts)”.

When FDISK starts select “Use entire disk” (A key) then select the middle entry and make the disk bootable (S Key) then exit out (Q Key).

Let FreeBSD install the BootManager unless you have a pressing need to do otherwise.

You will now have to slice the disk as follows:
ad0s1a 1000M /
ad0s1b 500M swap
ad0s1d 10M /spacer
ad0s1e 500M /config
ad0a1f /var

The spacer partition ensures that /config and /var have the correct designation (ad0s1e and ad0s1f respectively) – if your designations look a bit different that’s not a big problem. If anyone knows how to specify the slice so there’s no need to have the spacer mount then let me know. Save those slices off and you’ll be taken back to the menu.

Select the Minimal Distribution then select your install media. If you have the full FreeBSD install on CD then you should use that – if you booted from a Net install CD then you need to specify an FTP site.

The URL for the site is as follows:
32bit - ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/i386/
64bit - ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/amd64/

(That may change, you may need to hunt about for the correct location.)

During the FTP install you will be asked if you want to set up your network, do so and enter your network IP/Mask and gateway as requested.

For a CD install you may not get asked so select it from the menu so your network is up and running when FreeBSD starts.

Install FreeBSD – Once it’s complete, un-mount your CD and reboot into FreeBSD. Login as root with no password and you are good to go to the next stage documented here.

11 comments:

Unknown said...

I'm having issues with the Olive when it first boots...it stops at this point:

Trying to mount root from cd9660:/dev/md0

The boot/loader.conf is calling that mount point:
# Our root is a memory disk.
vfs.root.mountfrom="cd9660:/dev/md0"

Is it attempting to mount a flash drive instead of the hard drive?

Please assist...tia

SleepyKitten said...

Sorry for the delay! Did you get this sorted? If not can you paste in the full boot messages up to this point and I'll take a looksee.

Joe said...

Thanks for these instructions, they are really good!. I had previously setup Olives using qemu in the past but I like the use of VirtualBox even more!

Thought I'd add a few additional steps in case they are not obvious to others. Once you have setup the Olive as per the instructions, you can access it just as you would a real Juniper Router (i.e. Telnet, SSH, etc.) from your host Operating System. In my case I've bridged the VM Interface to my Host-Only network (setup by VirtualBox when you install it). Therefore I want to assign a management IP Address to the Olive that is in the same Host-Only network defined in VirtualBox. In my case this network is 192.168.56.0/24 which I believe is the default. To do this, use the following steps:

(1) Get to CLI mode as per SleepyKitten's instructions
(2) Type "configure"
(3) Enable SSH and Telnet

set system services telnet
set system services ssh protocol-version v2

(4) Add a user called "admin" (after entering this command you'll be prompted to enter a password for this user)

set system login user admin class super-user authentication plain-text-password

(5) Set the management IP Address of the Router (I'll pick 192.168.56.100)

set interfaces em0 unit 0 family inet address 192.168.56.100/24

(6) Save the changes

commit

If you have any errors you must fix them so a clean commit can be performed.

(7) Exit the configuration mode

exit

(8) I had to reboot my VM before I could TELNET or SSH to the Olive from my host operating system. Once I did this I used PuTTY to access the Olive directly.

I setup JUNOS 10.3 without any issues!

Unknown said...

do you know for sure it won't work with freebsd 8.0 or a different version than 6.4?

SleepyKitten said...

@Andrei

I use 6.4 because that's what JunOS is built on (it was 4.4 IIRC prior to 8.3.

It may work with 8.0 but I've never had occasion to try.

Unknown said...

i'm also having similar issue as Stephen, i got the following error:

Trying to mount root from cd9660:/dev/md0

The boot/loader.conf is calling that mount point:
# Our root is a memory disk.
vfs.root.mountfrom="cd9660:/dev/md0"

is there any solutions for this, where should i point the root mount point?

i'm using sun virtualbox, freebsd-6.4 and jinstall-9.0R1.10-domestic-olive.tgz

Unknown said...

Get BSD 6.4 here: ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/i386/ISO-IMAGES/6.4/

nanto said...

Hi Sleepy Kitten

I already followed your instruction, but I got this messages

WARNING: The /tmp filesystem that is created by the next stage of
WARNING: the installer does not have sufficient space. This package
WARNING: requires 159804k free (2k for configuration
WARNING: files and 159802k for the new software), but there is
WARNING: only -12140k availabe.

WARNING: This installation attempt will be aborted.
WARNING: If you wish to force the installation despite these warning
WARNING: you may use the 'force' option on the command line.
pkg_add: package /var/tmp/jinstal-olive.tgz fails requirements installing anyway

after it saved the configuration I tried to reboot and monitor the installation via serial console but the installation was stuck in the package setting.

my system:
freeBSD mini 4.4
jinstall-8.5R1.14-domestic-signed.tgz
virtualbox 4.0.8
host os Ubuntu 11.04

please assist...thanks

TheLegs said...

If you want to keep the same labeling without /spacer, you can just delete it right after creating /config and /var :)

sirop said...

Hi.

Is this FreeBSD 32 or 64 Bit?

Tnanks,
Boris

SleepyKitten said...

@sirop

32bit. The later versions may need 64bit though!