Solaris, unlike some other Operating Systems, does not ship with a method for creating bootable recovery media. The following procedure is one that I've been able to devise after searching for more help on the matter.

In documenting this process, I will first show you how to create a bootable recovery disk. Once that is successful, I'll describe how to create a bootable CDROM.

Slice 1 — the driver for the recovery

The partition we are going to build is a bit large — 200MB. You could make it smaller by squeezing stuff out, but it is fine for our purposes since the recovery image is generally quite small (less than 100MB for the core install).

I did this with a SCSI disk attached to an UltraSPARC 5. Using format, I created two partitions, a 200MB slice 1 (c1t1d0s1) and a 450MB (c1t1d0s0, to emulate the room remaing on the CD) slice 0. After partitioning the disk with format and with the Solaris 8 Software CD (Disk 1 of 2, 2/02 edition) at c0t2d0, I went through the following steps:

  1. Create a filesystem on slice 1 of the partitioned disk:
        # newfs /dev/rdsk/c1t1d0s1
  2. Mount slice 1 of the disk:
        # mount /dev/dsk/c1t1d0s1 /mnt
  3. Mount slice 1 of the install CD:
        # mount -o ro /dev/dsk/c0t2d0s1 /cdrom
  4. Copy the contents of slice 1 on the CD to the disk:
        # cd /cdrom; tar cf - .tmp_proto . | (cd /mnt; tar xf -)
  5. Unmount the slice 1 of the CD and mount slice 0:
        # umount /cdrom; mount -F hsfs /dev/dsk/c0t2d0s0 /cdrom
  6. Copy the filesystem from Solaris*/Tools/Boot to slice 1 of the disk, taking care not to copy over openwindows:
        # cd /cdrom/Solaris*/Tools/Boot
        # tar cf - a bin a cdrom devices kernel mnt \
          platform reconfigure  tmp var bin dev etc lib opt    \
          proc sbin usr/bin usr/ccs usr/kernel usr/kvm usr/lib \
          usr/old usr/perl5 usr/platform usr/preserve usr/proc \
          usr/pub usr/sadm usr/sbin usr/share usr/snadm        \
          usr/spool usr/src usr/tmp usr/usr usr/xpg4 | (cd /mnt;
          tar xf -)
    You probably don't have to copy all of that stuff, but the important thing is to avoid copying usr/dt and usr/openwin.
  7. Remove /mnt/etc/sysidcfg and replace it with a symlink to ../cdrom/sysidcfg:
        # rm /mnt/etc/sysidcfg
        # ln -s ../cdrom/sysidcfg /mnt/etc/sysidcfg
  8. (This step can be done by applying this patch.) Patch /mnt/sbin/rcS so that it will look at the CD for boot information rather than trying to get the information from the network. To do this, replace these lines:
    if [ $USING_DHCP -eq 1 ] ; then
    	echo "Using DHCP for network configuration information."
    	echo "Using RPC Bootparams for network configuration information."
    with these:
    if [ ! -f /cdrom/sysidcfg ]; then
      mount -F hsfs $cdrom /cdrom
      if [ ! -f /cdrom/sysidcfg ]; then
        echo Rescue CD
        if [ ! -z "${dial_pid}" ]; then
            kill $dial_pid >/dev/null 2>&1

    Note: we have "CdRoMmOuNtPoInTgOeShErE" intead of an actual mount point. This is so that we can replace the string later when it is embedded in a binary. If you are testing this with a disk before you burn a CD, you should put your slice 0 mount point in place of this string. Also, note that if the script doesn't find a sysidcfg file, it will run bash (which you will need to copy over with the libraries it needs seperately) and then reboot. This means that if you have a CD with just this slice 1 and no slice 0, you can use the CD as a rescue disk.

    Also, you will need to change /mnt/sbin/suninstall to add the line touch ${PREINSTALL} just before the following statements:

    if [ -f ${PREINSTALL} -o -f ${INSTALLBOOT} ]; then
            if [ -f ${JSLOCKFILE} ]; then
                    gettext "You must reboot the system to restart a JumpStart install."

  9. Install the boot block onto slice 1:
        # installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk

Slice 1 is now bootable and will launch into jumpstart if /cdrom contains the Jumpstart setup. We will exploit this and the new (in later versions of Solaris 8) Flash installation to create a CD that can recover the core OS with all the configuration intact.

Creating a flash archive

*** FIXME the script needs to ensure that root_password isn't blank.

Here is my mksysidcfg script. Using it takes a little preparation on your part. The script uses flarcreate from the Solaris 8 CDROM to create the Flash Archive. The script expects the file to be in /usr/sbin/flarcreate.

You should create a file named /etc/flar_exclude listing everything on the rootdisk that you don't want in the archive. For example, on our virus scanner, I have the following in /etc/flar_create:


/home/mah/cdrom is where I put the build images. I exclude that because I don't want the build image to contain a copy of itself. In cases where you want the directory, but not the files in the directory, you need to put the pathname with a trailing / as I did in this file. Also, it is a good idea to not copy over log files. Note that I've avoided the log files in the /var/iscan/ directory with /var/iscan/log. and I have just the top of the /var/log and /var/adm path. The logfiles there are touched in a postinstall script.

Mount the 450Mb partition and then run:

    # ./mksysidcfg -b -f /,/var,/usr -m /mnt

When running the script, you may get errors like

    WARNING: computehash not found; cannot generate checksums
    cpio: Error with lstat() of "", errno 2, No such file or directory
which you may safely ignore.

The above command creates a directory, /mnt/cdrom containing a jumpstart setup ready to do a Flash install of the machine you just ran it on. The contents of this directory need to be mounted as /cdrom when slice 1 (created above) boots up. This means that you probably need to move the contents of the subdirectory to the root of the disk.

In this case, I've mounted my disk at /mnt, so to have the disk set up properly, I run:

    # mv /mnt/cdrom/.install_config /mnt/cdrom/* /mnt
    # rmdir /mnt/cdrom

Now, to boot from the slice 1 on the disk, it is very handy to use devalias in the boot prom. My scsi disk is set up as c1t1d0 on a UltraSPARC 5, so the devalias command is:

    ok devalias scsi /pci@1f,0/pci@1/pci@1/SUNW,isptwo@4/sd@1,0
With this alias, I can boot off of the prepped slice (b) using
    ok boot scsi:b
(scsi:b here translates to /pci@1f,0/pci@1/pci@1/SUNW,isptwo@4/sd@1,0:b)

Assuming you've set the cdrom variable in the rcS script correctly, you should see it coming up, rebuilding the system from the flash archive, and rebooting as the restored system.

Creating the CD

The first step to building the recovery CD is to capture slice 1. Sun hardware looks at slice 1 on the CD to boot (that's a gloss-over — it looks at a different slice depending on the architecture, but, for our purposes, it looks at slice 1). This slice contains a complete UFS partition for booting.

In the previous steps, we created a bootable recovery disk; now we will use the slice 1 image to burn CDs for multiple machines.

  1. Copy the slice 1 image to a file:
        # dd if=/dev/rdsk/c1t1d0s1 of=s1.img
    Make sure that your sbin/rcS script has the string "cdrom=CdRoMmOuNtPoInTgOeShErE" in it.

    This image file can be used for different machines of the same architecture, so keep it around. The only thing you need to do is replace the "cdrom=CdRoMmOuNtPoInTgOeShErE" bit with "cdrom=/dev/dsk/???". Make sure to use a string of the same length when editing a binary file. Pad with spaces if you must.

  2. Determine the proper /dev/dsk file for the cdrom. Substitute this for the magic string in the s1.img file above:
        # sed 's/cdrom=CdRoMmOuNtPoInTgOeShErE/cdrom=\/dev\/dsk\/c0t2d0s0/' < s1.img > host.img
  3. Using the JumpStart image mksysidcfg created, the slice 1 image modified in the previous step, and a recent copy of mkisofs (the version of mkisofs available with Solaris 8 won't work), make an ISO image to burn to CD:
        # mkisofs -B host.img,... -o host.iso cdrom
    The above command assumes that you are sitting in the parent directory of the cdrom subdirectory that mksysidcfg created.
  4. Burn the ISO image to disk:
        # cdrecord dev=1,1 host.iso

    That's It!

    If you find this procedure useful, please email me and let me know.


    Building a Bootable JumpStart Installation CD-ROM