create_ramdisk.ksh revision e482cb0a07ec2a52aa89607892b8e7571b2bff92
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (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
# 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
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
# ident "%Z%%M% %I% %E% SMI"
#
# Parse options
#
do
if [ "$ALT_ROOT" != "/" ]; then
echo "Creating ram disk for $ALT_ROOT"
fi
;;
exit ;;
esac
done
fi
#
# mkisofs on s8 doesn't support functionality used by GRUB boot.
# Use ufs format for boot archive instead.
#
if [ "$release" = "5.8" ]; then
fi
if [ $# -eq 1 ]; then
ALT_ROOT="$1"
echo "Creating ram disk for $ALT_ROOT"
fi
function cleanup
{
}
function getsize
{
# should we exclude amd64 binaries?
# Estimate image size and add %10 overhead for ufs stuff.
# Note, we can't use du here in case we're on a filesystem, e.g. zfs,
# in which the disk usage is less than the sum of the file sizes.
# The nawk code
#
# {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7}
#
# next multiple of 1024. This mimics the behavior of ufs especially
# with directories. This results in a total size that's slightly
# bigger than if du was called on a ufs directory.
{t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7}
END {print int(t * 1.10 / 1024)}')
}
function create_ufs
{
# should we exclude amd64 binaries?
mkfile ${total_size}k "$rdfile"
# do the actual copy
cd "/$ALT_ROOT"
# on systems that have gzip. Then run gzip out of the patch to
# pick it up from bfubin or something like that if needed.
#
else
fi
}
function create_isofs
{
# should we exclude amd64 binaries?
# create image directory seed with graft points
do
fi
done
cd "/$ALT_ROOT"
# on systems that have gzip. Then run gzip out of the patch to
# pick it up from bfubin or something like that if needed.
#
gzip > "$ALT_ROOT/$BOOT_ARCHIVE-new"
else
fi
if [ $? -eq 0 ]; then
rm -f "$ALT_ROOT/$BOOT_ARCHIVE-new"
fi
fi
}
#
# get filelist
#
if [[ -z "$files" ]]
then
print -u2 "Can't find filelist.ramdisk"
exit 1
fi
#
# decide if cpu is amd64 capable
#
is_amd64=$?
# calculate image size
# check to see if there is sufficient space in tmpfs
#
# assumes we have enough scratch space on $ALT_ROOT
fi
fi
# make directory for temp files safely
# Clean up upon exit.
trap 'cleanup' EXIT
echo "updating $ALT_ROOT/$BOOT_ARCHIVE...this may take a minute"
if [ $format = "ufs" ]; then
else
fi
# Make sure $BOOT_ARCHIVE-new created by either create_ufs or creat_isofs
# above is flushed to the backing store before we do anything with it.
# sanity check the archive before moving it into place
# the file type check also establishes that the file exists at all
#
echo "update of $ALT_ROOT/$BOOT_ARCHIVE failed"
exit 1
fi
#
# For the diskless case, hardlink archive to /boot to make it
# visible via tftp. /boot is lofs mounted under /tftpboot/<hostname>.
# NOTE: this script must work on both client and server
#
if [ $? = 0 ]; then
mv "$ALT_ROOT/$BOOT_ARCHIVE-new" "$ALT_ROOT/$BOOT_ARCHIVE"
rm -f "$ALT_ROOT/boot/boot_archive"
exit
fi
mv "$ALT_ROOT/$BOOT_ARCHIVE-new" "$ALT_ROOT/$BOOT_ARCHIVE"