8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / svc / milestone / fs-root
blob9652eaaf94c032f3cfecf1168f34ae9e4f815ab6
1 #!/sbin/sh
3 # CDDL HEADER START
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]
20 # CDDL HEADER END
23 # Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
24 # Copyright 2015 Nexenta Systems, Inc. All rights reserved.
27 # Make sure that the libraries essential to this stage of booting can be found.
28 LD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH
30 libc_mount() {
32 # If there is an optimized libc available in /usr that fits this
33 # processor, mount it on top of the base libc.
35 LIBC_MOE_32=`/usr/bin/moe -32 '/usr/lib/libc/$HWCAP'`
36 if [ -n "$LIBC_MOE_32" ]; then
37 /usr/sbin/mount | egrep -s "^/lib/libc.so.1 on "
38 if [ $? -ne 0 ]; then
39 /usr/sbin/mount -O -F lofs $LIBC_MOE_32 /lib/libc.so.1
43 ARCH64=`isainfo | awk '{print $1}'`
44 LIBC_MOE_64=`/usr/bin/moe -64 /usr/lib/$ARCH64/libc/'$HWCAP'`
45 if [ -n "$LIBC_MOE_64" ]; then
46 /usr/sbin/mount | egrep -s "^/lib/$ARCH64/libc.so.1 on "
47 if [ $? -ne 0 ]; then
48 /usr/sbin/mount -O -F lofs $LIBC_MOE_64 \
49 /lib/$ARCH64/libc.so.1
54 . /lib/svc/share/smf_include.sh
55 . /lib/svc/share/fs_include.sh
58 # Most of the operations in this script are only necessary in the global
59 # zone but due to the way initialization scripts like this are packaged,
60 # it needs to currently exist for all zones.
62 if smf_is_nonglobalzone; then
63 libc_mount
64 exit $SMF_EXIT_OK
68 # Root is already mounted (by the kernel), but still needs to be
69 # checked, possibly remounted and entered into mnttab. First
70 # mount /usr if it is a separate file system. If the file system
71 # type is something other than zfs, mount it read-only. This must
72 # be done first to allow utilities such as fsck and setmnt to
73 # reside on /usr minimizing the space required by the root file
74 # system.
76 readvfstab "/usr" < $vfstab
77 if [ -n "$mountp" ]; then
78 if [ "$fstype" = zfs ]; then
79 mountfs - /usr $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
80 else
82 # Must use -o largefiles here to ensure the
83 # read-only mount does not fail as a result of
84 # having a large file present on /usr. This gives
85 # fsck a chance to fix up the largefiles flag
86 # before we remount /usr read-write.
88 if [ "x$mntopts" = x- ]; then
89 mntopts='ro,largefiles'
90 else
91 checkopt largefiles $mntopts
92 if [ "x$option" != xlargefiles ]; then
93 mntopts="largefiles,$mntopts"
96 checkopt ro $mntopts
97 if [ "x$option" != xro ]; then
98 mntopts="ro,$mntopts"
102 # Requesting logging on a read-only mount
103 # causes errors to be displayed, so remove
104 # "logging" from the list of options for now.
105 # The read-write mount performed later will
106 # specify the logging option if appropriate.
109 checkopt logging $mntopts
110 if [ "x$option" = xlogging ]; then
111 mntopts="$otherops"
115 mountfs -O /usr $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
120 # if we are booted from zfs, the /usr mount probably won't be a
121 # legacy mount. Use the standard zfs mount command instead.
123 readmnttab "/" < /etc/mnttab
124 if [ "$fstype" = zfs ]; then
125 mountp=`/sbin/zfs get -H -o value mountpoint $special/usr 2>/dev/null`
127 # if mountp = /usr, there is a non-legacy mount of /usr
128 # in the boot environment being booted.
130 if [ "x$mountp" = "x/usr" ] ; then
131 /sbin/zfs mount $special/usr
132 if [ $? != 0 ] ; then
133 msg='zfs-mount failed'
134 echo $msg
135 echo "$SMF_FMRI:" $msg >/dev/msglog
136 exit $SMF_EXIT_ERR_FATAL
142 # Also mount /boot now so that things like keymap.sh can access
143 # boot properties through eeprom. Readonly isn't required because
144 # /boot (and other pcfs filesystems) aren't fsck'ed at boot yet.
145 # Also, we don't account for caching /boot as it must be on a local
146 # disk. So what's in vfstab is fine as it stands; just look to see
147 # if it's there and avoid the mount if not.
149 readvfstab "/boot" < $vfstab
151 if [ -n "$mountp" ]; then
152 mountfs - /boot $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
156 # Update kernel driver.conf cache with any additional driver.conf
157 # files found on /usr, and device permissions from /etc/minor_perm.
159 /usr/sbin/devfsadm -I -P
161 libc_mount
163 exit $SMF_EXIT_OK