svn commit: r233224 - stable/9/usr.sbin/pc-sysinstall/backend

Josh Paetzel jpaetzel at FreeBSD.org
Mon Mar 19 23:20:52 UTC 2012


Author: jpaetzel
Date: Mon Mar 19 23:20:52 2012
New Revision: 233224
URL: http://svn.freebsd.org/changeset/base/233224

Log:
  MFC: 232899
  
  Add the ability to use a varity of ZFS dataset options.
  While here fix a bug causing zpools with /tmp mount-points to fail
  
  Submitted by:	kmoore
  Obtained from:	PC-BSD

Modified:
  stable/9/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
  stable/9/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
  stable/9/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
  stable/9/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
  stable/9/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
Directory Properties:
  stable/9/usr.sbin/pc-sysinstall/   (props changed)

Modified: stable/9/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
==============================================================================
--- stable/9/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh	Mon Mar 19 23:17:26 2012	(r233223)
+++ stable/9/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh	Mon Mar 19 23:20:52 2012	(r233224)
@@ -50,14 +50,14 @@ get_fs_line_xvars()
   ACTIVEDEV="${1}"
   LINE="${2}"
 
-  echo $LINE | grep -q ' (' 2>/dev/null
+  echo $LINE | cut -d ' ' -f 4 | grep -q ' (' 2>/dev/null
   if [ $? -eq 0 ] ; then
 
     # 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 2- | cut -d ')' -f 1 | xargs`"
+      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)?|spare|log|cache):" 2>/dev/null
 	  if [ $? -eq 0 ] ; then
@@ -126,9 +126,9 @@ gen_glabel_name()
   NUM="0"
   MAXNUM="20"
 
-  # Check if we are doing /, and rename it
-  if [ "$MOUNT" = "/" ]
-  then
+  if [ "$TYPE" = "ZFS" ] ; then
+    NAME="zpool"
+  elif [ "$MOUNT" = "/" ] ; then
     NAME="rootfs"
   else
     # If doing a swap partition, also rename it
@@ -341,7 +341,7 @@ setup_gpart_partitions()
       # Save this data to our partition config dir
       if [ "${_pType}" = "gpt" ] ; then
 	_dFile="`echo $_pDisk | sed 's|/|-|g'`"
-        echo "${FS}:${MNT}:${ENC}:${PLABEL}:GPT:${XTRAOPTS}" >${PARTDIR}/${_dFile}p${CURPART}
+        echo "${FS}#${MNT}#${ENC}#${PLABEL}#GPT#${XTRAOPTS}" >${PARTDIR}/${_dFile}p${CURPART}
 
         # Clear out any headers
         sleep 2
@@ -354,7 +354,7 @@ setup_gpart_partitions()
       else
 	# MBR Partition or GPT slice
 	_dFile="`echo $_wSlice | sed 's|/|-|g'`"
-        echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${_dFile}${PARTLETTER}
+        echo "${FS}#${MNT}#${ENC}#${PLABEL}#MBR#${XTRAOPTS}#${IMAGE}" >${PARTDIR}/${_dFile}${PARTLETTER}
         # Clear out any headers
         sleep 2
         dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 2>/dev/null
@@ -409,7 +409,7 @@ setup_gpart_partitions()
       fi
 
       # Found our flag to commit this label setup, check that we found at least 1 partition
-      if [ "${CURPART}" = "2" ] ; then
+      if [ "${CURPART}" = "1" ] ; then
         exit_err "ERROR: commitDiskLabel was called without any partition entries for it!"
       fi
 

Modified: stable/9/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
==============================================================================
--- stable/9/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh	Mon Mar 19 23:17:26 2012	(r233223)
+++ stable/9/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh	Mon Mar 19 23:20:52 2012	(r233224)
@@ -34,8 +34,8 @@ zfs_cleanup_unmount()
   for PART in `ls ${PARTDIR}`
   do
     PARTDEV=`echo $PART | sed 's|-|/|g'`
-    PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
-    PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+    PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+    PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
     ZPOOLNAME=$(get_zpool_name "${PARTDEV}")
 
     if [ "$PARTFS" = "ZFS" ]
@@ -84,9 +84,9 @@ zfs_cleanup_unmount()
   for PART in `ls ${PARTDIR}`
   do
     PARTDEV=`echo $PART | sed 's|-|/|g'`
-    PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
-    PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
-    PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+    PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+    PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+    PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
     ZPOOLNAME=$(get_zpool_name "${PARTDEV}")
 
     if [ "$PARTFS" = "ZFS" ]
@@ -101,17 +101,20 @@ zfs_cleanup_unmount()
       # Check if we have multiple zfs mounts specified
       for ZMNT in `echo ${PARTMNT} | sed 's|,| |g'`
       do
+	ZMNT="`echo $ZMNT | cut -d '(' -f 1`"
         PARTMNTREV="${ZMNT} ${PARTMNTREV}"
       done
 
       for ZMNT in ${PARTMNTREV}
       do
-        if [ "${ZMNT}" != "/" ]
-        then
-          rc_halt "zfs set mountpoint=${ZMNT} ${ZPOOLNAME}${ZMNT}"
+        if [ "${ZMNT}" = "/" ] ; then continue ; fi
+        # Some ZFS like /swap aren't mounted, and dont need unmounting
+        mount | grep -q "${FSMNT}${ZMNT}"
+	if [ $? -eq 0 ] ; then
           rc_halt "zfs unmount ${ZPOOLNAME}${ZMNT}"
-          sleep 2
+          rc_halt "zfs set mountpoint=${ZMNT} ${ZPOOLNAME}${ZMNT}"
         fi
+        sleep 2
       done
     fi
   done
@@ -154,10 +157,10 @@ setup_fstab()
   for PART in `ls ${PARTDIR}`
   do
     PARTDEV=`echo $PART | sed 's|-|/|g'`
-    PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
-    PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
-    PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
-    PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
+    PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+    PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+    PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
+    PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d '#' -f 4`"
 
     # Unset EXT
     EXT=""

Modified: stable/9/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
==============================================================================
--- stable/9/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh	Mon Mar 19 23:17:26 2012	(r233223)
+++ stable/9/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh	Mon Mar 19 23:20:52 2012	(r233224)
@@ -57,24 +57,52 @@ mount_partition()
     # Check if we have multiple zfs mounts specified
     for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'`
     do
+      # Check for any ZFS specific mount options
+      ZMNTOPTS="`echo $ZMNT | cut -d '(' -f 2 | cut -d ')' -f 1`" 
+      if [ "$ZMNTOPTS" = "$ZMNT" ] ; then ZMNTOPTS="" ; fi
+
+      # Reset ZMNT with options removed
+      ZMNT="`echo $ZMNT | cut -d '(' -f 1`"
+
       # First make sure we create the mount point
       if [ ! -d "${FSMNT}${ZMNT}" ] ; then
         mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT}
       fi
 
+      # Check for any volsize args
+      zcopt=""
+      for ZOPT in `echo $ZMNTOPTS | sed 's/|/ /g'`
+      do
+        echo "$ZOPT" | grep -q volsize
+        if [ $? -eq 0 ] ; then
+          volsize=`echo $ZOPT | cut -d '=' -f 2`
+          zcopt="-V $volsize"
+        fi
+      done
+
       if [ "${ZMNT}" = "/" ] ; then
         ZNAME=""
       else
         ZNAME="${ZMNT}"
-        echo_log "zfs create -p ${ZPOOLNAME}${ZNAME}"
-        rc_halt "zfs create -p ${ZPOOLNAME}${ZNAME}"
+        echo_log "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
+        rc_halt "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
       fi
       sleep 2
-      rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
+      if [ -z "$zcopt" ] ; then
+        rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
+      fi
+
+      # If no ZFS options, we can skip
+      if [ -z "$ZMNTOPTS" ] ; then continue ; fi
 
-      # Disable atime for this zfs partition, speed increase
-      rc_nohalt "zfs set atime=off ${ZPOOLNAME}${ZNAME}"
-    done 
+      # Parse any ZFS options now
+      for ZOPT in `echo $ZMNTOPTS | sed 's/|/ /g'`
+      do
+        echo "$ZOPT" | grep -q volsize
+        if [ $? -eq 0 ] ; then continue ; fi
+        rc_halt "zfs set $ZOPT ${ZPOOLNAME}${ZNAME}"
+      done
+    done # End of adding ZFS mounts
 
   else
     # If we are not on ZFS, lets do the mount now
@@ -107,9 +135,9 @@ mount_all_filesystems()
       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`"
+    PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+    PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+    PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
 
     if [ "${PARTENC}" = "ON" ]
     then
@@ -144,9 +172,9 @@ mount_all_filesystems()
       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`"
+    PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+    PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+    PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
 
     if [ "${PARTENC}" = "ON" ]
     then

Modified: stable/9/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
==============================================================================
--- stable/9/usr.sbin/pc-sysinstall/backend/functions-newfs.sh	Mon Mar 19 23:17:26 2012	(r233223)
+++ stable/9/usr.sbin/pc-sysinstall/backend/functions-newfs.sh	Mon Mar 19 23:20:52 2012	(r233224)
@@ -95,13 +95,13 @@ setup_filesystems()
       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`"
-    PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
-    PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d ':' -f 5`"
-    PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 6`"
-    PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d ':' -f 7`"
+    PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+    PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+    PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
+    PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d '#' -f 4`"
+    PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d '#' -f 5`"
+    PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 6`"
+    PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d '#' -f 7`"
 
     # Make sure journaling isn't enabled on this device
     if [ -e "${PARTDEV}.journal" ]

Modified: stable/9/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
==============================================================================
--- stable/9/usr.sbin/pc-sysinstall/backend/functions-unmount.sh	Mon Mar 19 23:17:26 2012	(r233223)
+++ stable/9/usr.sbin/pc-sysinstall/backend/functions-unmount.sh	Mon Mar 19 23:20:52 2012	(r233224)
@@ -72,10 +72,10 @@ unmount_all_filesystems()
   for PART in `ls ${PARTDIR}`
   do
     PARTDEV=`echo $PART | sed 's|-|/|g'`    
-    PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
-    PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
-    PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
-    PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
+    PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+    PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+    PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
+    PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d '#' -f 4`"
 
     if [ "${PARTENC}" = "ON" ]
     then
@@ -168,9 +168,9 @@ unmount_all_filesystems_failure()
     for PART in `ls ${PARTDIR}`
     do
       PARTDEV=`echo $PART | sed 's|-|/|g'` 
-      PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
-      PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
-      PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+      PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+      PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+      PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
 
       if [ "${PARTFS}" = "SWAP" ]
       then


More information about the svn-src-all mailing list