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).

16 comments:

  1. Fantastic, I've been trying to get this working with 12.1 for a few weeks now and have been getting caught up, this has been tested on virtualbox and esxi 5 using freebsd 7.4 and works great.

    ReplyDelete
  2. hi

    I have done what you documented , but I get these errors
    [IMG]http://i45.tinypic.com/2n8q6is.png[/IMG]

    ReplyDelete
  3. I used vmware workstation 9 in windows
    and edited those two file .
    one more question , should I have packed the entire unsigned jinstall into the signed package with .sha ,signature and
    +INSTALL , +REQUIRE files again ?

    ReplyDelete
  4. Thanks for this. I'm interested to see this working with a FreeBSD 9 release.

    One thing I'd like to add, you actually don't need `/usr/bin/true`. You can just replace `checkpic` with a shell script that returns with an exit status of 0

    #!/bin/sh
    exit 0

    Also, there's a typo in your tar command to repack pkgtools and jinstall -- it's `tar -cvzf` for anybody following along at home.

    ReplyDelete
  5. Need a little help, modified the files as suggested and packed up the files, when installing it complaints there isn't enough /vartmp space but continues anyway. But when booting after package installed it hangs at the boot memu

    Any ideas?

    ReplyDelete
    Replies
    1. I think you should wait a while , try to get a serila console to JUNOS by using Named pipe TCP proxy program to see complete boot time messages and then check what is going on during boot time !

      Delete
    2. I experienced the same issue of the boot sequence hanging on the VM console:

      Loading /boot/loader
      BTX loader 1.00 BTX version is 1.02

      The serial console output is below and look good at first then hangs at "Waiting 5 seconds for SCSI devices to settle". It took a 5 mins (?) and then the kernel panicked and dumped me into a debug shell.

      Serial Console Output:
      =====================================
      Consoles: serial port
      BIOS drive A: is disk0
      BIOS drive C: is disk1
      BIOS 638kB/1046464kB available memory

      FreeBSD/i386 bootstrap loader, Revision 1.2
      (builder@greteth, Sat Mar 24 08:37:57 UTC 2012)
      Loading /boot/defaults/loader.conf
      /boot/installer text=0x54f678 data=0x3dad0+0x7dd60 syms=[0x4+0x69dd0+0x4+0x981af]
      -
      Hit [Enter] to boot immediately, or space bar for command prompt.
      Booting [/boot/installer]...
      platform_early_bootinit: M/T Series Early Boot Initialization
      Olive CPU
      GDB: debug ports: sio
      GDB: current port: sio
      KDB: debugger backends: ddb gdb
      KDB: current backend: ddb
      Copyright (c) 1996-2012, Juniper Networks, Inc.
      All rights reserved.
      Copyright (c) 1992-2006 The FreeBSD Project.
      Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
      The Regents of the University of California. All rights reserved.
      JUNOS 12.1R1.9 #0: 2012-03-24 09:18:41 UTC
      builder@greteth:/volume/build/junos/12.1/release/12.1R1.9/obj-i386/junos/bsd/kernels/MFS/kernel
      Timecounter "i8254" frequency 1193182 Hz quality 0
      CPU: Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz (2194.34-MHz 686-class CPU)
      Origin = "GenuineIntel" Id = 0x206a7 Stepping = 7
      Features=0xfebfbff
      Features2=0x96982203,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,,XSAVE,,>
      AMD Features=0x28100000
      AMD Features2=0x1
      real memory = 1073741824 (1024 MB)
      avail memory = 1030889472 (983 MB)
      Initializing M/T platform properties ..
      cpu0 on motherboard

      ...snipped for brevity...

      sio2: configured irq 5 not in bitmap of probed irqs 0
      sio2: port may not be enabled
      sio3: configured irq 9 not in bitmap of probed irqs 0
      sio3: port may not be enabled
      uhub2: vendor 0x0e0f VMware Virtual USB Hub, class 9/0, rev 1.10/1.00, addr 3
      uhub2: 7 ports with 7 removable, self powered
      Initializing product: 1 ..
      platform_mastership_init: Unknown product_type 0x00000001
      Timecounter "TSC" frequency 2194339525 Hz quality 800
      ###PCB Group initialized for udppcbgroup
      ###PCB Group initialized for tcppcbgroup
      md0: Preloaded image 9678848 bytes at 0xc0b0de38
      ad0: 12288MB at ata0-master UDMA33
      Waiting 5 seconds for SCSI devices to settle
      WATCHDOG_TIMER : Loss of soft watchdog
      panic: Loss of soft watchdog
      db_log_stack_trace_cmd(c09ae6e0,c09ae6e0,e076fb28,e076fb14,c05ab80e) at db_log_stack_trace_cmd+0x36
      panic(e076fb28,e076fb28,0,0,0) at panic+0x216
      statclock(e076fca4,c41b3120,e076fc78,c07aa209,e076fca4) at statclock+0x2e1
      rtcintr(e076fca4,0,0,c40c13e0,0) at rtcintr+0x4b
      intr_execute_handlers(c0987220,e076fca4,c40c0d20,c0572cc0,0) at intr_execute_handlers+0xe8
      atpic_handle_intr(8,e076fca4) at atpic_handle_intr+0xae
      Xatpic_intr8() at Xatpic_intr8+0x21
      --- interrupt, eip = 0xc07ad2e0, esp = 0xe076fce4, ebp = 0xe076fce4 ---
      cpu_idle_default(e076fd00,c0572cd4,e076fd00,80246,c40c0d20) at cpu_idle_default+0x5
      cpu_idle(e076fd00,80246,c40c0d20,e076fd24,c0570292) at cpu_idle+0x1f
      idle_proc(0,e076fd38,0,0,0) at idle_proc+0x14
      fork_exit(c0572cc0,0,e076fd38) at fork_exit+0x84
      fork_trampoline() at fork_trampoline+0x8
      --- trap 0, eip = 0, esp = 0xe076fd70, ebp = 0 ---
      ###Entering boot mastership relinquish phase
      KDB: enter: panic
      [thread pid 10 tid 100006 ]
      Stopped at kdb_enter+0x15f: movl $0xc093d2e2,0(%esp)
      db>

      Delete
    3. Open .vmx file and make sure the following line is set properly:

      scsi0.present = "FALSE"

      Delete
    4. Where is the .vmx file located? am using ubuntu with Virtual box

      Delete
  6. by the way I managed to download the ready to use virtual
    hard disk of the installed JUNOS 12 for vmware !
    Is it possible to install Junos for SRX with same procedures ?

    ReplyDelete
  7. Hi Sam,

    Great tutorial so far, just a final issue.

    Your screenshot after the pkg_add command, I can't see above the "WARNING: This installation will not succeed." Did you get any other errors such as:

    sysctl: unknown oid 'hw.product.model'
    sysctl: unknown oid 'hw.re.model'
    sysctl: unknown oid 'hw.re.model'
    sysctl: unknown oid 'hw.re.model'

    I did. Everything else is the same as yours, but the errors above. After a reboot the VM, the kernel panics and I can't continue.

    I uploaded a screenshot of my error here:

    https://lh3.googleusercontent.com/-tbK-RQt02Gw/UPYioo5eCxI/AAAAAAAAAPw/bu47oeuw-1E/w720-h480-p-k/Junos_Olive_Package_Install_Failure.png

    Thanks.

    ReplyDelete
    Replies
    1. I forgot to change the .vmx file:

      Open .vmx file and make sure the following line is set properly:

      scsi0.present = "FALSE"

      Delete
  8. Hi Sam and everyone,
    If I got a new version of the jinstall-xxx-xxx-sign.tgz (like jinstall-ex-2200-11.xR1.x-domestic-sign.tgz), but the package has now bootstrap-xxx-xxx.tar, how could I installed it into the virtualbox?

    Thanks for help!

    ReplyDelete
  9. Any body getting stuck at the jbundle
    =================== Bootstrap installer starting ===================
    Initialized the environment
    Routing engine model is Olive
    Discovered that flash disk = , hard disk = ad0
    Disk to install is ad0
    mfs: available=925992
    Using 925992 for /tmp
    Setting ospackage=jboot-12.1R1.9.tgz, configpackage=configs-12.1R1.9.tgz
    Setting packlist=jbundle-12.1R1.9-domestic.tgz

    ReplyDelete
  10. I also got stuck at this the jbundle part (using qemu), after changing the memory from 512 to 1024MB the system continued.

    ReplyDelete
  11. Thank you! The best guide to create Olive from original Junos.

    ReplyDelete