fs-minimal revision b21718f06a7f8468913c84002f8381a5ee1cb8c4
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle#!/sbin/sh
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle#
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# CDDL HEADER START
2312a9d8e5342846988edcd629e1ac56a8b5d4a9Brendan Mmiller#
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# The contents of this file are subject to the terms of the
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# Common Development and Distribution License (the "License").
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# You may not use this file except in compliance with the License.
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle#
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# or http://www.opensolaris.org/os/licensing.
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# See the License for the specific language governing permissions
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# and limitations under the License.
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle#
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# When distributing Covered Code, include this CDDL HEADER in each
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# If applicable, add the following below this CDDL HEADER, with the
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# fields enclosed by brackets "[]" replaced with your own identifying
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# information: Portions Copyright [yyyy] [name of copyright owner]
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle#
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# CDDL HEADER END
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle#
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle#
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# Use is subject to license terms.
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle#
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
bf6542c5aa722eb97a0df17e6db46cc884f203bfJason Vincent# All rights reserved.
bf6542c5aa722eb97a0df17e6db46cc884f203bfJason Vincent#
bf6542c5aa722eb97a0df17e6db46cc884f203bfJason Vincent#
bf6542c5aa722eb97a0df17e6db46cc884f203bfJason Vincent# ident "%Z%%M% %I% %E% SMI"
331c327f500d45223e8ad933fd4472740a75aeeachad.kienle
33c021457bc11072601be0484041e2f46c2616a5Brendan Miller. /lib/svc/share/smf_include.sh
331c327f500d45223e8ad933fd4472740a75aeeachad.kienle. /lib/svc/share/fs_include.sh
49ca89f51e0242b83f998f16a269dc1982460f02Chad Kienle
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# Mount other file systems to be available in single user mode.
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# Currently, these are /var, /var/adm, /var/run and /tmp. A change
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# here will require a modification to the following programs (and
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# documentation): /sbin/mountall, /sbin/umountall, and
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle# /lib/svc/bin/svc.startd.
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienlerootiszfs=0
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienlereadmnttab / < /etc/mnttab
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienleif [ "$fstype" = zfs ] ; then
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle rootiszfs=1
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle be=$special
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienlefi
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienlefor fs in /var /var/adm /tmp; do
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle readvfstab $fs < $vfstab
ad0b283113c3f11ac1877df97d5d0fae899b56caBrendan Mmiller if [ -n "$mountp" ]; then
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle mounted $mountp $mntopts $fstype < /etc/mnttab && continue
c7d50eceb9a78ce2ecf39004ad4cf7e3d236aab0Alin Brici checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
c7d50eceb9a78ce2ecf39004ad4cf7e3d236aab0Alin Brici mountfs -O $mountp $fstype $mntopts - ||
495b3077b06dd17ae1badca754404b959855be2eBrendan Miller exit $SMF_EXIT_ERR_FATAL
21dcdac963f79c098a5ea1a2c5c5e109429c9786Brendan Miller continue
27d847b55dc37eb425475d2c53b1cf9dfb0b9f61Brendan Miller fi
331c327f500d45223e8ad933fd4472740a75aeeachad.kienle if [ "$rootiszfs" = 1 ]; then
331c327f500d45223e8ad933fd4472740a75aeeachad.kienle mountpt=`zfs get -H -o value mountpoint $be$fs 2>/dev/null`
331c327f500d45223e8ad933fd4472740a75aeeachad.kienle if [ $? = 0 ] ; then
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle if [ "x$mountpt" = "x$fs" ] ; then
331c327f500d45223e8ad933fd4472740a75aeeachad.kienle /sbin/zfs mount -O $be$fs
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle fi
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle fi
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle fi
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienledone
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienlemounted /var/run - tmpfs < /etc/mnttab
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienleif [ $? != 0 ] ; then
bf6542c5aa722eb97a0df17e6db46cc884f203bfJason Vincent mountfs -O /var/run tmpfs - swap || exit $SMF_EXIT_ERR_FATAL
331c327f500d45223e8ad933fd4472740a75aeeachad.kienlefi
331c327f500d45223e8ad933fd4472740a75aeeachad.kienle
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienleif [ "$rootiszfs" = 1 ] ; then
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle /sbin/zfs list -rH -o mountpoint -s mountpoint -t filesystem $be | \
b1c33bb0456be2f3b9e866871ff404ae012978b9Chad Kienle while read mountp ; do
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle if [ "x$mountp" != "x" -a "$mountp" != "legacy" ] ; then
bf6542c5aa722eb97a0df17e6db46cc884f203bfJason Vincent mounted $mountp - zfs < /etc/mnttab && continue
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienle /sbin/zfs mount $be$mountp
49ca89f51e0242b83f998f16a269dc1982460f02Chad Kienle fi
49ca89f51e0242b83f998f16a269dc1982460f02Chad Kienle done
49ca89f51e0242b83f998f16a269dc1982460f02Chad Kienlefi
49ca89f51e0242b83f998f16a269dc1982460f02Chad Kienle
bdcef189d83ab13d06dde11499a03b16cdb5b432Chad Kienleexit $SMF_EXIT_OK
2312a9d8e5342846988edcd629e1ac56a8b5d4a9Brendan Mmiller