Which files are in the boot_archive?


Which files are in the boot_archive?

by Bernd Schemmer, Last Update: November 2009

Homepage: http://www.bnsmb.de/

Table of contents

Purpose

Sometimes one need to know which files are in the boot_archive used for booting Solaris (or OpenSolaris).

You can list the files in the boot_archive using bootadm, e.g.

bash-3.2#  bootadm list-archive
etc/rtc_config
etc/system
etc/name_to_major
etc/driver_aliases
etc/name_to_sysnum
etc/dacf.conf
etc/driver_classes
etc/path_to_inst
etc/mach
etc/devices/devid_cache
etc/devices/retire_store
etc/devices/mdi_scsi_vhci_cache
etc/devices/mdi_ib_cache
etc/cluster/nodeid
kernel
platform/i86pc/biosint
platform/i86pc/kernel
platform/i86xpv/kernel
platform/i86pc/ucode/GenuineIntel
platform/i86pc/ucode/AuthenticAMD
boot/solaris/bootenv.rc
boot/solaris/devicedb/master
boot/acpi/tables

But bootadm says nothing about the contents of the files in the boot_archive.

Implementation


To get around this limitation and to handle the various locations and file formats (plain, compressed) for the boot_archive in the different flavours of Solaris (OpenSolaris for SPARC, OpenSolaris for x86, Solaris 10 SPARC, Solaris 10 x86) I wrote a little script to mount the boot_archive. The script also handles the different filesystems for the boot_archive (hsfs or ufs).

The Script


#!/usr/bin/ksh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License").  You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Description:
#
#	Script to mount/umount the boot_archive
#
# Author:
#	Bernd Schemmer (Bernd.Schemmer@gmx.de)
#
# History
#
#	03.11.2008 /bs
#		inital release
#
#	03.12.2008/bs
#		- added support for boot_archive files compressed by
#		  gzip or bzip2
#		- the script now always works on a copy of
#		  the boot_archive (there's no need to umount the
#		  boot_archive before rebooting the server or updating
#		  the boot_archive manually anymore)
#
# Usage:
#
#	boot_archive {mount|umount|uninstall}
#
# Parameter
#	mount
#		- create a temporary copy of the boot_archive and mount it
#	umount
#		- umount the temporary copy of the boot archive but do
#                 not delete the copy of the boot_archive
#	uninstall
#		- umount the temporary copy and delete the copy
#
# Default action without a parameter is  "mount"
#
#
# Notes:
#
# Be aware, that the files in the boot_archive of some Solaris Releases
# are all gezipped, e.g. to view the files use something like:
#
# 	gzip -cd /tmp/boot_archive/etc/path_to_inst
#
# or
#
#  	gzcat /tmp/boot_archive/etc/path_to_inst
#
# To start the script with verbose messages use
#
#	VERBOSE=0 boot_archive {parameter_for_bootarchive}
#
# Tested on
#	OpenSolaris 2008.11 snv_98 X86
#	Solaris 10 10/08 s10x_u6wos_07b X86
#	Solaris Express Community Edition snv_89 SPARC
#	Solaris Express Community Edition snv_78 X86
#
# Supported platforms:	        x86, SPARC
# Supported file formats:	uncompressed, compressed with gzip, compressed with bzip2
# Supported filesystems:	hsfs, ufs

# --------------------------------------------------------------------------------
# init the variables of the script
#

# save the parameter
#
ACTION="$1"

# name of this script
#
BASENAME="$( basename $0 )"

# mount point to mount the temporary boot_archive
#
MOUNT_POINT="/tmp/boot_archive"

# this script can run on x86 and SPARC
#
ARCH="$( uname -m )"

case  ${ARCH} in
	sun4u | sun4us | sunv4 )
		BOOT_ARCHIVE="/platform/${ARCH}/boot_archive"
		;;

	i86pc | i86xpv )
		[ "$( isainfo -b  )"x = "32"x ]  && ISADIR="/" || ISADIR="/amd64/"
		BOOT_ARCHIVE="/platform/i86pc${ISADIR}boot_archive"
		;;

# unknown machine architecture
	* )
		BOOT_ARCHIVE=""
		;;
esac


# remove the temporary file at script end (0 = true; else not)
# (used to delete incomplete temporary copies of the boot_archive)
#
REMOVE_TEMPORARY_FILE=1


# --------------------------------------------------------------------------------
# sub routines

logMsg() {
	[ "${QUIET}"x  = ""x ] && echo "${BASENAME}: $*"
}

logInfo() {
	[ "${VERBOSE}"x != ""x ] && logMsg "$*" >&2
}


die() {
	THISRC=$1
	if [ $# -ne 0 ] ; then
		shift
		[ ${THISRC} -gt 1 ] && logMsg "ERROR: $* !" >&2 || logMsg "$*"
	fi

	if [ ${REMOVE_TEMPORARY_FILE} = 0 -a "${TMP_BOOT_ARCHIVE}"x != ""x -a -f "${TMP_BOOT_ARCHIVE}" ] ; then
		logInfo "Removing the temporary file \"${TMP_BOOT_ARCHIVE}\" "
		rm "${TMP_BOOT_ARCHIVE}"
	fi

	exit ${THISRC}
}


# --------------------------------------------------------------------------------
# main routine
#

# check the machine architecture
#
[  "${BOOT_ARCHIVE}"x = ""x  ] && \
	die 3 "Unknown machine architecture \"${ARCH}\" "


# exit if the boot_archive does not exist
#
[ ! -r "${BOOT_ARCHIVE}" ]  && \
	die 5 "The boot archive \"${BOOT_ARCHIVE}\" does not exist or is not readable!"

# check the type of the boot_archive
#
FILE_OUTPUT="$( file "${BOOT_ARCHIVE}" )" || \
	die 7 "Can not detect the type of the boot_archive file \"${BOOT_ARCHIVE}\" "

echo "${FILE_OUTPUT}" | grep  gzip >/dev/null
if [ $? -eq 0 ] ; then
	FILE_TYPE="gzip"
else
	echo "${FILE_OUTPUT}" | grep  bzip2 >/dev/null
	if [ $? -eq 0 ] ; then
		FILE_TYPE="bzip2"
	else
		FILE_TYPE="uncompressed"
	fi
fi

# file used as temporary copy of the boot archive
#
TMP_BOOT_ARCHIVE="/tmp/$( basename "${BOOT_ARCHIVE}").${FILE_TYPE}"

# print some verbose messgages if requested
#
logInfo "The temporary copy of the boot_archive is \"${TMP_BOOT_ARCHIVE}\" "
logInfo "The type of the boot_archive is \"${FILE_TYPE}\" "
logInfo "The mount point for the boot_archive is \"${MOUNT_POINT}\" "


# check if there is already a lofi device for the copy of the boot_archive
#
LOFI_DEV="$( lofiadm "${TMP_BOOT_ARCHIVE}" 2>/dev/null )"

# create the mount point
#
[ ! -d "${MOUNT_POINT}" ] && mkdir -p "${MOUNT_POINT}" \
	die 9 "Error $? creating the temporary mountpoint \"${MOUNT_POINT}\" "


case ${ACTION} in

	uninstall | umount | unmount )
		logMsg "Using the boot archive \"${BOOT_ARCHIVE}\" ..."

		if [ "${LOFI_DEV}"x != ""x ] ; then
			logInfo "Umounting \"${LOFI_DEV}\" ..."
			umount "${LOFI_DEV}" 2>/dev/null || \
				die 11 "Error $? umounting the boot_archive"

			logInfo "Removing the lofi device \"${LOFI_DEV}\" ..."
			lofiadm -d "${LOFI_DEV}" || \
				die 12 "Error $? removing the lofi device"

			logMsg "boot_archive umounted"
		else
			logMsg "The boot_archive is not mounted."
		fi

		if [  -f "${TMP_BOOT_ARCHIVE}" ] ; then
			if [ "${ACTION}"x = "uninstall"x ] ;  then
				logMsg "Deleting the temporary boot_archive ..."
				rm "${TMP_BOOT_ARCHIVE}" >/dev/null 2>/dev/null
			else
				logMsg "The temporary boot_archive is \"${TMP_BOOT_ARCHIVE}\" "
			fi
		fi
		;;

        mount | "" )
		logMsg "Using the boot archive \"${BOOT_ARCHIVE}\" ..."

# prepare the temporary copy of the boot_archive
		if [ "${LOFI_DEV}"x = ""x ] ; then
			if [ -f ${TMP_BOOT_ARCHIVE} ] ; then
				logMsg "Using the existing boot_archive copy \"${TMP_BOOT_ARCHIVE}\" "
			else
				REMOVE_TEMPORARY_FILE=0
				case  "${FILE_TYPE}" in
					"uncompressed" )
						logMsg "Copying \"${BOOT_ARCHIVE}\" to \"${TMP_BOOT_ARCHIVE}\" ... "
						cp "${BOOT_ARCHIVE}" "${TMP_BOOT_ARCHIVE}" || \
							die 13 "Error $? copying \"${BOOT_ARCHIVE}\" to \"${TMP_BOOT_ARCHIVE}\" "
					;;

					"gzip" )
						logMsg "Uncompressing \"${BOOT_ARCHIVE}\" to \"${TMP_BOOT_ARCHIVE}\" using gzip ... "
						gzip -cd "${BOOT_ARCHIVE}" >"${TMP_BOOT_ARCHIVE}" || \
							die 15 "Error $? uncompressing \"${BOOT_ARCHIVE}\" to \"${TMP_BOOT_ARCHIVE}\" "
					;;

					"bzip2" )
						logMsg "Uncompressing \"${BOOT_ARCHIVE}\" to \"${TMP_BOOT_ARCHIVE}\" using bzip2 ... "
						bzip2 -cd "${BOOT_ARCHIVE}" >"${TMP_BOOT_ARCHIVE}" || \
							die 17 "Error $? uncompressing \"${BOOT_ARCHIVE}\" to \"${TMP_BOOT_ARCHIVE}\" "
					;;
				esac
				REMOVE_TEMPORARY_FILE=1
			fi

# create the lofi device
			LOFI_DEV=$( lofiadm -a "${TMP_BOOT_ARCHIVE}" ) || \
				die 19 "Error $? creating the lofi device for the copy of the boot_archive"
		fi

# mount the lofi device
		MOUNT_MSG="$( mount | grep " ${LOFI_DEV} "  )"
		if [ $? != 0 ] ; then
			FSTYP=$( fstyp "${LOFI_DEV}" )
			[ "${FSTYP}"x = "hsfs"x ] && MSG="readonly (${FSTYP})]" ||  MSG="readwrite (${FSTYP})]"
			mount -F "${FSTYP}" "${LOFI_DEV}" "${MOUNT_POINT}" ||
				die 21 "Error $? mounting the lofi device"
			logMsg "boot_archive mounted ${MSG}: "
			mount | grep "${MOUNT_POINT}"
		else
			logMsg "boot_archive already mounted:"
			logMsg "${MOUNT_MSG}"
		fi
		;;

	-h | --help | "-?" | * )
		die 1 "Usage: $( basename $0 ) {mount|uninstall|umount}"
		;;

esac

die 0 >/dev/null


Save the script to, for example, /usr/bin/boot_archive and make it executable via

chmod 755 /usr/bin/boot_archive


Script Usage

Now you can mount the boot_archive with

/usr/bin/boot_archive  

After executing this command the boot_archive is mounted to /tmp/boot_archive and you can view the files in the boot_archive, e.g.

 
bash-3.2# ls /tmp/boot_archive
boot      etc       kernel    platform
bash-3.2#
 

To unmount the boot_archive use

/usr/bin/boot_archive umount

 Or

/usr/bin/boot_archive uninstall

Both parameters are used to unmount the boot_archive; using the parameter "uninstall" instead of "umount" also deletes the temporay copy of the boot_archive used by the script.

Notes:

Please note that the files in the boot_archive in newer Solaris Releases are compressed with gzip (use the command "file" to check the format of the files), therefore you must use gzcat or gzip to view the files, e.g

gzip -cd /tmp/boot_archive/etc/path_to_inst

 # or

gzcat /tmp/boot_archive/etc/path_to_inst


This  version of the script uses always a temporary copy of the boot_archive so there is no need anymore to umount the boot_archive before rebooting or updating the boot_archive manually by calling "bootadm update-archive".

Examples

Example usage on OpenSolaris for x86

# Mounting the boot_archive

bash-3.2# boot_archive
boot_archive: Using the boot archive "/platform/i86pc/amd64/boot_archive" ...
boot_archive: Copying "/platform/i86pc/amd64/boot_archive" to "/tmp/boot_archive.uncompressed" ...
boot_archive: boot_archive mounted readonly (hsfs)]:
/tmp/boot_archive on /dev/lofi/1 read only/setuid/devices/noglobal/maplcase/rr/traildot/dev=2400001 on Thu Dec  4 19:13:51 2008


# checking the files in the boot_archive
bash-3.2# ls /tmp/boot_archive
boot      etc       kernel    platform

bash-3.2# file /tmp/boot_archive/boot/solaris/bootenv.rc
/tmp/boot_archive/boot/solaris/bootenv.rc:      gzip compressed data - deflate method , original file name

bash-3.2# gzcat /tmp/boot_archive/boot/solaris/bootenv.rc
#
# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# CDDL HEADER START
#
[...]

setprop lba-access-ok 1
setprop keyboard-layout 'Unknown'
setprop console 'text'


# umounting the boot_archive
bash-3.2# boot_archive umount
boot_archive: Using the boot archive "/platform/i86pc/amd64/boot_archive" ...
boot_archive: boot_archive umounted
boot_archive: The temporary boot_archive is "/tmp/boot_archive.uncompressed"

bash-3.2# ls -l /tmp/boot_archive.uncompressed
-rw-r--r--   1 root     root     28178432 Dec  4 19:13 /tmp/boot_archive.uncompressed

# removing the temporary copy of the boot_archive

bash-3.2# boot_archive uninstall
boot_archive: Using the boot archive "/platform/i86pc/amd64/boot_archive" ...
boot_archive: The boot_archive is not mounted.
boot_archive: Deleting the temporary boot_archive ...

bash-3.2# ls -l /tmp/boot_archive.uncompressed
/tmp/boot_archive.uncompressed: No such file or directory



Example usage on Solaris 10 U6 for x86


# Mounting the boot_archive
#  bash-3.00# boot_archive
boot_archive: Using the boot archive "/platform/i86pc/boot_archive" ...
boot_archive: Uncompressing "/platform/i86pc/boot_archive" to "/tmp/boot_archive.gzip" using gzip ...
boot_archive: boot_archive mounted readonly (hsfs)]:
/tmp/boot_archive on /dev/lofi/1 read only/setuid/devices/noglobal/maplcase/rr/traildot/dev=2400001 on Thu Dec  4 20:14:44 2008

# checking the contents of the boot_archive

bash-3.00# ls /tmp/boot_archive
boot      etc       kernel    platform

bash-3.00# file /tmp/boot_archive/boot/solaris/bootenv.rc
/tmp/boot_archive/boot/solaris/bootenv.rc:      ascii text

 
bash-3.00# cat /tmp/boot_archive/boot/solaris/bootenv.rc
#
# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

#ident  "@(#)bootenv.rc 1.33    07/03/03 SMI"
#
#       bootenv.rc -- boot "environment variables"
#
setprop ata-dma-enabled 1

[...]

setprop keyboard-layout 'German'
setprop console 'text'

# unmounting the boot_archive and deleting the temporary file

bash-3.00# boot_archive uninstall
boot_archive: Using the boot archive "/platform/i86pc/boot_archive" ...
boot_archive: boot_archive umounted
boot_archive: Deleting the temporary boot_archive ...


Example usage on OpenSolaris for SPARC

# mounting the boot_archive

# boot_archive
boot_archive: Using the boot archive "/platform/sun4u/boot_archive" ...
boot_archive: Using the existing boot_archive copy "/tmp/boot_archive.uncompressed"
boot_archive: boot_archive mounted readonly (hsfs)]:
/tmp/boot_archive on /dev/lofi/24 read only/setuid/devices/noglobal/maplcase/rr/traildot/dev=24c0018 on Thu Dec  4 20:06:33 2008


# checking the contents of the boot_archive
# ls /tmp/boot_archive
etc       kernel    platform

# file /tmp/boot_archive/etc/dacf.conf
/tmp/boot_archive/etc/dacf.conf:        ascii text

# cat /tmp/boot_archive/etc/dacf.conf
#
# CDDL HEADER START
#
[...]
#
# Configure and/or unconfigure DDI_NT_NET devices.
#
minor-nodetype="ddi_network" net_dacf:net_config post-attach -
minor-nodetype="ddi_network" net_dacf:net_config pre-detach -


# Unmounting the boot_archive and removing the temporary file

# boot_archive uninstall
boot_archive: Using the boot archive "/platform/sun4u/boot_archive" ...
boot_archive: boot_archive umounted
boot_archive: Deleting the temporary boot_archive ...

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Nov 05, 2008

    sysglen says:

    sun4u | sun4us | sunv4 ) I believe the sunv4 in line 57 should be su...

    sun4u | sun4us | sunv4 )

    I believe the sunv4 in line 57 should be sun4v

    Glen

    1. Nov 05, 2008

      bnsmb says:

      Glen, You're right -thanks for the info. I corrected the line.

      Glen,

      You're right -thanks for the info. I corrected the line.

  2. Dec 03, 2008

    i.doleck says:

    Hi, Your script looks nice, but... it doesn't work... To test it I try to moun...

    Hi,
    Your script looks nice, but... it doesn't work...

    To test it I try to mount boot-archive as a lofi (#lofiadm -a /platform/i86pc/boot_archive) just from CLI, but my system (S10 5/08) says:

    "lofiadm: size of /platform/i86pc/boot_archive is not a multiple of 512"

    It seems logical - S10 expect a block device with standard block size of 512 bytes to create a pseudo block device /dev/lofi , doesn't it? And boot_archive is not an ufs-like archive - as far as I know...

    Did I miss something??

    Regards,
    i.doleck

    1. Dec 03, 2008

      bnsmb says:

      i.doleck, >> Did I miss something??  No, I did :  In Solaris 1...

      i.doleck,
      >> Did I miss something??

       No, I did :

       In Solaris 10 x86  the boot_archive is compressed with gzip:

      bash-3.00# uname -a
      SunOS unknown 5.10 Generic_137138-09 i86pc i386 i86pc
      
      bash-3.00# file /platform/i86pc/boot_archive
      /platform/i86pc/boot_archive:   gzip compressed data - deflate method
      
      


      In OpenSolaris it is not compressed:

      xtrnaw7@opensolaris001:~$ uname -a
      
      SunOS opensolaris001 5.11 snv_98 i86pc i386 i86pc Solaris
      xtrnaw7@opensolaris001:~$ file /platform/i86pc/boot_archive
      /platform/i86pc/boot_archive:   ISO 9660 filesystem image
      


      I will update the script in the next days to work also with compressed files.

      Bernd

      1. Dec 03, 2008

        i.doleck says:

        bnsmb, Thanks! Now it's clear! You need only to rename boot_archive to "boot_arc...

        bnsmb,
        Thanks! Now it's clear!
        You need only to rename boot_archive to "boot_archive.gz" before gunziping, but after it does work!

        Regards,
        i.doleck

  3. Dec 04, 2008

    kperkins says:

    Thanks, Bernd, for updating the script to accommodate various locations and file...

    Thanks, Bernd, for updating the script to accommodate various locations and file formats (plain, compressed) for boot_archive in different flavors of Solaris.

    Wiki admin

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact