Determining Solaris boot device

It is possible that the first entry listed in the EEPROM boot-device is not the current boot-device. To determine the current boot-device:

$ prtconf -pv | grep bootpath

prtconf -pv can also be used to display device aliases without being at the Open Boot Prompt ("ok" prompt).

Here is a script I wrote to convert the bootpath into cxtxdx (logical) format. This procedure should work with Solaris 2.6 SPARC and later. See below for the change needed for Solaris x86.

If it does not work on your system, please send me the prtconf output above along with the full device path to your boot disk.

#!/bin/sh

# Determine the Solaris boot disk in cxtxdx format.

BOOTPATH=`prtconf -pv | grep bootpath | tr -d "'" | awk '{ print $2 }'`

if [ -n "`echo $BOOTPATH | grep "/disk"`" ] ; then
   # The bootpath contains "disk," but the /devices block device contains
   # either "sd" or "ssd"
   BOOTPATH=`echo $BOOTPATH | sed 's/disk@//'`
   BOOT_DISK=`ls -l /dev/dsk | sed -e 's/ssd@//' -e 's/sd@//' \
   | grep "$BOOTPATH" 2>/dev/null | awk '{ print $9 }' | sed 's/s[0-7]//'`
else
   BOOT_DISK=`ls -l /dev/dsk | grep "$BOOTPATH" 2>/dev/null | \
   awk '{ print $9 }' | sed 's/s[0-7]//'`
fi

if [ -n "$BOOT_DISK" ] ; then
   echo "Your boot disk is ${BOOT_DISK}."
else
   echo "Unable to determine logical boot disk."
fi

To make the script work with Solaris x86, change the BOOTPATH line to read:
BOOTPATH=`grep bootpath /boot/solaris/bootenv.rc | awk '{ print $3 }'`

More information at sun-managers mailing list.

Back to brandonhutchinson.com.
Last modified: 2009/01/26