17c478bd9Sstevel@tonic-gate#!/sbin/sh 27c478bd9Sstevel@tonic-gate# 37c478bd9Sstevel@tonic-gate# CDDL HEADER START 47c478bd9Sstevel@tonic-gate# 57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 66927f468Sdp# Common Development and Distribution License (the "License"). 76927f468Sdp# You may not use this file except in compliance with the License. 87c478bd9Sstevel@tonic-gate# 97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate# and limitations under the License. 137c478bd9Sstevel@tonic-gate# 147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate# 207c478bd9Sstevel@tonic-gate# CDDL HEADER END 217c478bd9Sstevel@tonic-gate# 227c478bd9Sstevel@tonic-gate# 231e49577aSRod Evans# Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. 24*fb01aed5SAlexander Eremin# Copyright 2015 Nexenta Systems, Inc. All rights reserved. 257c478bd9Sstevel@tonic-gate# 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate# Make sure that the libraries essential to this stage of booting can be found. 287c478bd9Sstevel@tonic-gateLD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gatelibc_mount() { 317c478bd9Sstevel@tonic-gate # 327c478bd9Sstevel@tonic-gate # If there is an optimized libc available in /usr that fits this 337c478bd9Sstevel@tonic-gate # processor, mount it on top of the base libc. 347c478bd9Sstevel@tonic-gate # 35b1593d50SJason Beloro LIBC_MOE_32=`/usr/bin/moe -32 '/usr/lib/libc/$HWCAP'` 36b1593d50SJason Beloro if [ -n "$LIBC_MOE_32" ]; then 377c478bd9Sstevel@tonic-gate /usr/sbin/mount | egrep -s "^/lib/libc.so.1 on " 387c478bd9Sstevel@tonic-gate if [ $? -ne 0 ]; then 39b1593d50SJason Beloro /usr/sbin/mount -O -F lofs $LIBC_MOE_32 /lib/libc.so.1 40b1593d50SJason Beloro fi 41b1593d50SJason Beloro fi 42b1593d50SJason Beloro 43b1593d50SJason Beloro ARCH64=`isainfo | awk '{print $1}'` 44b1593d50SJason Beloro LIBC_MOE_64=`/usr/bin/moe -64 /usr/lib/$ARCH64/libc/'$HWCAP'` 45b1593d50SJason Beloro if [ -n "$LIBC_MOE_64" ]; then 46b1593d50SJason Beloro /usr/sbin/mount | egrep -s "^/lib/$ARCH64/libc.so.1 on " 47b1593d50SJason Beloro if [ $? -ne 0 ]; then 48b1593d50SJason Beloro /usr/sbin/mount -O -F lofs $LIBC_MOE_64 \ 49b1593d50SJason Beloro /lib/$ARCH64/libc.so.1 507c478bd9Sstevel@tonic-gate fi 517c478bd9Sstevel@tonic-gate fi 527c478bd9Sstevel@tonic-gate} 537c478bd9Sstevel@tonic-gate 546927f468Sdp. /lib/svc/share/smf_include.sh 556927f468Sdp. /lib/svc/share/fs_include.sh 566927f468Sdp 577c478bd9Sstevel@tonic-gate# 587c478bd9Sstevel@tonic-gate# Most of the operations in this script are only necessary in the global 597c478bd9Sstevel@tonic-gate# zone but due to the way initialization scripts like this are packaged, 607c478bd9Sstevel@tonic-gate# it needs to currently exist for all zones. 617c478bd9Sstevel@tonic-gate# 626927f468Sdpif smf_is_nonglobalzone; then 637c478bd9Sstevel@tonic-gate libc_mount 646927f468Sdp exit $SMF_EXIT_OK 657c478bd9Sstevel@tonic-gatefi 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate# 687c478bd9Sstevel@tonic-gate# Root is already mounted (by the kernel), but still needs to be 697c478bd9Sstevel@tonic-gate# checked, possibly remounted and entered into mnttab. First 70a227b7f4Shs24103# mount /usr if it is a separate file system. If the file system 71a227b7f4Shs24103# type is something other than zfs, mount it read-only. This must 727c478bd9Sstevel@tonic-gate# be done first to allow utilities such as fsck and setmnt to 737c478bd9Sstevel@tonic-gate# reside on /usr minimizing the space required by the root file 747c478bd9Sstevel@tonic-gate# system. 757c478bd9Sstevel@tonic-gate# 767c478bd9Sstevel@tonic-gatereadvfstab "/usr" < $vfstab 777c478bd9Sstevel@tonic-gateif [ -n "$mountp" ]; then 78*fb01aed5SAlexander Eremin if [ "$fstype" = zfs ]; then 79a227b7f4Shs24103 mountfs - /usr $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 807c478bd9Sstevel@tonic-gate else 817c478bd9Sstevel@tonic-gate # 827c478bd9Sstevel@tonic-gate # Must use -o largefiles here to ensure the 837c478bd9Sstevel@tonic-gate # read-only mount does not fail as a result of 847c478bd9Sstevel@tonic-gate # having a large file present on /usr. This gives 857c478bd9Sstevel@tonic-gate # fsck a chance to fix up the largefiles flag 867c478bd9Sstevel@tonic-gate # before we remount /usr read-write. 877c478bd9Sstevel@tonic-gate # 887c478bd9Sstevel@tonic-gate if [ "x$mntopts" = x- ]; then 897c478bd9Sstevel@tonic-gate mntopts='ro,largefiles' 907c478bd9Sstevel@tonic-gate else 917c478bd9Sstevel@tonic-gate checkopt largefiles $mntopts 927c478bd9Sstevel@tonic-gate if [ "x$option" != xlargefiles ]; then 937c478bd9Sstevel@tonic-gate mntopts="largefiles,$mntopts" 947c478bd9Sstevel@tonic-gate fi 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate checkopt ro $mntopts 977c478bd9Sstevel@tonic-gate if [ "x$option" != xro ]; then 987c478bd9Sstevel@tonic-gate mntopts="ro,$mntopts" 997c478bd9Sstevel@tonic-gate fi 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate # 1027c478bd9Sstevel@tonic-gate # Requesting logging on a read-only mount 1037c478bd9Sstevel@tonic-gate # causes errors to be displayed, so remove 1047c478bd9Sstevel@tonic-gate # "logging" from the list of options for now. 1057c478bd9Sstevel@tonic-gate # The read-write mount performed later will 1067c478bd9Sstevel@tonic-gate # specify the logging option if appropriate. 1077c478bd9Sstevel@tonic-gate # 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate checkopt logging $mntopts 1107c478bd9Sstevel@tonic-gate if [ "x$option" = xlogging ]; then 1117c478bd9Sstevel@tonic-gate mntopts="$otherops" 1127c478bd9Sstevel@tonic-gate fi 1137c478bd9Sstevel@tonic-gate fi 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate mountfs -O /usr $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 1167c478bd9Sstevel@tonic-gate fi 1177c478bd9Sstevel@tonic-gatefi 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate# 120a227b7f4Shs24103# if we are booted from zfs, the /usr mount probably won't be a 121a227b7f4Shs24103# legacy mount. Use the standard zfs mount command instead. 122a227b7f4Shs24103 123a227b7f4Shs24103readmnttab "/" < /etc/mnttab 124a227b7f4Shs24103if [ "$fstype" = zfs ]; then 125a227b7f4Shs24103 mountp=`/sbin/zfs get -H -o value mountpoint $special/usr 2>/dev/null` 126a227b7f4Shs24103 # 127a227b7f4Shs24103 # if mountp = /usr, there is a non-legacy mount of /usr 128a227b7f4Shs24103 # in the boot environment being booted. 129a227b7f4Shs24103 # 130a227b7f4Shs24103 if [ "x$mountp" = "x/usr" ] ; then 131a227b7f4Shs24103 /sbin/zfs mount $special/usr 132a227b7f4Shs24103 if [ $? != 0 ] ; then 133a227b7f4Shs24103 msg='zfs-mount failed' 134a227b7f4Shs24103 echo $msg 135a227b7f4Shs24103 echo "$SMF_FMRI:" $msg >/dev/msglog 136a227b7f4Shs24103 exit $SMF_EXIT_ERR_FATAL 137a227b7f4Shs24103 fi 138a227b7f4Shs24103 fi 139a227b7f4Shs24103fi 140a227b7f4Shs24103 141a227b7f4Shs24103# 1427c478bd9Sstevel@tonic-gate# Also mount /boot now so that things like keymap.sh can access 1437c478bd9Sstevel@tonic-gate# boot properties through eeprom. Readonly isn't required because 1447c478bd9Sstevel@tonic-gate# /boot (and other pcfs filesystems) aren't fsck'ed at boot yet. 1457c478bd9Sstevel@tonic-gate# Also, we don't account for caching /boot as it must be on a local 1467c478bd9Sstevel@tonic-gate# disk. So what's in vfstab is fine as it stands; just look to see 1477c478bd9Sstevel@tonic-gate# if it's there and avoid the mount if not. 1487c478bd9Sstevel@tonic-gate# 1497c478bd9Sstevel@tonic-gatereadvfstab "/boot" < $vfstab 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gateif [ -n "$mountp" ]; then 1527c478bd9Sstevel@tonic-gate mountfs - /boot $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 1537c478bd9Sstevel@tonic-gatefi 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate# 1567c478bd9Sstevel@tonic-gate# Update kernel driver.conf cache with any additional driver.conf 1577c478bd9Sstevel@tonic-gate# files found on /usr, and device permissions from /etc/minor_perm. 1587c478bd9Sstevel@tonic-gate# 1597c478bd9Sstevel@tonic-gate/usr/sbin/devfsadm -I -P 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gatelibc_mount 1627c478bd9Sstevel@tonic-gate 1636927f468Sdpexit $SMF_EXIT_OK 164