diff options
author | jpaetzel <jpaetzel@FreeBSD.org> | 2012-05-03 21:53:25 +0000 |
---|---|---|
committer | jpaetzel <jpaetzel@FreeBSD.org> | 2012-05-03 21:53:25 +0000 |
commit | 2ba3a238daeb0647044ce72058c34540cb225fcb (patch) | |
tree | 83d7f8a7be26c9887d08acbcf17637d3d2723cae /usr.sbin | |
parent | b8cdf306fdaa71dc249156aac00fb9e58436c014 (diff) | |
download | FreeBSD-src-2ba3a238daeb0647044ce72058c34540cb225fcb.zip FreeBSD-src-2ba3a238daeb0647044ce72058c34540cb225fcb.tar.gz |
Fix some issues creating zpool mirror / raidz1(2)(3) devices.
Fix issues stamping boot on other ZFS drives, now you can boot after removing
mirror drive.
Submitted by: kmoore
Obtained from: PC-BSD
MFC after: 3 days
Sponsored by: iXsystems
Diffstat (limited to 'usr.sbin')
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh | 69 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-newfs.sh | 44 |
2 files changed, 60 insertions, 53 deletions
diff --git a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh index 3e54df4..35d0f50 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh @@ -50,41 +50,39 @@ get_fs_line_xvars() ACTIVEDEV="${1}" LINE="${2}" - echo $LINE | cut -d ' ' -f 4 | grep -q ' (' 2>/dev/null + echo $LINE | cut -d ' ' -f 4 | grep -q '(' 2>/dev/null + if [ $? -ne 0 ] ; then return ; fi + + # See if we are looking for ZFS specific options + echo $LINE | grep -q '^ZFS' 2>/dev/null if [ $? -eq 0 ] ; then + ZTYPE="NONE" + ZFSVARS="`echo $LINE | cut -d ' ' -f 4-20 |cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - # See if we are looking for ZFS specific options - echo $LINE | grep -q '^ZFS' 2>/dev/null + echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null if [ $? -eq 0 ] ; then - ZTYPE="NONE" - ZFSVARS="`echo $LINE | cut -d ' ' -f 4 |cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - - echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null - if [ $? -eq 0 ] ; then ZTYPE=`echo $ZFSVARS | cut -f1 -d:` ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"` - fi - - # Return the ZFS options - if [ "${ZTYPE}" = "NONE" ] ; then - VAR="${ACTIVEDEV} ${ZFSVARS}" - else - VAR="${ZTYPE} ${ACTIVEDEV} ${ZFSVARS}" - fi - export VAR - return - fi # End of ZFS block + fi - # See if we are looking for UFS specific newfs options - echo $LINE | grep -q '^UFS' 2>/dev/null - if [ $? -eq 0 ] ; then - FSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - VAR="${FSVARS}" - export VAR - return + # Return the ZFS options + if [ "${ZTYPE}" = "NONE" ] ; then + VAR="${ACTIVEDEV} ${ZFSVARS}" + else + VAR="${ZTYPE} ${ACTIVEDEV} ${ZFSVARS}" fi + export VAR + return + fi # End of ZFS block - fi # End of xtra-options block + # See if we are looking for UFS specific newfs options + echo $LINE | grep -q '^UFS' 2>/dev/null + if [ $? -eq 0 ] ; then + FSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" + VAR="${FSVARS}" + export VAR + return + fi # If we got here, set VAR to empty and export export VAR="" @@ -96,8 +94,10 @@ setup_zfs_mirror_parts() { _nZFS="" + ZTYPE="`echo ${1} | awk '{print $1}'`" + # Using mirroring, setup boot partitions on each disk - _mirrline="`echo ${1} | sed 's|mirror ||g'`" + _mirrline="`echo ${1} | sed 's|mirror ||g' | sed 's|raidz1 ||g' | sed 's|raidz2 ||g' | sed 's|raidz3 ||g' | sed 's|raidz ||g'`" for _zvars in $_mirrline do echo "Looping through _zvars: $_zvars" >>${LOGOUT} @@ -107,15 +107,16 @@ setup_zfs_mirror_parts() is_disk "$_zvars" >/dev/null 2>/dev/null if [ $? -eq 0 ] ; then - echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT} + echo "Setting up ZFS disk $_zvars" >>${LOGOUT} init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null - rc_halt "gpart add -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null + rc_halt "gpart add -a 4k -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null + rc_halt "gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${_zvars}" >/dev/null 2>/dev/null _nZFS="$_nZFS ${_zvars}p2" else _nZFS="$_nZFS ${_zvars}" fi done - echo "mirror $2 `echo $_nZFS | tr -s ' '`" + echo "$ZTYPE $2 `echo $_nZFS | tr -s ' '`" } ; # Function which creates a unique label name for the specified mount @@ -290,15 +291,15 @@ setup_gpart_partitions() else get_fs_line_xvars "${_wSlice}${PARTLETTER}" "${STRING}" fi - XTRAOPTS="${VAR}" + XTRAOPTS="$VAR" # Check if using zfs mirror - echo ${XTRAOPTS} | grep -q "mirror" 2>/dev/null + echo ${XTRAOPTS} | grep -q -e "mirror" -e "raidz" if [ $? -eq 0 -a "$FS" = "ZFS" ] ; then if [ "${_pType}" = "gpt" -o "${_pType}" = "gptslice" ] ; then XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}") else - XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}") + XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}${PARTLETTER}") fi fi diff --git a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh index 7be9bf3..1ebf922 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh @@ -44,6 +44,23 @@ setup_zfs_filesystem() sleep 5 sync + # Check if we have multiple zfs mounts specified + for i in `echo ${PARTMNT} | sed 's|,| |g'` + do + # Check if we ended up with needing a zfs bootable partition + if [ "${i}" = "/" -o "${i}" = "/boot" ] + then + if [ "$HAVEBOOT" = "YES" ] ; then continue ; fi + if [ "${PARTGEOM}" = "MBR" ] ; then + # Lets stamp the proper ZFS boot loader + echo_log "Setting up ZFS boot loader support" + rc_halt "dd if=/boot/zfsboot of=${ROOTSLICE} count=1" + rc_halt "dd if=/boot/zfsboot of=${PART}${EXT} skip=1 seek=1024" + fi + fi + done + + # Check if we have some custom zpool arguments and use them if so if [ ! -z "${ZPOOLOPTS}" ] ; then rc_halt "zpool create -m none -f ${ZPOOLNAME} ${ZPOOLOPTS}" @@ -55,23 +72,13 @@ setup_zfs_filesystem() # Disable atime for this zfs partition, speed increase rc_nohalt "zfs set atime=off ${ZPOOLNAME}" - # Check if we have multiple zfs mounts specified + # Check if we need to set a bootable zpool for i in `echo ${PARTMNT} | sed 's|,| |g'` do - # Check if we ended up with needing a zfs bootable partition - if [ "${i}" = "/" -o "${i}" = "/boot" ] - then + if [ "${i}" = "/" -o "${i}" = "/boot" ] ; then if [ "$HAVEBOOT" = "YES" ] ; then continue ; fi - if [ "${PARTGEOM}" = "MBR" ] - then - # Lets stamp the proper ZFS boot loader - echo_log "Setting up ZFS boot loader support" - rc_halt "zpool set bootfs=${ZPOOLNAME} ${ZPOOLNAME}" - rc_halt "zpool export ${ZPOOLNAME}" - rc_halt "dd if=/boot/zfsboot of=${ROOTSLICE} count=1" - rc_halt "dd if=/boot/zfsboot of=${PART}${EXT} skip=1 seek=1024" - rc_halt "zpool import ${ZPOOLNAME}" - fi + echo_log "Stamping zpool as bootfs" + rc_halt "zpool set bootfs=${ZPOOLNAME} ${ZPOOLNAME}" fi done @@ -90,11 +97,6 @@ setup_filesystems() for PART in `ls ${PARTDIR}` do PARTDEV="`echo $PART | sed 's|-|/|g'`" - if [ ! -e "${PARTDEV}" ] - then - exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?" - fi - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" @@ -103,6 +105,10 @@ setup_filesystems() PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 6`" PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d '#' -f 7`" + if [ ! -e "${PARTDEV}" ] ; then + exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?" + fi + # Make sure journaling isn't enabled on this device if [ -e "${PARTDEV}.journal" ] then |