functions-newfs.sh (210701) | functions-newfs.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-newfs.sh 210701 2010-07-31 19:27:43Z imp $ | 26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh 211730 2010-08-24 06:11:46Z imp $ |
27 28# Functions related to disk operations using newfs 29 30 31# Function which performs the ZFS magic 32setup_zfs_filesystem() 33{ 34 PART="$1" --- 41 unchanged lines hidden (view full) --- 76 done 77 78}; 79 80# Runs newfs on all the partiions which we've setup with bsdlabel 81setup_filesystems() 82{ 83 | 27 28# Functions related to disk operations using newfs 29 30 31# Function which performs the ZFS magic 32setup_zfs_filesystem() 33{ 34 PART="$1" --- 41 unchanged lines hidden (view full) --- 76 done 77 78}; 79 80# Runs newfs on all the partiions which we've setup with bsdlabel 81setup_filesystems() 82{ 83 |
84 # Create the keydir 85 rm -rf ${GELIKEYDIR} >/dev/null 2>/dev/null 86 mkdir ${GELIKEYDIR} | 84 # Create the keydir 85 rm -rf ${GELIKEYDIR} >/dev/null 2>/dev/null 86 mkdir ${GELIKEYDIR} |
87 | 87 |
88 # Lets go ahead and read through the saved partitions we created, and determine if we need to run 89 # newfs on any of them 90 for PART in `ls ${PARTDIR}` 91 do 92 if [ ! -e "/dev/${PART}" ] 93 then 94 exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?" 95 fi | 88 # Lets go ahead and read through the saved partitions we created, and determine if we need to run 89 # newfs on any of them 90 for PART in `ls ${PARTDIR}` 91 do 92 if [ ! -e "/dev/${PART}" ] 93 then 94 exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?" 95 fi |
96 | 96 |
97 PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" 98 PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" 99 PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" 100 PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`" 101 PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d ':' -f 5`" 102 PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 6`" | 97 PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" 98 PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" 99 PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" 100 PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`" 101 PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d ':' -f 5`" 102 PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 6`" |
103 | 103 |
104 # Make sure journaling isn't enabled on this device 105 if [ -e "/dev/${PART}.journal" ] 106 then 107 rc_nohalt "gjournal stop -f ${PART}.journal" 108 rc_nohalt "gjournal clear ${PART}" 109 fi | 104 # Make sure journaling isn't enabled on this device 105 if [ -e "/dev/${PART}.journal" ] 106 then 107 rc_nohalt "gjournal stop -f ${PART}.journal" 108 rc_nohalt "gjournal clear ${PART}" 109 fi |
110 | 110 |
111 # Setup encryption if necessary 112 if [ "${PARTENC}" = "ON" -a "${PARTFS}" != "SWAP" ] 113 then 114 echo_log "Creating geli provider for ${PART}" 115 rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1" 116 rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key /dev/${PART}" 117 rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key /dev/${PART}" | 111 # Setup encryption if necessary 112 if [ "${PARTENC}" = "ON" -a "${PARTFS}" != "SWAP" ] 113 then 114 echo_log "Creating geli provider for ${PART}" 115 rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1" 116 rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key /dev/${PART}" 117 rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key /dev/${PART}" |
118 | 118 |
119 EXT=".eli" 120 else 121 # No Encryption 122 EXT="" 123 fi | 119 EXT=".eli" 120 else 121 # No Encryption 122 EXT="" 123 fi |
124 | 124 |
125 case ${PARTFS} in 126 UFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}" 127 sleep 2 128 rc_halt "newfs /dev/${PART}${EXT}" 129 sleep 2 130 rc_halt "sync" 131 rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" 132 rc_halt "sync" | 125 case ${PARTFS} in 126 UFS) 127 echo_log "NEWFS: /dev/${PART} - ${PARTFS}" 128 sleep 2 129 rc_halt "newfs /dev/${PART}${EXT}" 130 sleep 2 131 rc_halt "sync" 132 rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" 133 rc_halt "sync" |
133 | 134 |
134 # Set flag that we've found a boot partition 135 if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then 136 HAVEBOOT="YES" 137 fi 138 sleep 2 139 ;; 140 UFS+S) echo_log "NEWFS: /dev/${PART} - ${PARTFS}" 141 sleep 2 142 rc_halt "newfs -U /dev/${PART}${EXT}" 143 sleep 2 144 rc_halt "sync" 145 rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" 146 rc_halt "sync" 147 # Set flag that we've found a boot partition 148 if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then 149 HAVEBOOT="YES" 150 fi 151 sleep 2 152 ;; 153 UFS+J) echo_log "NEWFS: /dev/${PART} - ${PARTFS}" 154 sleep 2 155 rc_halt "newfs /dev/${PART}${EXT}" 156 sleep 2 157 rc_halt "gjournal label -f /dev/${PART}${EXT}" 158 sleep 2 159 rc_halt "newfs -O 2 -J /dev/${PART}${EXT}.journal" 160 sleep 2 161 rc_halt "sync" 162 rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" 163 rc_halt "sync" 164 # Set flag that we've found a boot partition 165 if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then 166 HAVEBOOT="YES" 167 fi 168 sleep 2 169 ;; 170 ZFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}" 171 setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}" "${PARTXTRAOPTS}" 172 ;; 173 SWAP) rc_halt "sync" 174 rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" 175 rc_halt "sync" 176 sleep 2 177 ;; 178 *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;; 179 esac | 135 # Set flag that we've found a boot partition 136 if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then 137 HAVEBOOT="YES" 138 fi 139 sleep 2 140 ;; |
180 | 141 |
181 done | 142 UFS+S) 143 echo_log "NEWFS: /dev/${PART} - ${PARTFS}" 144 sleep 2 145 rc_halt "newfs -U /dev/${PART}${EXT}" 146 sleep 2 147 rc_halt "sync" 148 rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" 149 rc_halt "sync" 150 # Set flag that we've found a boot partition 151 if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then 152 HAVEBOOT="YES" 153 fi 154 sleep 2 155 ;; 156 157 UFS+J) 158 echo_log "NEWFS: /dev/${PART} - ${PARTFS}" 159 sleep 2 160 rc_halt "newfs /dev/${PART}${EXT}" 161 sleep 2 162 rc_halt "gjournal label -f /dev/${PART}${EXT}" 163 sleep 2 164 rc_halt "newfs -O 2 -J /dev/${PART}${EXT}.journal" 165 sleep 2 166 rc_halt "sync" 167 rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" 168 rc_halt "sync" 169 # Set flag that we've found a boot partition 170 if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then 171 HAVEBOOT="YES" 172 fi 173 sleep 2 174 ;; 175 176 ZFS) 177 echo_log "NEWFS: /dev/${PART} - ${PARTFS}" 178 setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}" "${PARTXTRAOPTS}" 179 ;; 180 181 SWAP) 182 rc_halt "sync" 183 rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" 184 rc_halt "sync" 185 sleep 2 186 ;; 187 188 *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;; 189 esac 190 191 done |
182}; | 192}; |