Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Sep 2012 14:59:53 +0000 (UTC)
From:      Josh Paetzel <jpaetzel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r240165 - head/usr.sbin/pc-sysinstall/backend
Message-ID:  <201209061459.q86Exr56038506@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jpaetzel
Date: Thu Sep  6 14:59:53 2012
New Revision: 240165
URL: http://svn.freebsd.org/changeset/base/240165

Log:
  Add TRIM support, enabled by default.
  Fix a bug installing components from a localPath.
  Allow autosizing of any partition, not just the last partition.
  Adjust how ZFS is laid out to work with Boot Environments.
  
  Submitted by:	kmoore
  Obtained from:	PC-BSD
  MFC after:	3 days

Modified:
  head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
  head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
  head/usr.sbin/pc-sysinstall/backend/functions-disk.sh
  head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh
  head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
  head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh

Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh	Thu Sep  6 13:54:01 2012	(r240164)
+++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh	Thu Sep  6 14:59:53 2012	(r240165)
@@ -164,6 +164,38 @@ gen_glabel_name()
   export VAL="${NAME}${NUM}" 
 };
 
+# Function to determine the size we can safely use when 0 is specified
+get_autosize()
+{
+  # Disk tag to look for
+  dTag="$1"
+
+  # Total MB Avail
+  get_disk_mediasize_mb "$2"
+  local _aSize=$VAL
+
+  while read line
+  do
+    # Check for data on this slice
+    echo $line | grep -q "^${_dTag}-part=" 2>/dev/null
+    if [ $? -ne 0 ] ; then continue ; fi
+
+    get_value_from_string "${line}"
+    STRING="$VAL"
+
+    # Get the size of this partition
+    SIZE=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2` 
+    if [ $SIZE -eq 0 ] ; then continue ; fi
+    _aSize=`expr $_aSize - $SIZE`
+  done <${CFGF}
+
+  # Pad the size a bit
+  _aSize=`expr $_aSize - 2`
+
+  VAL="$_aSize"
+  export VAL
+};
+
 # Function to setup partitions using gpart
 setup_gpart_partitions()
 {
@@ -173,6 +205,7 @@ setup_gpart_partitions()
   local _sNum="$4"
   local _pType="$5"
   FOUNDPARTS="1"
+  USEDAUTOSIZE=0
 
   # Lets read in the config file now and setup our partitions
   if [ "${_pType}" = "gpt" ] ; then
@@ -245,7 +278,15 @@ setup_gpart_partitions()
 
       if [ "$SIZE" = "0" ]
       then
-        SOUT=""
+	if [ $USEDAUTOSIZE -eq 1 ] ; then
+          exit_err "ERROR: You can not have two partitions with a size of 0 specified!"
+	fi
+        case ${_pType} in
+	  gpt|apm) get_autosize "${_dTag}" "$_pDisk" ;;
+	        *) get_autosize "${_dTag}" "$_wSlice" ;;
+        esac
+        SOUT="-s ${VAL}M"
+	USEDAUTOSIZE=1
       else
         SOUT="-s ${SIZE}M"
       fi

Modified: head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh	Thu Sep  6 13:54:01 2012	(r240164)
+++ head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh	Thu Sep  6 14:59:53 2012	(r240165)
@@ -49,7 +49,7 @@ zfs_cleanup_unmount()
           # Creating a dedicated "/boot" partition
           cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q "vfs.root.mountfrom=" 2>/dev/null
           if [ $? -ne 0 ] ; then
-            echo "vfs.root.mountfrom=\"zfs:${ZPOOLNAME}\"" >> ${FSMNT}/boot/loader.conf
+            echo "vfs.root.mountfrom=\"zfs:${ZPOOLNAME}/ROOT/default\"" >> ${FSMNT}/boot/loader.conf
           fi
           export FOUNDZFSROOT="${ZPOOLNAME}"
         fi
@@ -195,8 +195,8 @@ setup_fstab()
     if [ $? -eq 0 ] ; then
       if [ "${PARTFS}" = "ZFS" ] ; then
         ROOTFSTYPE="zfs"
-        XPOOLNAME=$(get_zpool_name "${PARTDEV}")
-        ROOTFS="${ZPOOLNAME}"
+        ZPOOLNAME=$(get_zpool_name "${PARTDEV}")
+        ROOTFS="${ZPOOLNAME}/ROOT/default"
       else
         ROOTFS="${DEVICE}"
         ROOTFSTYPE="ufs"

Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh	Thu Sep  6 13:54:01 2012	(r240164)
+++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh	Thu Sep  6 14:59:53 2012	(r240165)
@@ -224,6 +224,15 @@ get_disk_mediasize()
   export VAL="${mediasize}"
 };
 
+# Function which returns a target disks mediasize in megabytes
+get_disk_mediasize_mb()
+{
+  mediasize=`diskinfo -v ${1} | grep "# mediasize in bytes" | tr -s ' ' | cut -f 2`
+  mediasize=`expr $mediasize / 1024`
+  mediasize=`expr $mediasize / 1024`
+  export VAL="${mediasize}"
+};
+
 # Function to delete all gparts before starting an install
 delete_all_gpart()
 {

Modified: head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh	Thu Sep  6 13:54:01 2012	(r240164)
+++ head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh	Thu Sep  6 14:59:53 2012	(r240165)
@@ -71,8 +71,16 @@ copy_component()
         fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0"
         RESULT="$?"
        ;;
-
-      sftp) ;;
+    local)
+        get_value_from_cfg localPath
+        if [ -z "$VAL" ]; then
+          exit_err "Install medium was set to local, but no localPath was provided!"
+        fi
+        LOCALPATH=$VAL
+        cp ${LOCALPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE} \
+		  ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
+	RESULT="$?"
+       ;;
     esac
 
     if [ "${RESULT}" != "0" ]

Modified: head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh	Thu Sep  6 13:54:01 2012	(r240164)
+++ head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh	Thu Sep  6 14:59:53 2012	(r240165)
@@ -81,15 +81,34 @@ mount_partition()
       done
 
       if [ "${ZMNT}" = "/" ] ; then
-        ZNAME=""
+	# If creating ZFS / dataset, give it name that beadm works with
+        ZNAME="/ROOT/default"
+        ZMKMNT=""
+        echo_log "zfs create $zcopt -p ${ZPOOLNAME}/ROOT"
+        rc_halt "zfs create $zcopt -p ${ZPOOLNAME}/ROOT"
+        echo_log "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
+        rc_halt "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
       else
         ZNAME="${ZMNT}"
+        ZMKMNT="${ZMNT}"
         echo_log "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
         rc_halt "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
       fi
       sleep 2
       if [ -z "$zcopt" ] ; then
-        rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
+        rc_halt "zfs set mountpoint=${FSMNT}${ZMKMNT} ${ZPOOLNAME}${ZNAME}"
+      fi
+
+      # Do we need to make this / zfs dataset bootable?
+      if [ "$ZMNT" = "/" ] ; then
+        echo_log "Stamping ${ZPOOLNAME}/ROOT/default as bootfs"
+        rc_halt "zpool set bootfs=${ZPOOLNAME}/ROOT/default ${ZPOOLNAME}"
+      fi
+
+      # Do we need to make this /boot zfs dataset bootable?
+      if [ "$ZMNT" = "/boot" ] ; then
+        echo_log "Stamping ${ZPOOLNAME}${ZMNT} as bootfs"
+        rc_halt "zpool set bootfs=${ZPOOLNAME}${ZMNT} ${ZPOOLNAME}"
       fi
 
       # If no ZFS options, we can skip

Modified: head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh	Thu Sep  6 13:54:01 2012	(r240164)
+++ head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh	Thu Sep  6 14:59:53 2012	(r240165)
@@ -72,16 +72,6 @@ setup_zfs_filesystem()
   # Disable atime for this zfs partition, speed increase
   rc_nohalt "zfs set atime=off ${ZPOOLNAME}"
 
-  # Check if we need to set a bootable zpool
-  for i in `echo ${PARTMNT} | sed 's|,| |g'`
-  do
-    if [ "${i}" = "/" -o "${i}" = "/boot" ] ; then
-      if [ "$HAVEBOOT" = "YES" ] ; then continue ; fi
-      echo_log "Stamping zpool as bootfs" 
-      rc_halt "zpool set bootfs=${ZPOOLNAME} ${ZPOOLNAME}"
-    fi
-  done 
-
 };
 
 # Runs newfs on all the partiions which we've setup with bsdlabel
@@ -144,7 +134,7 @@ setup_filesystems()
       UFS)
         echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
         sleep 2
-        rc_halt "newfs ${PARTXTRAOPTS} ${PARTDEV}${EXT}"
+        rc_halt "newfs -t ${PARTXTRAOPTS} ${PARTDEV}${EXT}"
         sleep 2
         rc_halt "sync"
         rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"
@@ -160,7 +150,7 @@ setup_filesystems()
       UFS+S)
         echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
         sleep 2
-        rc_halt "newfs ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}"
+        rc_halt "newfs -t ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}"
         sleep 2
         rc_halt "sync"
         rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"
@@ -175,7 +165,7 @@ setup_filesystems()
       UFS+SUJ)
         echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
         sleep 2
-        rc_halt "newfs ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}"
+        rc_halt "newfs -t ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}"
         sleep 2
         rc_halt "sync"
         rc_halt "tunefs -j enable ${PARTDEV}${EXT}"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209061459.q86Exr56038506>