Tuesday, April 3, 2012

Creating an Olive with JunOS 12.1 on VirtualBox




First, download jinstall-12.1R1.9-domestic-signed.tgz from the Juniper website.





You’ll need to unpack it and play around with it a little. Unpack the tgz

sam@laptop:~/Downloads$ mkdir jinst-signed
sam@laptop:~/Downloads$ cd jinst-signed/
sam@laptop:~/Downloads/jinst-signed$ tar -xzf ../jinstall-12.1R1.9-domestic-signed.tgz
sam@laptop:~/Downloads/jinst-signed$ ls -l
razem 437104
-rw-r--r-- 1 sam sam      7153 2012-03-24 19:57 certs.pem
-rw-r--r-- 1 sam sam        50 2012-03-25 03:31 +COMMENT
-rw-r--r-- 1 sam sam      1154 2012-03-25 03:31 +CONTENTS
-rw-r--r-- 1 sam sam       195 2012-03-25 03:31 +DESC
-rw-r--r-- 1 sam sam     87216 2012-03-25 03:31 +INSTALL
-rw-r--r-- 1 sam sam      6267 2012-03-25 02:25 issu-indb.tgz
-rw-r--r-- 1 sam sam 447458263 2012-03-25 02:40 jinstall-12.1R1.9-domestic.tgz
-rw-r--r-- 1 sam sam        33 2012-03-25 03:19 jinstall-12.1R1.9-domestic.tgz.md5
-rw-r--r-- 1 sam sam        41 2012-03-25 03:19 jinstall-12.1R1.9-domestic.tgz.sha1
-rw-r--r-- 1 sam sam       525 2012-03-25 03:31 jinstall-12.1R1.9-domestic.tgz.sig



There are tons of of files in this archive, and lots of guides say to try and play with it and pack it back up, but it’s actually a lot easier to just use the unsigned archive jinstall-12.1R1.9-domestic.tgz


If we unpack this, we get the following files:



-rw-r--r-- 1 sam sam  11673600 2012-03-25 02:38 bootstrap-install-12.1R1.9.tar
-rw-r--r-- 1 sam sam        39 2012-03-25 02:39 +COMMENT
-rw-r--r-- 1 sam sam       702 2012-03-25 02:39 +CONTENTS
-rw-r--r-- 1 sam sam    106121 2012-03-25 02:39 +DEINSTALL
-rw-r--r-- 1 sam sam       244 2012-03-25 02:39 +DESC
-rw-r--r-- 1 sam sam    107634 2012-04-02 19:57 +INSTALL
-rw-r--r-- 1 sam sam 440390207 2012-03-25 02:26 jbundle-12.1R1.9-domestic.tgz
-rw-r--r-- 1 sam sam      5933 2012-04-02 19:56 pkgtools.tgz
-rw-r--r-- 1 sam sam    106669 2012-04-02 19:57 +REQUIRE



We need to do edit the +INSTALL and +REQUIRE files here. Do a search for "re_name" and you'll find the following line:



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

This will make the install fail, so we need to replace it with the following:

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


Once you've updated both of these files, unpack the pkgtools.tgz into a new directory


sam@laptop:~/Downloads/jinst-signed/jinst$ mkdir pkgtools
sam@laptop:~/Downloads/jinst-signed/jinst$ cd pkgtools/
sam@laptop:~/Downloads/jinst-signed/jinst/pkgtools$ tar -xzf ../pkgtools.tgz
sam@laptop:~/Downloads/jinst-signed/jinst/pkgtools$ ls -l
razem 8
drwxrwxr-x 2 sam sam 4096 2012-04-02 18:52 bin
drwxrwxr-x 2 sam sam 4096 2012-04-02 18:52 pkg
sam@laptop:~/Downloads/jinst-signed/jinst/pkgtools$ ls -l bin/
razem 4
-rwxr-xr-x 1 sam sam 2980 2012-04-02 19:55 checkpic



The checkpic file needs to be replaced with the "true" program from FreeBSD, so now is a good time to install it on our virtual machine. I've used FreeBSD 7.3, because FreeBSD 8 and higher use gpart instead of bsdlabel for changing the boot partition, but if you're keen to play with it, look in the +INSTALL file for the line "bsdlabel -B -b /boot/boot $labeldrive"


Anyway, get the i386 ISO for FreeBSD (the NZ mirror is on Citylink, so if your ISP zero-rates traffic through WIX/APE then it won't add to your data cap), and make up a virtual machine. I've used VirtualBox, but it should work in any virtual machine software



I used 512MB at first, but it wasn't enough for JunOS 12.1 - bumping it up to 640MB for the install made it work though. As you'll see in the later screenshots, I did this on my netbook with 990MB of RAM, so I couldn't bump it up too much further.

 An 8GB virtual hard drive gives you lots of room for new versions of software in your /var/tmp directory

This part is important - when booting, you can only see the output from JunOS through the console port. The easiest way to get this set up is to install socat and screen, and use the following command:
socat UNIX-CONNECT:/tmp/olivecom1 PTY,link=olivescreen
This will hang (only works once the virtual machine is running and the pipe is created) - so in a second terminal use this command:
screen olivescreen


 Boot up the installer, and go for a Standard install.
At the partition screen, push C to create a new slice, and allocate all the disk space to it. Then press Q and go to the next screen
 Choose a Standard boot loader
 The next screen lets you create partitions. Create the first partition with 1024M, as a file system partition, and mount point /

 Once this is done, create a 1024M swap partition, then a 16sM file system partition mounted at /dummy (this makes the labels line up so the installer doesn't fail), a 1024M file system partition at /config, and the last partition (with all the left over space) on /var

 Looking good so far? If the drive labels don't match up (i.e. no partition ad0s1f) then the JunOS install will fail

 Do a minimum install, install from CD/DVD, say no to all the questions, and you're done!
 Now you can exit the installer and reboot (don't forget to eject the virtual DVD!)
 When it reboots, use "dhclient em0" to get an address (probably 10.0.2.15), and then copy the file /usr/bin/true to your computer. The command "scp /usr/bin/true name@10.0.2.2:~/" should work for some computers, but under lubuntu it fails, so I had to use my GuruPlug instead ;)

Let's leave that virtual machine cooking for a bit. Now you have this "true" file, copy it in place of checkpic in your pkgtools/bin directory, then pack it all up

sam@laptop:~/Downloads/jinst-signed/jinst/pkgtools$ tar -xzf ../pkgtools.tgz *


Delete the pkgtools directory, and pack this all up into another .tgz

sam@laptop:~/Downloads/jinst-signed/jinst$ tar -xzf ../jinstall-12.1R1.9-domestic-olive.tgz *


Then you're good to go. Use scp to copy this onto your virtual machine, and use the pkg_add command to install JunOS 12.1
 When it's all done, rebooot, and watch it all in your terminal
And here is your JunOS 12.1 Olive. Haven't tested mine yet, but will end up using it as a testbed for big changes at work. Make sure you use the "cli" command to get the JunOS commandline, then run it like normal - use "request system power-off" to shut it down before turning it off. Check my older posts for how to network them, and remember - ethernet multicast fails on these, but you can make it work over GRE or IP-IP tunnels (older posts cover this too).