Burning a bootable CDRom for Solaris

CURRENT UPDATE:

Issues and methods stated in this article are outdated. Reading it may still help understand the problems.
You might want to check out the PDF from Sun Blueprints for a much easier way of doing things these days.
http://www.sun.com/software/solutions/blueprints/0301/BuildBoot.pdf

Preface:

I have been trying to customize a Solaris install CDROM to my own needs. After several searches without any usable results, I ran into some really good explanations on this topic on the SunManagers Mailinglist Archive.

The work of Victoria Lau (vlau@msmail2.hac.com) 'Log file to customize the Solaris 2.5 boot cdrom' and a paper of James Hutchinson (lsharp@taz.hutch.org) 'Summary: How to build a Solaris bootable CDROM' helped alot, but these documents are Solaris 2.5 specific. Sun changed the CD-Layout from 2.5 to 2.6 :=)

In this document, I will explain how the Sun boots off the CDROM and how this CDROM could be customized to fit someones needs. This paper refers to the Solaris 2.6 HW 5/98 CDROM. The new Solaris 2.7 CDROM seems to share the same layout.

This document is structured in several sections:

1. Introduction to the Sun CDROM layout

2. How is the machine booting off the CDROM and where does the installation begin.

3. Altering the CDROM
3.1 The VTOC explained
3.2 Two possible methods for changing the CD

4. Testing your future, bootable CDROM

5. Scripts and other goodies

6. Comments from Readers

 

Last, why am I doing this? I would like to be able to install a standalone system without human interaction. For example for a firewall, my clients should be able to buy the recommended hardware (Sun Ultra10 with additional Ethernet port) , shove in my customized CD, plug in the LAN and WAN, type boot cdrom. No more, No less! The installation includes Operating System with Patches, Eagle Firewall with Patches and configuration, and a couple of custom scripts, which lets me administrate the system.

Please send me your comments, suggestions etc. You can reach me at lkarrer@trash.net

Good luck in burning your own bootable CD's

Lukas Karrer

 

1. Introduction to the Sun CDROM layout

There are 5 slices on the CDROM.

The exact layout can be found in the VTOC of the CDROM:

# prtvtoc /dev/dsk/c0t6d0s2

Attention: This command can only be issued when vold is not running! Eject the CDROM, kill vold, reinsert the CDROM!

 

2. Booting off the CDROM and starting the installation

When issuing the boot cdrom command from the boot promt the system loads its specific bootblock and gets redirected to slice 1 to start loading the kernel. The system comes up into Single User Mode.
Since there is only a minimal /usr on slice 1, the OS mounts a full /usr from slice 0 over the previous minimal /usr.
This can be found in /cdrom/cdrom1/s0/Solaris_2.6/Tools/Boot/usr

The system comes up and starts the shell script /sbin/suninstal. Suninstall does:

  1. Mount the path to the JumpStart directory (profind)
  2. Validate the contents of the JumpStart directory (chkprobe)
  3. Set the application type (jumpstart or interactive)
  4. JumpStart (Custom or Factory) begin script
  5. Save the JumpStart environment variables
  6. Mount the path to the SolStart directory
  7. Validate the contents of the SolStart directory (chkprobe)
  8. SolStart (SunSoft and OEM) begin script
  9. Save the SolStart environment variables
  10. Restore the JumpStart environment variables
  11. Interactive install (installtool/ttinstall)
    or
    JumpStart (Custom or Factory) profile install (pfinstall/pfupgrade)
  12. Restore the SolStart environment variables
  13. SolStart (SunSoft and OEM) finish script
  14. Restore the JumpStart environment variables
  15. JumpStart (Custom or Factory) finish script
  16. Cleanup

As I understand, there is no difference in doing a JumpStart installation over the net or doing the installation from CD.

 

3. Altering the CDROM

So far you might ask yourself, what are the difficulties in burning a custom CD.

The problem lies in the VTOC! When booting off CDROM, the boot prom checks the VTOC. This is the 'Table of Contents' which is located in the first cylinder (512 Bytes) of slice 0. The partition map of the CDROM is specified in the VTOC together with a checksum. Whenever changing the partition layout, the Sun system WILL NOT BOOT OFF THIS CDROM ANYMORE. So far I do not know of any tool to create a new VTOC. Hints for this are very welcome.

A second problem is the ufs format. Slice 1 to 5 MUST be in ufs format. The ufs format is bound to the disk geometry which is different on CD and your harddrive.

 

3.1 The VTOC

At first we look at the layout of the CDROM. Remember: To print the VTOC, vold MUST NOT be running and the CDROM MUST be unmounted!

# prtvtoc /dev/dsk/c0t6d0s2
* /dev/dsk/c0t6d0s2 partition map
*
* Dimensions:
* 512 bytes/sector
* 640 sectors/track
* 1 tracks/cylinder
* 640 sectors/cylinder
* 2048 cylinders
* 2048 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* Unallocated space:
* First Sector Last
* Sector Count Sector
* 1088000 3200 1091199
* 1100800 209920 1310719
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory 0 4 10 0 984960 984959
1 2 10 984960 103040 1087999
2 0 00 1088000 3200 1091199
3 0 00 1091200 3200 1094399
4 0 00 1094400 3200 1097599
5 0 00 1097600 3200 1100799
#

The size of the partitions can be calculated by multiplying the Count field by 512 eg:

Slice 0: 984960 sectors * 512 bytes / sector = 504299520 Bytes = 481 MB

WE ARE ABSOLUTELY BOUND TO THIS PARTITION MAP! The 110MB of unallocated space CANNOT be used.

Whatever we change, WE MUST STAY IN THE VTOC SPECIFIED RANGE

 

3.2. Possible Changes

I have two suggestions how to customize the CD. First, a simple and dirty one, mentioned in the 'Summary: How to build a Solaris bootable CDROM' then a more elaborate one.

3.2.1 A simple, but dirty possibility

Note: Most of this text is copied from the mentioned document. I only changed the procedure accomodated for the 2.6 changes and provided some deeper explanations to the needed steps.

  1. Create a new fs on a partition with ample space. You should reserve at least 1GB for the following steps!

  2. Use dd to grab the first cylinder off the solaris boot cdrom. This
    contains a valid disk label and VTOC for the cdrom. Once this is created
    our limitation is that we must work within the definitions of this VTOC.

    dd if=/dev/dsk/c0t6d0s0 of=cdrom.vtoc bs=512 count=1

  3. Now use dd to grab the UFS slices from 1 to 5

    for slice in 1 2 3 4 5
    do
    dd if=/dev/dsk/c0t6d0s${slice} of=cdrom.s${slice}
    done

  4. Mount slice 0 of the CDROM and copy everything to the staging area.
    Use GNUtar to copy the files, since there are some special-files
    (named Pipes, special files etc.) which won't get right with cp or the original tar!
    Trimm out the parts you don't need.

    NOTE: You NEED EVERYTHING IN /cdrom/cdrom1/s0/Solaris_2.6/Tools/Boot/usr
    DO NOT change this path!

  5. Add in all the things you need for your CD. The space is pretty small. If you delete everything but the /usr part, you will gain about 300 MB. -> This is the maximum size that you can use for your files.
    For me this meant a shell script that automated the build process, and images of all the data
    I wanted to move out. Make sure you do not go beyond the size of the slice
    0 on the CDROM you started with. (Check with the info prtvtoc shows.)

  6. Using mkisofs or the tools that came with your CDROM burning package
    (HyCD worked well, as well as Gear) turn your staging area into a hsfs
    filesystem image, making sure that symbolic links are unmodified. HyCD
    required changing a default option that would have modified all the links.

  7. (Possibility one): Patch the slice 1 image (CDROM s1) to start your custom application
    rather than the suninstall. This can be done by finding the break point
    you wish to use in the file cdrom:/sbin/sysconfig, selecting a unique set
    of chars in this file ( I used the string #***** S30sysid.net ) and then
    searching via a hex-editor or emacs in bin mode for that string. Then find
    a comment line, change the first # and chars after to point to your
    script, then add a # line after. For examle I patched my image so the line

    #***** S30sysid.net

    became

    exec build #ysid.net

    Then Input a script in my staging area into the /usr/bin dir. (the staging
    area will be made into slice 0 which is hsfs)

  8. Using dd, throw away the first block of this image.

    dd if=image of=image.data bs=512 skip=1

  9. Get the exact block count of this image.

    dd if=image.data of=/dev/null bs=512

    (Possibility two): Instead of using a hex-editor on one image, there is a more elaborate way:
    Download the content of the CD to a new partition:
    dd if=/dev/dsk/c0t6d0s1 of=/dev/rdsk/c0t1d0s1 bs=512
    fsck /dev/rdsk/c0t1d0s1
    mount /dev/dsk/c0t1d0s1 /s1
    vi /s1/sbin/sysconfig
    sync; sync; sync; umount /s1 dd if=/dev/rdsk/c0t1d0s1 of=cdrom.s1 bs=512 count=5240

    5240 is the number of blocks which dd reported before
  10. Subtract the block count of image.data from the original block count of slice 0 from the Solaris CDROM.
    (This is the number which prtvtoc prints out)
    If dd from Step 9 reported 803040+0 records you should calculate:

    984960 - 803040 = 181920

  11. Subtract 1 from this number. (The 1 accounts for the 1 block where VTOC resides)

    181920 - 1 = 181919

  12. Feed this number into dd reading from /dev/zero to build a pad file.

    dd if=/dev/zero of=image.pad bs=512 count=181919

  13. Cat all of the image files together with the VTOC and the UFS slices.

    cat cdrom.vtoc > cd_image
    cat image.data >> cd_image
    cat image.pad >> cd_image
    cat cdrom.s1 >> cd_image
    ..
    cat cdrom.s5 >> cd_image

  14. Burn this image to the CDROM drive using cdrecord, HyCD, Gear. etc
    eg. cdrecord speed=4 dev=0,3,0 cd_image

Additional note: The pad file is needed in order to keep the starting block number of the slices aligned to the number stated in VTOC

 

3.2.2 A second, more elaborate procedure

Since the available size is limited to about 300 Megs, I have thought about other possibilities. Further I would like to install the OS off the virgin files provided on the CD. I do not want to use an image. Since I want no human interaction, the Sun HW should have two CDROM players. This costs additional 200$ but we have max convenience. Note: It could also be done with somebody changing CD's inbetween the installation process.

The main problem is changing the /sbin/suninstall file on the CDROM to accomodate my changes. This file lies on slice 1 of the CD. The changes are that severe that they cannot be made using a binary editor and changing a few lines in this file. I am still working on getting the whole procedure to run as I want to. Therefore the noted changes are ideas and NOT tested out yet!!!

change suninstall to load a config file off diskette, use this as config for pfinstall to install the machine.
reboot the machine
start application installation off second CDROM
reboot and finish up

The problem lies in changing the suninstall file. Here is what I did (Analog to the document from Victoria Lau):

  1. Create a partition of about 100MB.

  2. Create a second partition of about 700 MB, newfs this partition and mount it.

  3. follow steps 1 - 3 of 3.2.1
    We well need all the slices, so we might as well do the for statements from 0 to 5
    The image of the CDROM slices should now reside on the new partition.

  4. dd if=cdrom.s1 of=/dev/rdsk/c0t1d0s5 bs=8k
    c0t1d0s5 is the raw device of the 100Mb Partition we created before.
    Remember the number of blocks which dd reports

  5. fsck /dev/rdsk/c0t1d0s5

  6. mount /dev/dsk/c0t1d0s5 /mnt/instcdrom

  7. cd /mnt/instcdrom; df -k shows how much space we have left.

  8. change the files to use our custom installation procedure

  9. sync;sync;sync; umount /mnt/instcdrom

  10. mv cdrom.s1 cdrom.s1.orig

  11. dd if=/dev/rdsk/c0t1d0s5 of=cdrom.s1 count=5240
    5240 is the number of blocks which dd reported in step 4

  12. cat all the images in one file which you are able to burn. If you did not change anything in slice 0, the VTOC and PAD File are not needed.
    cat cdrom.s0 > cd_image
    cat cdrom.s1 >> cd_image
    ..
    cat cdrom.s5 >> cd_image

  13. Burn this image to the CDROM drive using cdrecord, HyCD, Gear. etc
    eg. cdrecord speed=4 dev=0,3,0 cd_image

 

4. Testing your CD

Catherine Baley Catherine.Baley@matranortel.com mentioned a neat possibility to test the CD before burning!

Copy the 6 partitions to a disk. (all the partitions can be ufs, even s0)
Then boot on this disk:

ok boot disk1:d 	(d sun4m)

 

5. Scripts and other goodies

Eric Negaard has put together some shell scripts, which help with the burning process.

Here you will find :

  • burnit which basically does the whole thing for you.
  • extractcd to extract data from an original Solaris CDRom.
  • sunfdisk.patch a Patch to the Linux fdisk program distributed with the util-linux package (version 2.9r) for creating a "sunfdisk" program that will compile and run on Solaris machines.
    The primary use has been to create/modify partition tables from bootable CD-ROMs. (the fdisk/sunfdisk program happily operates on regular files as well as devices).

     

    6. Comments from Readers

    Jan Stevens has some other ideas to reach the same goal.

    Daniel Solero mentions a tool CDTK which can recreate the slice map, vtoc, etc.

    Christoph Stevens submitted a totally different procedure ito burn bootable CD's This document describes how to create a bootable cd from an existing (running) machine.

    Mari Donkers describes a procedure to extend the partition table of a Solaris 2.6 hw 5/98 CD-ROM here

    Jürg Schilly, the developer of cdrecord notes:
    Paragraph 3 is wrong:

    1. mkisofs does support Sparc bootable CD's for about a year.
    2. UFS is not bound to the disk geometry. It only uses it as a hint. The FBK driver allows you to create any ufs image you like.

    "Out of boredom" Ignatios Souvatzis analyzed the format of bootable CDs a while ago
    Results can be found in the "mksunbootcd" program in NetBSD. See /usr/src/distrib/utils/mksunbootcd (accessible via http://cvsweb.netbsd.org/