Cover V12, I05

Article

may2003.tar

Putting a Flash Archive on a Bootable CD

Liz Frank

In my ten years as a systems administrator, I have cloned many systems, including Suns, and in my experience it is best done over a network with JumpStart or as a disk-to-disk dump with a bootblock installation. Most recently, however, management asked me to build a SolarisTM installation CD to clone our Suns. In addition to duplicating systems, I also needed to satisfy the following criteria:

1. Loading the operating system must be no different than a standard Solaris installation. Although competent systems administrators, the staff building the clones cannot take time away from their regular duties to do a great deal of configuration or troubleshooting.

2. Due to capacity and reliability issues, the cloning must be done standalone. Some of our systems are offsite, and network connectivity is saturated and unreliable.

3. The most critical requirement of the project is the ability to produce, on demand, a specific system configuration to demonstrate a particular version of code in order to satisfy an audit. The operating system must be available on long-term, compact media that can be easily stored and restored on the system.

Much to my surprise, management was right. We need a bootable Solaris CD to install a clone of a current system. Fortunately, Solaris provides the necessary tools: JumpStartTM to automate the installation process in client/server fashion, and Flash ArchiveTM to clone an existing system.

Sun also publishes the documentation to make use of these packages. JumpStart Technology: Effective Use in the Solaris Operating Environment by John S. Howard and Alex Noordergraaf, part of the Sun Blueprints series, provides excellent step-by-step instructions for constructing a Flash Archive and creating a bootable installation CD. However, they don't give detailed steps to put the two together. Because this is a process we want to repeat on a regular basis, and because I don't want guaranteed job security into the next lifetime, I have thoroughly documented this procedure, including a few pitfalls I encountered.

In this article, I will provide a set of instructions to build a Flash Archive of a system, replace the packages on an installation CD with the archive, create a new installation image, burn it to a bootable JumpStart CD, and install the archive from that CD to another system. In this case, I am using release 2/02 of Solaris 8, but the procedure should be the same for any version.

System Preparation

Because JumpStart requires the archive to fit on a single CD, it may be necessary to slim down the operating system. I stripped out unnecessary packages, such as foreign language fonts and unused device drivers, to reduce the disk usage to less than a gigabyte. When compressed, the archive will occupy considerably less than the 640 MB available on a CD. This limitation should cease to be an issue as DVD burners become more readily available.

Build the Flash Archive

The Flash Archive is constructed with the flarcreate command:

# flarcreate -n "Master System Flash Archive" -R / -c \
# -x /tmp /tmp/system.flar
where -n specifies the name given to the archive internally, -R / instructs the command to begin the archive from the root directory, and -c says to compress the resulting archive. The -x option excludes the named file or directory, in this case /tmp and /tmp/system.flar is the Flash Archive that will be created.

Pitfall #1

Although the man page implies otherwise, only the first -x option takes effect. Since I want to exclude the contents of /tmp as well as the archive (to prevent recursion), I put the archive in /tmp then exclude it. I then unmount user data and NFS partitions to prevent their inclusion. This may require bringing the system into single-user mode, in which case the archive will have to be moved from /tmp to a location that won't be cleared on reboot.

Extract the Boot CD Contents

To re-create a boot CD, it is necessary to know its layout. This information is available in the Virtual Table of Contents (VTOC) in the first block of slice 0 on the Operating Environment (OE) CD and is read via the prtvtoc command.

The volume manager must be stopped before the command is issued:

# /etc/init.d/volmgt stop
Insert the Solaris OE CD (labeled Software 1/2, version 8-2/02) and issue the prtvtoc command for the CDROM:

# prtvtoc /dev/rdsk/c0t1d0s0
to produce the following output:

* /dev/rdsk/c0t1d0s0 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
*     1268480      2560   1271039
*     1278720     32000   1310719
*
*                         First    Sector  Last
* Partition  Tag  Flags  Sector    Count   Sector  Mount Directory
       0      4    10         0  1056640   1056639
       1      2    10   1056640   211840   1268479
       2      0    00   1268480     2560   1271039
       3      0    00   1271040     2560   1273599
       4      0    00   1273600     2560   1276159
       5      0    00   1276160     2560   1278719
The final image burned to the CD must have the same number of sectors as slice 0, 1056640 in this case.

Eject the CD and restart the volume manager:

# /etc/init.d/volmgt start
The process requires enough disk space to store the contents of the CD while it is modified and the newly created image that will be burned to CD.

In this example, I use /export/tmp. The Solaris packages and system installation instructions are located in slice 0 of the CD. The packages will be replaced by the Flash Archive and the contents of files in s0/.install_config will be modified to do the install. Because it will be rebuilt, the first slice must be copied out with cpio:

# mkdir /export/tmp/s0
# cd /cdrom/cdrom0/s0
# find . -print | cpio -dpm /export/tmp/s0
The other sectors won't be manipulated in the same way, thus they can be copied out with dd.

Stop the volume manager again:

# /etc/init.d/volmgt stop
Now dump each slice to a file:

# foreach n (1 2 3 4 5)
    dd if=/dev/dsk/c0t1d0s$n of=/export/tmp/sol8.s$n bs=512
  end
We will also need the volume table of contents (VTOC) from the first cylinder of the first slice on the CD:

# dd if=/dev/dsk/c0t1d0s0 of=sol8.cdrom.vtoc bs=512 count=1
Restart the volume manager:

# /etc/init.d/volmgt start
Modify the Boot CD Contents

To replace the Solaris packages usually installed from the CD with the Flash Archive, remove the files and directories in s0/Solaris_8/Product and copy system.flar to the directory in their place:

# cd /export/tmp/s0/Solaris_8
# rm -rf Product/*
# cp /tmp/system.flar Product/system.flar
Several files direct the installation process and must be built or modified.

Five of these files: rules, rules.ok, install_begin, install_finish, and profile, reside in the /export/tmp/s0/.install_config directory. The rules file provides the installation process with the names of the "profile", "begin", and "end" scripts.

I use a very basic rules file:

# cat rules
    any - install_begin Sol8.profile install_finish
Each entry in the file specifies a keyword and value pair followed by the names of the "begin", "profile", and "end" scripts. According to the rule above, "any" system with any value is to use the install_begin script for pre-installation instructions, Sol8.profile for its configuration profile, and any post-installation tasks will be found in install_finish.

The profile script specifies the type of installation, the location of the archive, and the disk-partitioning scheme, among other things. In this case, the configuration profile requires "flash_install" for the install_type, and the archive_location is in reference to the s0 slice. The local_device refers to the usual CDROM device and the filesystem type is hsfs. A sample file is shown below:

# cat Sol8.profile
     install_type    flash_install
     archive_location     local_device   \
              /dev/dsk/c0t1d0s0 /Solaris_8/Product/system.flar \
              hsfs
     partitioning explicit
     filesys c0t0d0s1 0:839 swap
     filesys c0t0d0s0 free /
     filesys c0t1d0s0 free /user_data
Making the partitioning "existing" rather than "explicit", the drive will be used in its current format.

Because I don't want to format each new system's drives before every installation, I specify 839 cylinders for swap on slice 1 of the first drive, the remainder of the disk for the operating system, and user data on the entire second disk.

The install_begin script provided in s0/Solaris_8/Tools/Boot/usr/sbin/install.d/install_config works with no modifications:

# cat s0/Solaris_8/Tools/Boot/usr/sbin/install.d/install_config/\
     install_begin:
 
#!/sbin/sh

# Local Variables
#
STATUS=0
OK=0

# This may be used in the future for interface version checking 
# between the elements of this mechanism.
INTERFACE_VERSION=1.0


PROGNAME='basename $0'

#echo 'gettext "Executing script '${PROGNAME}'..."'
#echo

#echo 'gettext "Script '${PROGNAME}' execution completed."'
#echo

exit ${STATUS}
I simply copy it to its proper location:

# cp s0/Solaris_8/Tools/Boot/usr/sbin/install.d/install_config/\
     install_begin s0/.install_config/install_begin
The install_finish script isn't necessary, but I choose to clean up the tmp directories and logs like so:

#!/bin/sh

for i in /a/var/adm/messages* /a/var/adm/utmpx /a/var/adm/wtmpx \
                      /a/var/adm/lastlog
do
              cp /dev/null ${i}
done

mkdir /a/var/tmp
chown root:sys /a/var/tmp
chmod 1777 /a/var/tmp
Pitfall #2

Files manipulated by this script must be referenced from the /a directory where the file system is mounted at this point. For example, changes to the /etc/hosts file must be made to /a/etc/hosts.

Generate a rules.ok File

With the three scripts in place, a rules.ok file must be generated from the rules file using a check script found in s0/Solaris_8/Misc/jumpstart_sample. Run check from the s0/.install_config directory:

# cd /export/tmp/s0/.install_config
# /export/tmp/s0/Solaris_8/Misc/jumpstart_sample/check
This simply checks for the named files and replicates the rules file with version and checksum information:

# cat rules.ok
     any     -       install_begin   Profile install_finish
     # version=2 checksum=4006
The profind script controls the setup of the installation profile directory and must be modified to use the CDROM for JumpStart. The script found in /export/tmp/s0/Solaris_8/Tools/Boot/usr/sbin/install.d requires four additional lines of code added to the cdrom() function as shown below:

 cdrom()
 {
 # Factory JumpStart is only allowed with factory
 # stub images, indicated by the file /tmp/.preinstall
 #
 if [ -f /tmp/.preinstall ]; then
     mount -o ro -F lofs ${CD_CONFIG_DIR} ${SI_CONFIG_DIR} >/dev/null 2>&1

     if [ $? -eq 0 ]; then
         verify_config "defaults" "CDROM"
     fi
 fi
 gettext " <<< using CD default >>>"; echo       # Added code
 rmdir ${SI_CONFIG_DIR}                          # Added code
 ln -s /cdrom/.install_config ${SI_CONFIG_DIR}   # Added code
 exit 0                                          # Added code
 }
Finally, the sysidcfg file can further automate the installation process by providing responses to the install programs' queries for network, timezone, password, and other information. My sysidcfg is a text file in /tmp with the following information:

system_locale=en_US
timezone=MST7MDT
network_interface=primary {netmask=255.255.255.0
                          protocol_ipv6=no}
name_service=NONE
Because this file resides in slice 1, it must be modified via the Solaris 8 OE loopback file driver administration commands (lofiadm), which mounts sol8.s1 as a filesystem:

# lofiadm -a /export/tmp/sol8.s1 /dev/lofi/1
Mount the resulting device to a temporary location:

# mount /dev/lofi/1 /mnt
Remove /mnt/etc/sysidcfg (which is a symlink) and replace it with the desired sysidcfg, unmount, and release the device:

# rm /mnt/etc/sysidcfg
# cp /tmp/sysidcfg /mnt/etc/sysidcfg
# umount /mnt
# lofiadm -d /dev/lofi/1
Pitfall #3

The sysidcfg doesn't perform exactly as advertised for me. The information required before the startup of OpenWindows is taken from the sysidcfg, but the OpenWindows install prompts for other items using the sysidcfg values as defaults. Complete descriptions of these files and their options can be found in JumpStart Technology.

Build the Image and Burn It to CD

At this point, I create the CD image from the slices in /export/tmp. These instructions are taken from Chapter 9 of JumpStart Technology: Effective Use in the Solaris Operating Environment. To begin, create an HSFS filesystem from s0:

# mkisofs -R -d -L -l -o sol8.s0 s0

         *****  lots of output may appear here *****
The options to mkisofs are detailed in the man page. The resulting file, sol8.s0, is an ISO image with a VTOC (volume table of contents), which must be replaced with the one extracted from the OE CD. Use dd to create a new image without the VTOC by skipping the first block:

# dd if=sol8.s0 of=new.sol8.s0 bs=512 skip=1
This produces output similar to the following:

     960655+0 records in
     960655+0 records out
Pad slice 0 to match the size specified by the VTOC. The final size is specified in the prtvtoc output, 1056640 sectors in this case. The size of the pad is that value (1056640) minus the size of sol8.s0 created above plus one to allow for the position of the VTOC:

# bc
     1056640 - (960655 + 1)
     95984
Create a pad of zeros:

# dd if=/dev/zero of=pad.s0 bs=512 count=95984
It's time to concatenate all the slices into one image. The OE CD VTOC is the first information to go into the image, followed by the first slice, followed by the zero pad to extend it to the proper length. The remaining slices are attached sequentially:

# cat sol8.cdrom.vtoc new.sol8.s0 pad.s0 sol8.s1 sol8.s2 sol8.s3 \
     sol8.s4 sol8.s5 > image
Finally, burn the image to CD:

# cdrw -i image
Boot and Install from the JumpStart CD

To boot and install from the CD, the install option must be supplied and the CDROM device must be defined at the boot prompt:

ok> boot cdrom - install cdrom=/dev/dsk/c0t1d0s0
The installation will start OpenWindows and then prompt for any information not provided in the sysidcfg and profile files before extracting from the Flash Archive.

Pitfall #4

The OpenBoot PROM must have the correct settings to make this work. If the system has been configured to do a Web-based JumpStart and the diag-device environment variable is set to "net", reset it to the correct disk:

ok> setenv diag-device disk:a
Pitfall #5

Third-party hardware or software can cause problems if the cloned system is not configured exactly like the master.

Conclusion

There are drawbacks to the JumpStart CD method of cloning. Besides the operating system size limit imposed by CD capacity, even minor changes to the system require a complete rebuild of the master CD. However, it may provide a more efficient and convenient mechanism for building multiple standalone systems as well as a means of storing and restoring a system configuration.

Acknowledgements

In addition to writing an excellent resource, John Howard provided much appreciated guidance in this endeavor. I also thank management for providing the challenge.

Liz Frank has a B.S. in Biomedical Engineering and a M.S. in Electrical Engineering from the University of New Mexico. She has been a UNIX systems administrator for more than 10 years and has worked on a variety of platforms, although Suns are currently her favorite. Liz can be contacted at: lfrank@swcp.com.