Deleted Added
full compact
functions-mountdisk.sh (209552) functions-mountdisk.sh (211730)
1#!/bin/sh
2#-
3# Copyright (c) 2010 iXsystems, Inc. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
1#!/bin/sh
2#-
3# Copyright (c) 2010 iXsystems, Inc. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh 209552 2010-06-27 16:46:11Z imp $
26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh 211730 2010-08-24 06:11:46Z imp $
27
28# Functions related mounting the newly formatted disk partitions
29
30# Mounts all the specified partition to the mount-point
31mount_partition()
32{
33 if [ -z "${1}" -o -z "${2}" -o -z "${3}" ]
34 then

--- 12 unchanged lines hidden (view full) ---

47 else
48 MNTFLAGS="-o rw,${MNTFLAGS}"
49 fi
50
51
52 #We are on ZFS, lets setup this mount-point
53 if [ "${PARTFS}" = "ZFS" ]
54 then
27
28# Functions related mounting the newly formatted disk partitions
29
30# Mounts all the specified partition to the mount-point
31mount_partition()
32{
33 if [ -z "${1}" -o -z "${2}" -o -z "${3}" ]
34 then

--- 12 unchanged lines hidden (view full) ---

47 else
48 MNTFLAGS="-o rw,${MNTFLAGS}"
49 fi
50
51
52 #We are on ZFS, lets setup this mount-point
53 if [ "${PARTFS}" = "ZFS" ]
54 then
55 ZPOOLNAME=$(get_zpool_name "${PART}")
55 ZPOOLNAME=$(get_zpool_name "${PART}")
56
56
57 # Check if we have multiple zfs mounts specified
58 for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'`
59 do
60 # First make sure we create the mount point
61 if [ ! -d "${FSMNT}${ZMNT}" ] ; then
62 mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT}
63 fi
57 # Check if we have multiple zfs mounts specified
58 for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'`
59 do
60 # First make sure we create the mount point
61 if [ ! -d "${FSMNT}${ZMNT}" ] ; then
62 mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT}
63 fi
64
64
65 if [ "${ZMNT}" = "/" ] ; then
66 ZNAME=""
67 else
68 ZNAME="${ZMNT}"
69 echo_log "zfs create -p ${ZPOOLNAME}${ZNAME}"
70 rc_halt "zfs create -p ${ZPOOLNAME}${ZNAME}"
71 fi
72 sleep 2
73 rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
65 if [ "${ZMNT}" = "/" ] ; then
66 ZNAME=""
67 else
68 ZNAME="${ZMNT}"
69 echo_log "zfs create -p ${ZPOOLNAME}${ZNAME}"
70 rc_halt "zfs create -p ${ZPOOLNAME}${ZNAME}"
71 fi
72 sleep 2
73 rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
74
74
75 # Disable atime for this zfs partition, speed increase
76 rc_nohalt "zfs set atime=off ${ZPOOLNAME}${ZNAME}"
77 done
75 # Disable atime for this zfs partition, speed increase
76 rc_nohalt "zfs set atime=off ${ZPOOLNAME}${ZNAME}"
77 done
78
79 else
78
79 else
80 # If we are not on ZFS, lets do the mount now
80 # If we are not on ZFS, lets do the mount now
81 # First make sure we create the mount point
82 if [ ! -d "${FSMNT}${MNTPOINT}" ]
83 then
84 mkdir -p ${FSMNT}${MNTPOINT} >>${LOGOUT} 2>>${LOGOUT}
85 fi
86
87 echo_log "mount ${MNTFLAGS} /dev/${PART} -> ${FSMNT}${MNTPOINT}"
88 sleep 2
89 rc_halt "mount ${MNTFLAGS} /dev/${PART} ${FSMNT}${MNTPOINT}"
90 fi
91
92};
93
94# Mounts all the new file systems to prepare for installation
95mount_all_filesystems()
96{
81 # First make sure we create the mount point
82 if [ ! -d "${FSMNT}${MNTPOINT}" ]
83 then
84 mkdir -p ${FSMNT}${MNTPOINT} >>${LOGOUT} 2>>${LOGOUT}
85 fi
86
87 echo_log "mount ${MNTFLAGS} /dev/${PART} -> ${FSMNT}${MNTPOINT}"
88 sleep 2
89 rc_halt "mount ${MNTFLAGS} /dev/${PART} ${FSMNT}${MNTPOINT}"
90 fi
91
92};
93
94# Mounts all the new file systems to prepare for installation
95mount_all_filesystems()
96{
97 # Make sure our mount point exists
98 mkdir -p ${FSMNT} >/dev/null 2>/dev/null
97 # Make sure our mount point exists
98 mkdir -p ${FSMNT} >/dev/null 2>/dev/null
99
99
100 # First lets find and mount the / partition
101 #########################################################
102 for PART in `ls ${PARTDIR}`
103 do
104 if [ ! -e "/dev/${PART}" ]
105 then
106 exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
107 fi
100 # First lets find and mount the / partition
101 #########################################################
102 for PART in `ls ${PARTDIR}`
103 do
104 if [ ! -e "/dev/${PART}" ]
105 then
106 exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
107 fi
108
109 PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
110 PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
111 PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
112
113 if [ "${PARTENC}" = "ON" ]
114 then
115 EXT=".eli"
116 else
117 EXT=""
118 fi
119
120 # Check for root partition for mounting, including ZFS "/,/usr" type
121 echo "$PARTMNT" | grep "/," >/dev/null
122 if [ "$?" = "0" -o "$PARTMNT" = "/" ]
123 then
124 case ${PARTFS} in
108
109 PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
110 PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
111 PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
112
113 if [ "${PARTENC}" = "ON" ]
114 then
115 EXT=".eli"
116 else
117 EXT=""
118 fi
119
120 # Check for root partition for mounting, including ZFS "/,/usr" type
121 echo "$PARTMNT" | grep "/," >/dev/null
122 if [ "$?" = "0" -o "$PARTMNT" = "/" ]
123 then
124 case ${PARTFS} in
125 UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
126 ;;
127 UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
128 ;;
129 UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime"
130 ;;
131 ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT}
132 ;;
133 *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
125 UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
126 UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
127 UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;;
128 ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
129 *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
134 esac
130 esac
135
136 fi
131 fi
137
138 done
132 done
139
133
140 # Now that we've mounted "/" lets do any other remaining mount-points
141 ##################################################################
142 for PART in `ls ${PARTDIR}`
143 do
144 if [ ! -e "/dev/${PART}" ]
145 then
146 exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
147 fi
134 # Now that we've mounted "/" lets do any other remaining mount-points
135 ##################################################################
136 for PART in `ls ${PARTDIR}`
137 do
138 if [ ! -e "/dev/${PART}" ]
139 then
140 exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
141 fi
148
142
149 PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
150 PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
151 PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
143 PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
144 PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
145 PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
152
146
153 if [ "${PARTENC}" = "ON" ]
154 then
155 EXT=".eli"
156 else
157 EXT=""
158 fi
147 if [ "${PARTENC}" = "ON" ]
148 then
149 EXT=".eli"
150 else
151 EXT=""
152 fi
159
153
160 # Check if we've found "/" again, don't need to mount it twice
161 echo "$PARTMNT" | grep "/," >/dev/null
162 if [ "$?" != "0" -a "$PARTMNT" != "/" ]
163 then
154 # Check if we've found "/" again, don't need to mount it twice
155 echo "$PARTMNT" | grep "/," >/dev/null
156 if [ "$?" != "0" -a "$PARTMNT" != "/" ]
157 then
164 case ${PARTFS} in
158 case ${PARTFS} in
165 UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
166 ;;
167 UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
168 ;;
169 UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime"
170 ;;
171 ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT}
172 ;;
173 SWAP) # Lets enable this swap now
174 if [ "$PARTENC" = "ON" ]
175 then
176 echo_log "Enabling encrypted swap on /dev/${PART}"
177 rc_halt "geli onetime -d -e 3des ${PART}"
178 sleep 5
179 rc_halt "swapon /dev/${PART}.eli"
180 else
181 echo_log "swapon ${PART}"
182 sleep 5
183 rc_halt "swapon /dev/${PART}"
184 fi
185 ;;
159 UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
160 UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
161 UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;;
162 ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
163 SWAP)
164 # Lets enable this swap now
165 if [ "$PARTENC" = "ON" ]
166 then
167 echo_log "Enabling encrypted swap on /dev/${PART}"
168 rc_halt "geli onetime -d -e 3des ${PART}"
169 sleep 5
170 rc_halt "swapon /dev/${PART}.eli"
171 else
172 echo_log "swapon ${PART}"
173 sleep 5
174 rc_halt "swapon /dev/${PART}"
175 fi
176 ;;
186 *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
177 *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
187 esac
188 fi
189 done
178 esac
179 fi
180 done
190};
181};