5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 # Copyright 2016 Nexenta Systems, Inc.
29 PATH
="/usr/bin:/usr/sbin:${PATH}"; export PATH
32 while getopts R
: OPT
2>/dev
/null
37 ?
) echo "Usage: ${0##*/}: [-R \<root\>]"
49 bootdev
=`grep -v "^#" "$ALT_ROOT"/etc/vfstab | grep pcfs \
50 | grep "[ ]/stubboot[ ]" | nawk '{print $1}'`
51 if [ X
"$bootdev" = "X" ]; then
58 if [ -f "$ALT_ROOT"/etc
/lu
/GRUB_slice
]; then
59 dev
=`grep '^PHYS_SLICE=' "$ALT_ROOT"/etc/lu/GRUB_slice |
61 if [ "`fstyp $dev`" = "zfs" ]; then
65 rootfstype
=`df -n ${ALT_ROOT:-/} | awk '{print $3}'`
66 if [ "$rootfstype" = "zfs" ]; then
74 # Return the list of raw devices
78 if [ -f "$ALT_ROOT"/etc
/lu
/GRUB_slice
]; then
79 dev
=`grep '^PHYS_SLICE' "$ALT_ROOT"/etc/lu/GRUB_slice |
81 if [ "$is_zfs_boot" = "yes" ]; then
82 fstyp
-a "$dev" |
grep 'path: ' |
grep -v phys_path
: |
83 cut
-d"'" -f2 |
sed 's+/dsk/+/rdsk/+'
88 elif [ "$is_zfs_boot" = "yes" ]; then
89 rootpool
=`df -k ${ALT_ROOT:-/} | tail +2 | cut -d/ -f1`
90 rootdevlist
=`LC_ALL=C zpool iostat -v "$rootpool" | tail +5 |
91 egrep -v "mirror|spare|replacing" |
92 sed -n -e '/--/q' -e p | awk '{print $1}'`
94 dev
=`grep -v "^#" "$ALT_ROOT"/etc/vfstab | \
95 grep "[ ]/[ ]" | nawk '{print $2}'`
96 if [[ $dev = /dev
/rdsk
/* ]]; then
97 rootdevlist
=`basename "$dev"`
100 for rootdev
in $rootdevlist
102 echo /dev
/rdsk
/`basename $rootdev`
107 # multiboot: install grub on the boot slice
111 # Stage 2 blocks must remain untouched
112 STAGE1
="$ALT_ROOT"/boot
/grub
/stage1
113 STAGE2
="$ALT_ROOT"/boot
/grub
/stage2
115 if [ $is_pcfs_boot = yes ]; then
117 # Note: /stubboot/boot/grub/stage2 must stay untouched.
119 mkdir
-p "$ALT_ROOT"/stubboot
/boot
/grub
120 cp "$ALT_ROOT"/boot
/grub
/menu.lst
"$ALT_ROOT"/stubboot
/boot
/grub
121 bootdev
=`grep -v "^#" "$ALT_ROOT"/etc/vfstab | grep pcfs | \
122 grep "[ ]/stubboot[ ]" | nawk '{print $1}'`
123 rpcfsdev
=`echo "$bootdev" | sed -e "s/dev\/dsk/dev\/rdsk/"`
124 if [ X
"$rpcfsdev" != X
]; then
125 print
"Installing grub on $rpcfsdev"
126 "$ALT_ROOT"/sbin
/installgrub
$STAGE1 $STAGE2 $rpcfsdev
130 grubdevlist
=`get_rootdev_list`
132 if [ "$is_zfs_boot" = "yes" ]; then
136 for rootdev
in $grubdevlist
138 if [ X
"$rpcfsdev" != X
]; then
139 echo "create GRUB menu in "$ALT_ROOT"/stubboot"
140 "$ALT_ROOT"/sbin
/bootadm update-menu
$zfsarg\
141 -R "$ALT_ROOT"/stubboot
-o $rootdev,"$ALT_ROOT"
143 echo "Creating GRUB menu in ${ALT_ROOT:-/}"
144 $ALT_ROOT/sbin
/bootadm update-menu
-R ${ALT_ROOT:-/} \
147 print
"Installing grub on $rootdev"
148 "$ALT_ROOT"/sbin
/installgrub
$STAGE1 $STAGE2 $rootdev
152 if [ -f "$ALT_ROOT"/platform
/i86pc
/multiboot
-a "$ARCH" = i386
] ; then