create_ramdisk.ksh revision 5648:161f8007cab9
1219820Sjeff#!/bin/ksh -p 2219820Sjeff# 3219820Sjeff# CDDL HEADER START 4219820Sjeff# 5219820Sjeff# The contents of this file are subject to the terms of the 6219820Sjeff# Common Development and Distribution License (the "License"). 7219820Sjeff# You may not use this file except in compliance with the License. 8219820Sjeff# 9219820Sjeff# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10219820Sjeff# or http://www.opensolaris.org/os/licensing. 11219820Sjeff# See the License for the specific language governing permissions 12219820Sjeff# and limitations under the License. 13219820Sjeff# 14219820Sjeff# When distributing Covered Code, include this CDDL HEADER in each 15219820Sjeff# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16219820Sjeff# If applicable, add the following below this CDDL HEADER, with the 17219820Sjeff# fields enclosed by brackets "[]" replaced with your own identifying 18219820Sjeff# information: Portions Copyright [yyyy] [name of copyright owner] 19219820Sjeff# 20219820Sjeff# CDDL HEADER END 21219820Sjeff# 22219820Sjeff 23219820Sjeff# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24219820Sjeff# Use is subject to license terms. 25219820Sjeff 26219820Sjeff# ident "%Z%%M% %I% %E% SMI" 27219820Sjeff 28219820Sjeffformat=ufs 29219820SjeffALT_ROOT= 30219820SjeffALTROOT_ARG= 31219820Sjeffcompress=yes 32219820SjeffSPLIT=unknown 33219820SjeffERROR=0 34219820Sjeffdirsize32=0 35219820Sjeffdirsize64=0 36219820Sjeff 37219820SjeffPLAT=`uname -m` 38219820Sjeffif [ $PLAT = i86pc ] ; then 39219820Sjeff ARCH64=amd64 40219820Sjeffelse 41219820Sjeff ARCH64=sparcv9 42219820Sjefffi 43219820SjeffBOOT_ARCHIVE=platform/$PLAT/boot_archive 44219820SjeffBOOT_ARCHIVE_64=platform/$PLAT/$ARCH64/boot_archive 45219820Sjeff 46219820Sjeff# 47219820Sjeff# set path, but inherit /tmp/bfubin if owned by 48219820Sjeff# same uid executing this process, which must be root. 49219820Sjeff# 50219820Sjeffif [ "`echo $PATH | cut -f 1 -d :`" = /tmp/bfubin ] && \ 51219820Sjeff [ -O /tmp/bfubin ] ; then 52219820Sjeff export PATH=/tmp/bfubin:/usr/sbin:/usr/bin:/sbin 53219820Sjeffelse 54219820Sjeff export PATH=/usr/sbin:/usr/bin:/sbin 55219820Sjefffi 56219820Sjeff 57219820SjeffEXTRACT_FILELIST="/boot/solaris/bin/extract_boot_filelist" 58219820Sjeff 59219820Sjeff# 60219820Sjeff# Parse options 61219820Sjeff# 62219820Sjeffwhile [ "$1" != "" ] 63219820Sjeffdo 64219820Sjeff case $1 in 65219820Sjeff -R) shift 66219820Sjeff ALT_ROOT="$1" 67219820Sjeff if [ "$ALT_ROOT" != "/" ]; then 68219820Sjeff echo "Creating ram disk for $ALT_ROOT" 69219820Sjeff ALTROOT_ARG="-R $ALT_ROOT" 70219820Sjeff EXTRACT_FILELIST="${ALT_ROOT}${EXTRACT_FILELIST}" 71219820Sjeff fi 72219820Sjeff ;; 73219820Sjeff -n|--nocompress) compress=no 74219820Sjeff ;; 75219820Sjeff *) echo Usage: ${0##*/}: [-R \<root\>] [--nocompress] 76219820Sjeff exit 77219820Sjeff ;; 78219820Sjeff esac 79219820Sjeff shift 80219820Sjeffdone 81219820Sjeff 82219820Sjeffif [ -x /usr/bin/mkisofs -o -x /tmp/bfubin/mkisofs ] ; then 83219820Sjeff format=isofs 84219820Sjefffi 85219820Sjeff 86219820Sjeff# 87219820Sjeff# mkisofs on s8 doesn't support functionality used by GRUB boot. 88219820Sjeff# Use ufs format for boot archive instead. 89219820Sjeff# 90219820Sjeffrelease=`uname -r` 91219820Sjeffif [ "$release" = "5.8" ]; then 92219820Sjeff format=ufs 93219820Sjefffi 94219820Sjeff 95219820Sjeffshift `expr $OPTIND - 1` 96219820Sjeff 97219820Sjeffif [ $# -eq 1 ]; then 98219820Sjeff ALT_ROOT="$1" 99219820Sjeff echo "Creating ram disk for $ALT_ROOT" 100219820Sjefffi 101219820Sjeff 102219820Sjeffif [ $PLAT = i86pc ] ; then 103219820Sjeff rundir=`dirname $0` 104219820Sjeff if [ ! -x "$rundir"/symdef ]; then 105219820Sjeff # Shouldn't happen 106219820Sjeff echo "Warning: $rundir/symdef not present." 107219820Sjeff echo "Creating single archive at $ALT_ROOT/$BOOT_ARCHIVE" 108219820Sjeff SPLIT=no 109219820Sjeff compress=no 110219820Sjeff elif "$rundir"/symdef "$ALT_ROOT"/platform/i86pc/kernel/unix \ 111219820Sjeff dboot_image 2>/dev/null; then 112219820Sjeff SPLIT=yes 113219820Sjeff else 114219820Sjeff SPLIT=no 115219820Sjeff compress=no 116219820Sjeff fi 117219820Sjeffelse # must be sparc 118219820Sjeff SPLIT=no # there's only 64-bit (sparcv9), so don't split 119219820Sjeff compress=no 120219820Sjefffi 121219820Sjeff 122219820Sjeff[ -x /usr/bin/gzip ] || compress=no 123219820Sjeff 124219820Sjefffunction cleanup 125219820Sjeff{ 126219820Sjeff umount -f "$rdmnt32" 2>/dev/null 127219820Sjeff umount -f "$rdmnt64" 2>/dev/null 128219820Sjeff lofiadm -d "$rdfile32" 2>/dev/null 129219820Sjeff lofiadm -d "$rdfile64" 2>/dev/null 130219820Sjeff [ -n "$rddir" ] && rm -fr "$rddir" 2> /dev/null 131219820Sjeff [ -n "$new_rddir" ] && rm -fr "$new_rddir" 2>/dev/null 132219820Sjeff} 133219820Sjeff 134219820Sjefffunction getsize 135219820Sjeff{ 136219820Sjeff # Estimate image size and add 10% overhead for ufs stuff. 137219820Sjeff # Note, we can't use du here in case we're on a filesystem, e.g. zfs, 138219820Sjeff # in which the disk usage is less than the sum of the file sizes. 139219820Sjeff # The nawk code 140219820Sjeff # 141219820Sjeff # {t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5} 142219820Sjeff # 143219820Sjeff # below rounds up the size of a file/directory, in bytes, to the 144219820Sjeff # next multiple of 1024. This mimics the behavior of ufs especially 145219820Sjeff # with directories. This results in a total size that's slightly 146219820Sjeff # bigger than if du was called on a ufs directory. 147219820Sjeff size32=$(cat "$list32" | xargs -I {} ls -lLd "{}" 2> /dev/null | 148219820Sjeff nawk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5} 149219820Sjeff END {print int(t * 1.10 / 1024)}') 150219820Sjeff (( size32 += dirsize32 )) 151219820Sjeff size64=$(cat "$list64" | xargs -I {} ls -lLd "{}" 2> /dev/null | 152219820Sjeff nawk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5} 153219820Sjeff END {print int(t * 1.10 / 1024)}') 154219820Sjeff (( size64 += dirsize64 )) 155219820Sjeff (( total_size = size32 + size64 )) 156219820Sjeff 157219820Sjeff if [ $compress = yes ] ; then 158219820Sjeff total_size=`echo $total_size | nawk '{print int($1 / 2)}'` 159219820Sjeff fi 160219820Sjeff} 161219820Sjeff 162219820Sjeff# 163219820Sjeff# Copies all desired files to a target directory. One argument should be 164219820Sjeff# passed: the file containing the list of files to copy. This function also 165219820Sjeff# depends on several variables that must be set before calling: 166219820Sjeff# 167219820Sjeff# $ALT_ROOT - the target directory 168219820Sjeff# $compress - whether or not the files in the archives should be compressed 169219820Sjeff# $rdmnt - the target directory 170219820Sjeff# 171219820Sjefffunction copy_files 172219820Sjeff{ 173219820Sjeff list="$1" 174219820Sjeff 175219820Sjeff # 176219820Sjeff # If compress is set, the files are gzip'd and put in the correct 177219820Sjeff # location in the loop. Nothing is printed, so the pipe and cpio 178219820Sjeff # at the end is a nop. 179219820Sjeff # 180219820Sjeff # If compress is not set, the file names are printed, which causes 181219820Sjeff # the cpio at the end to do the copy. 182219820Sjeff # 183219820Sjeff while read path 184219820Sjeff do 185219820Sjeff if [ $compress = yes ]; then 186219820Sjeff dir="${path%/*}" 187219820Sjeff mkdir -p "$rdmnt/$dir" 188219820Sjeff /usr/bin/gzip -c "$path" > "$rdmnt/$path" 189219820Sjeff else 190219820Sjeff print "$path" 191219820Sjeff fi 192219820Sjeff done <"$list" | cpio -pdum "$rdmnt" 2>/dev/null 193219820Sjeff 194219820Sjeff if [ `uname -p` = sparc ] ; then 195219820Sjeff # copy links 196219820Sjeff find $filelist -type l -print 2>/dev/null |\ 197219820Sjeff cpio -pdum "$rdmnt" 2>/dev/null 198219820Sjeff if [ $compress = yes ] ; then 199219820Sjeff # always copy unix uncompressed 200219820Sjeff find $filelist -name unix -type f -print 2>/dev/null |\ 201219820Sjeff cpio -pdum "$rdmnt" 2>/dev/null 202219820Sjeff fi 203219820Sjeff fi 204219820Sjeff 205219820Sjeff} 206219820Sjeff 207219820Sjeff# 208219820Sjeff# The first argument can be: 209219820Sjeff# 210219820Sjeff# "both" - create an archive with both 32-bit and 64-bit binaries 211219820Sjeff# "32-bit" - create an archive with only 32-bit binaries 212219820Sjeff# "64-bit" - create an archive with only 64-bit binaries 213219820Sjeff# 214219820Sjefffunction create_ufs 215219820Sjeff{ 216219820Sjeff which=$1 217219820Sjeff archive=$2 218219820Sjeff lofidev=$3 219219820Sjeff 220219820Sjeff # should we exclude amd64 binaries? 221219820Sjeff if [ "$which" = "32-bit" ]; then 222219820Sjeff rdfile="$rdfile32" 223219820Sjeff rdmnt="$rdmnt32" 224219820Sjeff list="$list32" 225219820Sjeff elif [ "$which" = "64-bit" ]; then 226219820Sjeff rdfile="$rdfile64" 227219820Sjeff rdmnt="$rdmnt64" 228219820Sjeff list="$list64" 229219820Sjeff else 230219820Sjeff rdfile="$rdfile32" 231219820Sjeff rdmnt="$rdmnt32" 232219820Sjeff list="$list32" 233219820Sjeff fi 234219820Sjeff 235219820Sjeff newfs $lofidev < /dev/null 2> /dev/null 236219820Sjeff mkdir "$rdmnt" 237219820Sjeff mount -F mntfs mnttab /etc/mnttab > /dev/null 2>&1 238219820Sjeff mount -o nologging $lofidev "$rdmnt" 239219820Sjeff files= 240219820Sjeff 241219820Sjeff # do the actual copy 242219820Sjeff copy_files "$list" 243219820Sjeff umount "$rdmnt" 244219820Sjeff rmdir "$rdmnt" 245219820Sjeff 246219820Sjeff if [ `uname -p` = sparc ] ; then 247219820Sjeff rlofidev=`echo "$lofidev" | sed -e "s/dev\/lofi/dev\/rlofi/"` 248219820Sjeff bb="$ALT_ROOT/usr/platform/`uname -i`/lib/fs/ufs/bootblk" 249219820Sjeff installboot "$bb" $rlofidev 250219820Sjeff fi 251219820Sjeff 252219820Sjeff # 253219820Sjeff # Check if gzip exists in /usr/bin, so we only try to run gzip 254219820Sjeff # on systems that have gzip. Then run gzip out of the patch to 255219820Sjeff # pick it up from bfubin or something like that if needed. 256219820Sjeff # 257219820Sjeff # If compress is set, the individual files in the archive are 258219820Sjeff # compressed, and the final compression will accomplish very 259219820Sjeff # little. To save time, we skip the gzip in this case. 260219820Sjeff # 261219820Sjeff if [ `uname -p` = i386 ] && [ $compress = no ] && \ 262219820Sjeff [ -x /usr/bin/gzip ] ; then 263219820Sjeff gzip -c "$rdfile" > "${archive}-new" 264219820Sjeff else 265219820Sjeff cat "$rdfile" > "${archive}-new" 266219820Sjeff fi 267219820Sjeff} 268219820Sjeff 269219820Sjeff# 270219820Sjeff# The first argument can be: 271219820Sjeff# 272219820Sjeff# "both" - create an archive with both 32-bit and 64-bit binaries 273219820Sjeff# "32-bit" - create an archive with only 32-bit binaries 274219820Sjeff# "64-bit" - create an archive with only 64-bit binaries 275219820Sjeff# 276219820Sjefffunction create_isofs 277219820Sjeff{ 278219820Sjeff which=$1 279219820Sjeff archive=$2 280219820Sjeff 281219820Sjeff # should we exclude amd64 binaries? 282219820Sjeff if [ "$which" = "32-bit" ]; then 283219820Sjeff rdmnt="$rdmnt32" 284219820Sjeff errlog="$errlog32" 285219820Sjeff list="$list32" 286219820Sjeff elif [ "$which" = "64-bit" ]; then 287219820Sjeff rdmnt="$rdmnt64" 288219820Sjeff errlog="$errlog64" 289219820Sjeff list="$list64" 290219820Sjeff else 291219820Sjeff rdmnt="$rdmnt32" 292219820Sjeff errlog="$errlog32" 293219820Sjeff list="$list32" 294219820Sjeff fi 295219820Sjeff 296219820Sjeff # create image directory seed with graft points 297219820Sjeff mkdir "$rdmnt" 298219820Sjeff files= 299219820Sjeff isocmd="mkisofs -quiet -graft-points -dlrDJN -relaxed-filenames" 300219820Sjeff 301219820Sjeff if [ `uname -p` = sparc ] ; then 302219820Sjeff bb="$ALT_ROOT/usr/platform/`uname -i`/lib/fs/hsfs/bootblk" 303219820Sjeff isocmd="$isocmd -G \"$bb\"" 304219820Sjeff fi 305219820Sjeff 306219820Sjeff copy_files "$list" 307219820Sjeff isocmd="$isocmd \"$rdmnt\"" 308219820Sjeff rm -f "$errlog" 309219820Sjeff 310219820Sjeff # 311219820Sjeff # Check if gzip exists in /usr/bin, so we only try to run gzip 312219820Sjeff # on systems that have gzip. Then run gzip out of the patch to 313219820Sjeff # pick it up from bfubin or something like that if needed. 314219820Sjeff # 315219820Sjeff # If compress is set, the individual files in the archive are 316219820Sjeff # compressed, and the final compression will accomplish very 317219820Sjeff # little. To save time, we skip the gzip in this case. 318219820Sjeff # 319219820Sjeff if [ `uname -p` = i386 ] &&[ $compress = no ] && [ -x /usr/bin/gzip ] 320219820Sjeff then 321219820Sjeff ksh -c "$isocmd" 2> "$errlog" | \ 322219820Sjeff gzip > "${archive}-new" 323219820Sjeff else 324219820Sjeff ksh -c "$isocmd" 2> "$errlog" > "${archive}-new" 325219820Sjeff fi 326219820Sjeff 327219820Sjeff if [ `uname -p` = sparc ] ; then 328219820Sjeff bb="$ALT_ROOT/usr/platform/`uname -i`/lib/fs/hsfs/bootblk" 329219820Sjeff lofidev=`lofiadm -a "${archive}-new"` 330219820Sjeff rlofidev=`echo "$lofidev" | sed -e "s/dev\/lofi/dev\/rlofi/"` 331219820Sjeff installboot "$bb" "$rlofidev" 332219820Sjeff lofiadm -d "$lofidev" 333219820Sjeff fi 334219820Sjeff 335219820Sjeff if [ -s "$errlog" ]; then 336219820Sjeff grep Error: "$errlog" >/dev/null 2>&1 337219820Sjeff if [ $? -eq 0 ]; then 338219820Sjeff grep Error: "$errlog" 339219820Sjeff rm -f "${archive}-new" 340219820Sjeff fi 341219820Sjeff fi 342219820Sjeff rm -f "$errlog" 343219820Sjeff} 344219820Sjeff 345219820Sjefffunction create_archive 346219820Sjeff{ 347219820Sjeff which=$1 348219820Sjeff archive=$2 349219820Sjeff lofidev=$3 350219820Sjeff 351219820Sjeff echo "updating $archive" 352219820Sjeff 353219820Sjeff if [ "$format" = "ufs" ]; then 354219820Sjeff create_ufs "$which" "$archive" "$lofidev" 355219820Sjeff else 356219820Sjeff create_isofs "$which" "$archive" 357219820Sjeff fi 358219820Sjeff 359219820Sjeff # sanity check the archive before moving it into place 360219820Sjeff # 361219820Sjeff ARCHIVE_SIZE=`ls -l "${archive}-new" | nawk '{ print $5 }'` 362219820Sjeff if [ $compress = yes ] || [ `uname -p` = sparc ] ; then 363219820Sjeff # 364219820Sjeff # 'file' will report "English text" for uncompressed 365219820Sjeff # boot_archives. Checking for that doesn't seem stable, 366219820Sjeff # so we just check that the file exists. 367219820Sjeff # 368219820Sjeff ls "${archive}-new" >/dev/null 2>&1 369219820Sjeff else 370219820Sjeff # 371219820Sjeff # the file type check also establishes that the 372219820Sjeff # file exists at all 373219820Sjeff # 374219820Sjeff LC_MESSAGES=C file "${archive}-new" | grep gzip > /dev/null 375219820Sjeff fi 376219820Sjeff 377219820Sjeff if [ $? = 1 ] && [ -x /usr/bin/gzip ] || [ $ARCHIVE_SIZE -lt 5000 ] 378219820Sjeff then 379219820Sjeff # 380219820Sjeff # Two of these functions may be run in parallel. We 381219820Sjeff # need to allow the other to clean up, so we can't 382219820Sjeff # exit immediately. Instead, we set a flag. 383219820Sjeff # 384219820Sjeff echo "update of $archive failed" 385219820Sjeff ERROR=1 386219820Sjeff else 387219820Sjeff lockfs -f "/$ALT_ROOT" 2>/dev/null 388219820Sjeff mv "${archive}-new" "$archive" 389219820Sjeff lockfs -f "/$ALT_ROOT" 2>/dev/null 390219820Sjeff fi 391219820Sjeff 392219820Sjeff} 393219820Sjeff 394219820Sjefffunction fatal_error 395219820Sjeff{ 396219820Sjeff print -u2 $* 397219820Sjeff exit 1 398219820Sjeff} 399219820Sjeff 400219820Sjeff# 401219820Sjeff# get filelist 402219820Sjeff# 403219820Sjeffif [ ! -f "$ALT_ROOT/boot/solaris/filelist.ramdisk" ] && 404219820Sjeff [ ! -f "$ALT_ROOT/etc/boot/solaris/filelist.ramdisk" ] 405219820Sjeffthen 406219820Sjeff print -u2 "Can't find filelist.ramdisk" 407219820Sjeff exit 1 408219820Sjefffi 409219820Sjefffilelist=$($EXTRACT_FILELIST $ALTROOT_ARG /boot/solaris/filelist.ramdisk \ 410219820Sjeff /etc/boot/solaris/filelist.ramdisk 2>/dev/null | sort -u) 411219820Sjeff 412219820Sjeff# 413219820Sjeff# We use /tmp/ for scratch space now. This may be changed later if there 414219820Sjeff# is insufficient space in /tmp/. 415219820Sjeff# 416219820Sjeffrddir="/tmp/create_ramdisk.$$.tmp" 417219820Sjeffnew_rddir= 418219820Sjeffrm -rf "$rddir" 419219820Sjeffmkdir "$rddir" || fatal_error "Could not create temporary directory $rddir" 420219820Sjeff 421219820Sjeff# Clean up upon exit. 422219820Sjefftrap 'cleanup' EXIT 423219820Sjeff 424219820Sjefflist32="$rddir/filelist.32" 425219820Sjefflist64="$rddir/filelist.64" 426219820Sjeff 427219820Sjefftouch $list32 $list64 428219820Sjeff 429219820Sjeff# 430219820Sjeff# This loop creates the 32-bit and 64-bit lists of files. The 32-bit list 431219820Sjeff# is written to stdout, which is redirected at the end of the loop. The 432219820Sjeff# 64-bit list is appended with each write. 433219820Sjeff# 434219820Sjeffcd "/$ALT_ROOT" 435219820Sjefffind $filelist -print 2>/dev/null | while read path 436219820Sjeffdo 437219820Sjeff if [ $SPLIT = no ]; then 438219820Sjeff print "$path" 439219820Sjeff elif [ -d "$path" ]; then 440219820Sjeff if [ $format = ufs ]; then 441219820Sjeff size=`ls -lLd "$path" | nawk ' 442219820Sjeff {print ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}'` 443219820Sjeff if [ `basename "$path"` != "amd64" ]; then 444219820Sjeff (( dirsize32 += size )) 445219820Sjeff fi 446219820Sjeff (( dirsize64 += size )) 447219820Sjeff fi 448219820Sjeff else 449219820Sjeff filetype=`LC_MESSAGES=C file "$path" 2>/dev/null |\ 450219820Sjeff awk '/ELF/ { print $3 }'` 451219820Sjeff if [ "$filetype" = "64-bit" ]; then 452219820Sjeff print "$path" >> "$list64" 453219820Sjeff elif [ "$filetype" = "32-bit" ]; then 454219820Sjeff print "$path" 455219820Sjeff else 456219820Sjeff # put in both lists 457219820Sjeff print "$path" 458219820Sjeff print "$path" >> "$list64" 459219820Sjeff fi 460219820Sjeff fi 461219820Sjeffdone >"$list32" 462219820Sjeff 463219820Sjeffif [ $format = ufs ] ; then 464219820Sjeff # calculate image size 465219820Sjeff getsize 466219820Sjeff 467219820Sjeff # check to see if there is sufficient space in tmpfs 468219820Sjeff # 469219820Sjeff tmp_free=`df -b /tmp | tail -1 | awk '{ printf ($2) }'` 470219820Sjeff (( tmp_free = tmp_free / 2 )) 471219820Sjeff 472219820Sjeff if [ $total_size -gt $tmp_free ] ; then 473219820Sjeff # assumes we have enough scratch space on $ALT_ROOT 474219820Sjeff new_rddir="/$ALT_ROOT/create_ramdisk.$$.tmp" 475219820Sjeff rm -rf "$new_rddir" 476219820Sjeff mkdir "$new_rddir" || fatal_error \ 477219820Sjeff "Could not create temporary directory $new_rddir" 478219820Sjeff 479219820Sjeff # Save the file lists 480219820Sjeff mv "$list32" "$new_rddir"/ 481219820Sjeff mv "$list64" "$new_rddir"/ 482219820Sjeff list32="/$new_rddir/filelist.32" 483219820Sjeff list64="/$new_rddir/filelist.64" 484219820Sjeff 485219820Sjeff # Remove the old $rddir and set the new value of rddir 486219820Sjeff rm -rf "$rddir" 487219820Sjeff rddir="$new_rddir" 488219820Sjeff new_rddir= 489219820Sjeff fi 490219820Sjefffi 491219820Sjeff 492219820Sjeffrdfile32="$rddir/rd.file.32" 493219820Sjeffrdfile64="$rddir/rd.file.64" 494219820Sjeffrdmnt32="$rddir/rd.mount.32" 495219820Sjeffrdmnt64="$rddir/rd.mount.64" 496219820Sjefferrlog32="$rddir/rd.errlog.32" 497219820Sjefferrlog64="$rddir/rd.errlog.64" 498219820Sjefflofidev32="" 499219820Sjefflofidev64="" 500219820Sjeff 501219820Sjeffif [ $SPLIT = yes ]; then 502219820Sjeff # 503219820Sjeff # We can't run lofiadm commands in parallel, so we have to do 504219820Sjeff # them here. 505219820Sjeff # 506219820Sjeff if [ "$format" = "ufs" ]; then 507219820Sjeff mkfile ${size32}k "$rdfile32" 508219820Sjeff lofidev32=`lofiadm -a "$rdfile32"` 509219820Sjeff mkfile ${size64}k "$rdfile64" 510219820Sjeff lofidev64=`lofiadm -a "$rdfile64"` 511219820Sjeff fi 512219820Sjeff create_archive "32-bit" "$ALT_ROOT/$BOOT_ARCHIVE" $lofidev32 & 513219820Sjeff create_archive "64-bit" "$ALT_ROOT/$BOOT_ARCHIVE_64" $lofidev64 514219820Sjeff wait 515219820Sjeff if [ "$format" = "ufs" ]; then 516219820Sjeff lofiadm -d "$rdfile32" 517219820Sjeff lofiadm -d "$rdfile64" 518219820Sjeff fi 519219820Sjeffelse 520219820Sjeff if [ "$format" = "ufs" ]; then 521219820Sjeff mkfile ${total_size}k "$rdfile32" 522219820Sjeff lofidev32=`lofiadm -a "$rdfile32"` 523219820Sjeff fi 524219820Sjeff create_archive "both" "$ALT_ROOT/$BOOT_ARCHIVE" $lofidev32 525219820Sjeff [ "$format" = "ufs" ] && lofiadm -d "$rdfile32" 526219820Sjefffi 527219820Sjeffif [ $ERROR = 1 ]; then 528219820Sjeff cleanup 529 exit 1 530fi 531 532# 533# For the diskless case, hardlink archive to /boot to make it 534# visible via tftp. /boot is lofs mounted under /tftpboot/<hostname>. 535# NOTE: this script must work on both client and server. 536# 537grep "[ ]/[ ]*nfs[ ]" "$ALT_ROOT/etc/vfstab" > /dev/null 538if [ $? = 0 ]; then 539 rm -f "$ALT_ROOT/boot/boot_archive" "$ALT_ROOT/boot/amd64/boot_archive" 540 ln "$ALT_ROOT/$BOOT_ARCHIVE" "$ALT_ROOT/boot/boot_archive" 541 ln "$ALT_ROOT/$BOOT_ARCHIVE_64" "$ALT_ROOT/boot/amd64/boot_archive" 542fi 543[ -n "$rddir" ] && rm -rf "$rddir" 544