rageek

A place for Unix Thoughts and Ideas

uberjs

Building a Custom UberJS boot cd/dvd for Solaris 10

For maintenance of my Solaris 10 images I have gone with the simple approach of maintaining one profile that works for all versions and architectures.

It is simply a profile that starts with SUNWCXall and then removes and adds packages back in and has worked consistently for various Solaris versions since u5. When a new update comes out, I just update the profile for packages to add/remove and re-check.

This is in contrast to having to generate and manage flars for every hardware type and os revision.

Since my provisioning strategy depends on Jumpstart profiles and not Flars, I have had a solid dependency on RARP/DHCP/PXE for provisioning.

I have no control over the DHCP/PXE on my subnets, so I updated Uberjs to work on Solaris 10 so I can provision x86 and Sparc systems when I didn’t have a local jumpstart server.

Here is my process for building a custom Solaris 10 jumpstart cd/dvd for Solaris Sparc and x86

I have images for various versions of solaris 10, but this is one for Solaris 10 u9.
Please note that if you are planning to use a zfs root filesystem, you can only use an update 9 cd/dvd to provision an update 9 machine. This is due to update 9 having a newer version of zfs and u8 cannot mount the newer zpools, you might be able to get around this if you patch the image as part of the jumpstart process.

Here is a my modified copy of uberjs (original copy is available at http://clue.eng.iastate.edu/uberjs)
http://dl.dropbox.com/u/2529674/uberjs-exec

I have made the following changes
1. Changed the regex strings to accommodate newer drivers such as e1000g and to better filter out ifconfig output.
2. Change nslookups to getent hosts
3. Fix bug where the script would ask for the default gateway regardless if it was defined previous, this meant that only the last interface in its loop could be used, this sucked when using nxge’s on M4000’s and the built-ins for the X4100. 
4. Had it unset IP_FROM_ETHERS after the hostname is set so it doesn’t trigger DHCP.
5. Added a 30 sec timeout with 3 retries for wget and added recurse option.

I manually specify my ip, netmask and gateway, I haven’t fully tested the other features and they may not work under solaris 10, if you find a issue and fix it, let me know and I’ll update my copy with the fix.

I have updated the install-discovery script to boot to single user (and not run uberjs) if the -s option is specified. 

Build Steps:
1. Mount the solaris 10 dvd iso via lofi.
lofiadm -a /isos/sol-10-u9-ga-sparc-dvd.iso
or 
lofiadm -a /isos/sol-10-u9-ga-x86-dvd.iso
/dev/lofi/1
mount -F hsfs /dev/lofi/1 /mnt

2. Create directory told hold new image:
mkdir -p /custom_iso/dvd
cd /mnt
find . -print | egrep -v ‘Solaris_10/Product|Solaris_10/Patches’ | cpio -pdm /custom_iso/dvd

3. Backup miniroots and Unpack/mount miniroot 
3a. SPARC only
cd /custom_iso
mkdir miniroot
cp `pwd`/dvd/boot/sparc.miniroot .
/boot/solaris/bin/root_archive unpack `pwd`/dvd/boot/sparc.miniroot `pwd`/miniroot

3b. x86 only 
cd /custom_iso
mkdir /custom_iso/miniroot
cp dvd/boot/x86.miniroot x86.miniroot.orig
/boot/solaris/bin/root_archive unpack `pwd`/dvd/boot/x86.miniroot `pwd`/miniroot
mkdir /custom_iso/miniroot_x64
/boot/solaris/bin/root_archive unpack `pwd`/dvd/boot/amd64/x86.miniroot `pwd`/miniroot_x64

4. Create Uberjs Directories 
cd miniroot/.tmp_proto
mkdir uberjs
cd uberjs

5. Setup uberjs
cp /custom_iso/uberjs-exec .
ln -s /usr/sfw/bin/wget wget
chmod a+x uberjs-exec

For my installations, I specify the IP/Gateway information and do not rely on dhcp or any autodectection. 

touch disable_dial
touch nodhcp
touch noautoroute

7. Create nfs_server file
This has the information for your jumpstart media, rules & profile and sysidcfg. You can skip this step if you want to exclusively get this info from a downloaded file

cat nfs_servers
192.168.17.150:/export/jumpstart/install/sol_10_0910_x86   192.168.17.150:/export/jumpstart/config    192.168.17.150:/export/jumpstart/config/sysidcfg/default
192.168.17.150:/export/jumpstart/install/sol_10_0910_sparc   192.168.17.150:/export/jumpstart/config    192.168.17.150:/export/jumpstart/config/sysidcfg/default
192.170.48.150:/export/jumpstart/install/sol_10_0910_x86  192.170.48.150:/export/jumpstart/config   192.170.48.150:/export/jumpstart/config/sysidcfg/default
192.170.48.150:/export/jumpstart/install/sol_10_0910_sparc  192.170.48.150:/export/jumpstart/config   192.170.48.150:/export/jumpstart/config/sysidcfg/default

8. Create wget_servers file
This file tells uberjs where to download the nfs_server or any other files you want, this isn’t necessary if you specified the options in 8

The logic in the script literally does a cp -r /tmp/wget/*/*, because of this, any files you retrieve must be in the uberjs subdirectory off of your web server. 
ie http://servername/jumpstart/uberjs works, http://servername/uberjs doesn’t

cat wget_servers 
http://192.168.17.150/jumpstart/uberjs/nfs_servers

9. Update Solaris install scripts
cd /custom_iso/miniroot/sbin
Modify install-discovery

Near line 449 
change
                 /sbin/ifconfig $i auto-revarp >/tmp/dev.$$ 2>&1
to 
                 #/sbin/ifconfig $i auto-revarp >/tmp/dev.$$ 2>&1
                 /sbin/ifconfig $i plumb >/tmp/dev.$$ 2>&1

Around line 680 change

#
# Start the twirling dial
#
if [ -x /sbin/dial ]; then
       /sbin/dial &
       dial_pid=$!
fi

to

# Start the twirling dial
#
#if [ -x /sbin/dial ]; then
#       /sbin/dial &
#       dial_pid=$!
#fi

if [ -x /sbin/dial ]; then
  # Note:  uses /.tmp_proto instead of /tmp since /tmp 
  # isn’t created until a few lines from here
  if [ -f /.tmp_proto/uberjs/disable_dial  -a $SINGLE_USER != ‘1’  ]; then
    echo “Dial disabled”
  else
    dial &
    dial_pid=$!
  fi
fi

Near line 794 change
                text)
                        install_menu=text
                        cat < /dev/null > /tmp/.text_install
                        shift
                        ;;
                dhcp)
                        TRY_DHCP=”yes”
                        shift
                        ;;

to

                text)
                        install_menu=text
                        cat < /dev/null > /tmp/.text_install
                        shift
                        ;;
                -s|s)
                        SINGLE_USER=1
                        shift
                        ;;
                dhcp)
                        TRY_DHCP=”yes”
                        shift
                        ;;

around line 889 change 

        # restart the twirling dial
        #
        if [ -x /sbin/dial ]; then
                /sbin/dial &
                dial_pid=$!
        fi

to

        # restart the twirling dial
        #
        #if [ -x /sbin/dial ]; then
        #       /sbin/dial &
        #       dial_pid=$!
        #fi
        if [ -x /sbin/dial ]; then
          # Note:  uses /.tmp_proto instead of /tmp since /tmp
          # isn’t created until a few lines from here
          if [ -f /.tmp_proto/uberjs/disable_dial  -a $SINGLE_USER != ‘1’  ]; then
            echo “Dial disabled”
          else
            dial &
            dial_pid=$!
          fi
        fi

and around line 1060 change

if [ “X${_INIT_NET_STRATEGY}” = “Xmanual” ] ; then
        echo “Network interface was configured manually.”
        manual_find_and_mount_cdrom

to

if [ -f /tmp/uberjs/uberjs-exec  -a $SINGLE_USER != ‘1’  ]; then
    echo “Executing UberJS script: /tmp/uberjs/uberjs-exec”
    /sbin/sh /tmp/uberjs/uberjs-exec
elif [ “X${_INIT_NET_STRATEGY}” = “Xmanual” ] ; then
        echo “Network interface was configured manually.”
        manual_find_and_mount_cdrom

 

10. Now edit sysidfind

around line 416, right after the call to property_sysid_config but before the if statement to floppy
change

            property_sysid_config
                

            if [ $? -ne 0 ]; then
                floppy_sysid_config
            fi

to

            property_sysid_config

            if [ $? -ne 0 ]; then
                if [ -f /etc/sysidcfg ]; then
                        echo “Using sysidcfg already in /etc (or possibly a link from /tmp/uberjs)”
                        return 0
                fi
            fi 

            if [ $? -ne 0 ]; then
                floppy_sysid_config
            fi

11. Set up DNS Resolution
Create a resolv.conf and update nsswitch.conf files for DNS Resolution
cd /custom_iso/miniroot/.tmp_proto/root/etc

cat resolv.conf
domain testdomain.com
nameserver 192.168.2.27
nameserver 192.168.2.28
search testdomain.com

Update nsswitch
perl -pi -e ‘s/hosts:      files/hosts:      files dns/’ nsswitch.conf 

On my miniroot the following had to be fixed
cd /custom_iso/miniroot/etc
test -s resolv.conf || ln -s ../tmp/root/etc/resolv.conf resolve.conf

12. Install extra packages on miniroot (ignore package dependencies)

Install bash
yes | pkgadd -R /custom_iso/miniroot -d /mnt/Solaris_10/Product SUNWbash
test -d /custom_iso/miniroot_x64/usr && yes |pkgadd -R /custom_iso/miniroot_x86 -d /mnt/Solaris_10/Product SUNWbash

Install ssh
yes |pkgadd -R /custom_iso/miniroot -d /mnt/Solaris_10/Product SUNWsshr SUNWsshcu SUNWsshu SUNWcry
test -d /custom_iso/miniroot_x64/usr && yes |pkgadd -R /custom_iso/miniroot_x86 -d /mnt/Solaris_10/Product SUNWsshr SUNWsshcu SUNWsshu SUNWcry

Install less and wget w/ssl
yes | pkgadd -R /custom_iso/miniroot -d /mnt/Solaris_10/Product SUNWopenssl-libraries SUNWwgetr SUNWwgetu SUNWless
test -d /custom_iso/miniroot_x64/usr && yes |pkgadd -R /custom_iso/miniroot_x86 -d /mnt/Solaris_10/Product SUNWwgetr SUNWwgetu SUNWless
ln -s ../sfw/bin/wget /custom_iso/miniroot/usr/bin/wget 
test -d /custom_iso/miniroot_x64/usr && ln -s ../sfw/bin/wget /custom_iso/miniroot_x64/usr/bin/wget 

12. Copy updated files to x64 miniroot (X86 only)
cp -rp /custom_iso/miniroot/.tmp_proto/uberjs /custom_iso/miniroot_x64/.tmp_proto
cp -p /custom_iso/miniroot/.tmp_proto/root/etc/resolv.conf /custom_iso/miniroot_x64/.tmp_proto/root/etc
cp -p /custom_iso/miniroot/.tmp_proto/root/etc/nsswitch.conf /custom_iso/miniroot_x64/.tmp_proto/root/etc
cp /custom_iso/miniroot/sbin/install-discovery /custom_iso/miniroot_x64/sbin
cp /custom_iso/miniroot/sbin/sysidfind /custom_iso/miniroot_x64/sbin
ln -s ../sfw/bin/wget /custom_iso/miniroot/usr/bin/wget 


13. Pack miniroot’s
13a. Sparc
 cd /custom_iso 
 /boot/solaris/bin/root_archive pack `pwd`/dvd/boot/sparc.miniroot `pwd`/miniroot
13b. x86
cd /custom_iso 
/boot/solaris/bin/root_archive pack `pwd`/dvd/boot/x86.miniroot `pwd`/miniroot
/boot/solaris/bin/root_archive pack `pwd`/dvd/boot/amd64/x86.miniroot `pwd`/miniroot_x64

14. Create GRUB menu (x86 ONLY!)
This grub setup is configured to boot from the first HDD after 60 sec.

cd dvd/boot/grub
vi menu.lst (can download http://dl.dropbox.com/u/2529674/menu.lst)
default=0
timeout=60
min_mem64 1024
title Default
        root (hd0,0)
        chainloader +1
        makeactive
title Solaris (local media) – Jumpstart
  kernel /boot/multiboot  kernel/$ISADIR/unix – install w
  module /boot/$ISADIR/x86.miniroot
title Solaris (local media) – Jumpstart Serial Console ttya
kernel /boot/multiboot  kernel/$ISADIR/unix -B console=ttya – install w
module /boot/$ISADIR/x86.miniroot
title Solaris (Single user)
  kernel /boot/multiboot  kernel/$ISADIR/unix -s
  module /boot/$ISADIR/x86.miniroot
title Solaris
        kernel /boot/multiboot  kernel/$ISADIR/unix -B install_media=cdrom
        module /boot/$ISADIR/x86.miniroot
title Solaris Serial Console ttya
        kernel /boot/multiboot  kernel/$ISADIR/unix -B install_media=cdrom,console=ttya
        module /boot/$ISADIR/x86.miniroot

14. dvd/ directory
The dvd directory contains much of the contents of the installation dvd and will also be available on this disk, you now have the option to add more utilities to it. For my systems, I added the sysfwdownload utilities to add in firmware updates.

15. Create ISO Image
15a. SPARC
cd /custom_iso
mkisofs -N -r -d -D -l -J -V SOL-10-JS -allow-leading-dots -G `pwd`/dvd/boot/hsfs.bootblock -B … -o sol10u9_sparc_`date ‘+%m%d%y_%H%M’`.iso dvd
15b. X86
cd /custom_iso
mkisofs -eltorito-boot boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -r -ldots -disable-deep-relocation -full-iso9660-filenames -relaxed-filenames -omit-period -omit-version-number -o sol10u9_x86_`date ‘+%m%d%y_%H%M’`.iso dvd

Complete!

3 responses to “uberjs

  1. Pingback: Uberjs on Solaris 10 « rageek

  2. T.j. Yang October 5, 2011 at 9:50 pm

    I had concern about UberJS since I was only able to get it to work on solaris 9 and below. Thanks a lot for publishing your enhancement to get Uberjs work with Solaris 10.

  3. T.j. Yang October 5, 2011 at 9:56 pm

    Thanks for publishing your work on getting Uberjs to work with Solaris 10.

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

%d bloggers like this: