[PC-BSD Commits] r6307 - pcbsd/trunk/pc-sysinstall/backend

svn at pcbsd.org svn at pcbsd.org
Fri Feb 26 13:10:30 PST 2010


Author: kris
Date: 2010-02-26 13:10:30 -0800 (Fri, 26 Feb 2010)
New Revision: 6307

Modified:
   pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh
   pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.sh
   pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
   pcbsd/trunk/pc-sysinstall/backend/functions-localize.sh
   pcbsd/trunk/pc-sysinstall/backend/functions-mountdisk.sh
   pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh
   pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh
Log:

Large update to pc-sysinstall, now when doing a full-disk install, we use GPT / EFI partitioning, which lets
us blow past the 2TB barrier, and also increases the number of partitions we can have. 

Also, while where here, add support for specifying multiple mount-points for a zpool partition, which
means we can now use the entire disk as one zpool, but within it create all the various zfs mount-points
which the user can then play with post-install



Modified: pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh	2010-02-26 19:30:57 UTC (rev 6306)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh	2010-02-26 21:10:30 UTC (rev 6307)
@@ -47,22 +47,12 @@
   export VAL
 }
 
-# Reads through the config and sets up a BSDLabel for the given slice
-populate_disk_label()
+# Function to setup / stamp a legacy MBR bsdlabel
+setup_mbr_partitions()
 {
-  if [ ! -z "${1}" ]
-  then
-    WRKSLICE="${1}"
-  else
-    exit_err "ERROR: populate_disk_label() called without argument!"
-  fi
 
-  if [ -e "${SLICECFGDIR}/${WRKSLICE}" ]
-  then
-    DISKTAG="`cat ${SLICECFGDIR}/${WRKSLICE}`"
-  else
-    exit_err "ERROR: Missing SLICETAG data. This shouldn't happen - please let the developers know"
-  fi
+  DISKTAG="$1"
+  WRKSLICE="$2"
 
   # Lets setup the BSDLABEL
   BSDLABEL="${TMPDIR}/bsdLabel-${WRKSLICE}"
@@ -143,11 +133,12 @@
         fi
 
         # Check if we found a valid root partition
-        if [ "${MNT}" = "/" ]
-        then
-          FOUNDROOT="0" 
-          export FOUNDROOT
-        fi
+        for CHECKMNT in `echo ${MNT} | sed 's|,| |g'`
+        do
+          if [ "${CHECKMNT}" = "/" ] ; then
+            FOUNDROOT="0" ; export FOUNDROOT
+          fi
+        done 
       else
         if [ "$FS" = "SWAP" ]
         then
@@ -162,7 +153,7 @@
       PLABEL="${VAL}"
 
       # Save this data to our partition config dir
-      echo "${FS}:${MNT}:${ENC}:${PLABEL}" >${PARTDIR}/${WRKSLICE}${PARTLETTER}
+      echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR" >${PARTDIR}/${WRKSLICE}${PARTLETTER}
 
       # This partition letter is used, get the next one
       case ${PARTLETTER} in
@@ -203,6 +194,171 @@
   done <${CFGF}
 };
 
+# Function to setup partitions using gpt
+setup_gpt_partitions()
+{
+  DISKTAG="$1"
+  DISK="$2"
+
+  # Lets read in the config file now and setup our GPT partitions
+  CURPART="2"
+  while read line
+  do
+    # Check for data on this slice
+    echo $line | grep "^${DISKTAG}-part=" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ]
+    then
+      FOUNDPARTS="0"
+      # Found a slice- entry, lets get the slice info
+      get_value_from_string "${line}"
+      STRING="$VAL"
+
+      # We need to split up the string now, and pick out the variables
+      FS=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 1` 
+      SIZE=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2` 
+      MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 3` 
+
+      # Check if we have a .eli extension on this FS
+      echo ${FS} | grep ".eli" >/dev/null 2>/dev/null
+      if [ "$?" = "0" ]
+      then
+        FS="`echo ${FS} | cut -d '.' -f 1`"
+        ENC="ON"
+      else
+        ENC="OFF"
+      fi
+
+      # Check if the user tried to setup / as an encrypted partition
+      if [ "${MNT}" = "/" -a "${ENC}" = "ON" ]
+      then
+        exit_err "ERROR: Encrypted root partitions are not supported at this time."
+      fi
+          
+      # Now check that these values are sane
+      case $FS in
+       UFS|UFS+S|UFS+J|ZFS|SWAP) ;;
+       *) exit_err "ERROR: Invalid file system specified on $line" ;;
+      esac
+
+      # Check that we have a valid size number
+      expr $SIZE + 1 >/dev/null 2>/dev/null
+      if [ "$?" != "0" ]; then
+        exit_err "ERROR: The size specified on $line is invalid"
+      fi
+
+      # Check that the mount-point starts with /
+      echo "$MNT" | grep -e "^/" -e "^none" >/dev/null 2>/dev/null
+      if [ "$?" != "0" ]; then
+        exit_err "ERROR: The mount-point specified on $line is invalid"
+      fi
+
+      if [ "$SIZE" = "0" ]
+      then
+        SOUT=""
+      else
+        SOUT="-s ${SIZE}M"
+      fi
+
+      # Check if we found a valid root partition
+      for CHECKMNT in `echo ${MNT} | sed 's|,| |g'`
+      do
+        if [ "${CHECKMNT}" = "/" ] ; then
+          FOUNDROOT="0" ; export FOUNDROOT
+        fi
+      done
+
+      # Generate a unique label name for this mount
+      gen_glabel_name "${MNT}" "${FS}"
+      PLABEL="${VAL}"
+
+      case ${FS} in
+          ZFS) PARTYPE="freebsd-zfs" ;;
+         SWAP) PARTYPE="freebsd-swap" ;;
+            *) PARTYPE="freebsd-ufs" ;;
+      esac
+
+      rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${DISK}"
+
+      # Check if this is a root / boot partition, and stamp the right loader
+      for TESTMNT in `echo ${MNT} | sed 's|,| |g'`
+      do
+        if [ "${TESTMNT}" = "/" -a -z "${BOOTTYPE}" ] ; then
+           BOOTTYPE="${PARTYPE}" 
+        fi 
+        if [ "${TESTMNT}" = "/boot" ]  ; then
+           BOOTTYPE="${PARTYPE}" 
+        fi 
+      done 
+
+      # Save this data to our partition config dir
+      echo "${FS}:${MNT}:${ENC}:${PLABEL}:GPT" >${PARTDIR}/${DISK}p${CURPART}
+
+      # Increment our parts counter
+      CURPART="`expr ${CURPART} + 1`"
+
+    fi # End of subsection locating a slice in config
+
+    echo $line | grep "^commitDiskLabel" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ]
+    then
+
+      # If this is the boot disk, stamp the right gptboot
+      if [ ! -z "${BOOTTYPE}" ] ; then
+        case ${BOOTTYPE} in
+           freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${DISK}" ;;
+           freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${DISK}" ;;
+        esac 
+      fi
+
+
+      # Found our flag to commit this label setup, check that we found at least 1 partition
+      if [ "${CURPART}" = "2" ] ; then
+        exit_err "ERROR: commitDiskLabel was called without any partition entries for it!"
+      fi
+    fi
+  done <${CFGF}
+};
+
+# Reads through the config and sets up a BSDLabel for the given slice
+populate_disk_label()
+{
+  if [ -z "${1}" ]
+  then
+    exit_err "ERROR: populate_disk_label() called without argument!"
+  fi
+
+  # Set some vars from the given working slice
+  disk="`echo $1 | cut -d '-' -f 1`" 
+  slicenum="`echo $1 | cut -d '-' -f 2`" 
+  type="`echo $1 | cut -d '-' -f 3`" 
+  
+  # Set WRKSLICE based upon format we are using
+  if [ "$type" = "mbr" ] ; then
+    wrkslice="${disk}s${slicenum}"
+  fi
+  if [ "$type" = "gpt" ] ; then
+    wrkslice="${disk}p${slicenum}"
+  fi
+
+  if [ -e "${SLICECFGDIR}/${wrkslice}" ]
+  then
+    disktag="`cat ${SLICECFGDIR}/${wrkslice}`"
+  else
+    exit_err "ERROR: Missing SLICETAG data. This shouldn't happen - please let the developers know"
+  fi
+
+  # Using Traditional MBR for dual-booting
+  if [ "$type" = "mbr" ] ; then
+    setup_mbr_partitions "${disktag}" "${wrkslice}"
+  fi
+
+  # Using entire disk mode, use GPT for this
+  if [ "$type" = "gpt" ] ; then
+    setup_gpt_partitions "${disktag}" "${disk}"
+  fi
+
+};
+
 # Function which reads in the disk slice config, and performs it
 setup_disk_label()
 {
@@ -216,9 +372,15 @@
   # Check that the slices we have did indeed get setup and fdisk worked
   for i in $WORKINGSLICES
   do
-    if [ ! -e "/dev/${i}" ]; then
-      exit_err "ERROR: The slice ${i} doesn't exist! FDISK Failure"
+    disk="`echo $i | cut -d '-' -f 1`" 
+    pnum="`echo $i | cut -d '-' -f 2`" 
+    type="`echo $i | cut -d '-' -f 3`" 
+    if [ "$type" = "mbr" -a ! -e "/dev/${disk}s${pnum}" ] ; then
+      exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!"
     fi
+    if [ "$type" = "gpt" -a ! -e "/dev/${disk}p${pnum}" ] ; then
+      exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!"
+    fi
   done
 
   # Setup some files which we'll be referring to

Modified: pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.sh	2010-02-26 19:30:57 UTC (rev 6306)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.sh	2010-02-26 21:10:30 UTC (rev 6307)
@@ -12,12 +12,16 @@
     PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
     if [ "$PARTFS" = "ZFS" ]
     then
-      if [ "${PARTMNT}" = "/" ]
-      then
-        echo "vfs.root.mountfrom=\"zfs:${PART}\"" >> ${FSMNT}/boot/loader.conf
-        FOUNDZFSROOT="${PART}"
-      fi
-     FOUNDZFS="1"
+      # Check if we have multiple zfs mounts specified
+      for ZMNT in `echo ${PARTMNT} | sed 's|,| |g'`
+      do
+        if [ "${ZMNT}" = "/" ]
+        then
+          echo "vfs.root.mountfrom=\"zfs:${PART}\"" >> ${FSMNT}/boot/loader.conf
+          FOUNDZFSROOT="${PART}"
+        fi
+      done
+      FOUNDZFS="1"
     fi
   done
 
@@ -43,11 +47,6 @@
     cp /etc/hostid ${FSMNT}/etc/hostid
   fi
 
-  if [ ! -z "${FOUNDZFSROOT}" ]
-  then
-    rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}"
-  fi
-
   # Loop through our FS and see if we have any ZFS partitions to cleanup
   for PART in `ls ${PARTDIR}`
   do
@@ -57,15 +56,30 @@
 
     if [ "$PARTFS" = "ZFS" ]
     then
-      if [ "${PARTMNT}" != "/" ]
-      then
-        rc_halt "zfs set mountpoint=${PARTMNT} ${PART}${PARTMNT}"
-        umount ${FSMNT}/${PARTMNT}
-        sleep 2
-      fi
+      # Check if we have multiple zfs mounts specified
+      for ZMNT in `echo ${PARTMNT} | sed 's|,| |g'`
+      do
+        PARTMNTREV="${ZMNT} ${PARTMNTREV}"
+      done
+
+      for ZMNT in ${PARTMNTREV}
+      do
+        if [ "${ZMNT}" != "/" ]
+        then
+          rc_halt "zfs set mountpoint=${ZMNT} ${PART}${ZMNT}"
+          rc_halt "zfs unmount ${PART}${ZMNT}"
+          sleep 2
+        fi
+      done
     fi
   done
 
+  # If are using a ZFS on "/" set it to legacy
+  if [ ! -z "${FOUNDZFSROOT}" ]
+  then
+    rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}"
+  fi
+
 };
 
 # Function which creates the /etc/fstab for the installed system

Modified: pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh	2010-02-26 19:30:57 UTC (rev 6306)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh	2010-02-26 21:10:30 UTC (rev 6307)
@@ -1,7 +1,39 @@
 #!/bin/sh
-# Functions related to disk operations using fdisk
+# Functions related to disk operations using gpart
 
 
+# Function to delete all gparts before starting an install
+delete_all_gpart()
+{
+  echo_log "Deleting all gparts"
+  DISK="$1"
+
+  # Check for any swaps to stop
+  for i in `gpart show ${DISK} | grep 'freebsd-swap' | tr -s ' ' | cut -d ' ' -f 4`
+  do
+    swapoff /dev/${DISK}s${i}b >/dev/null 2>/dev/null
+    swapoff /dev/${DISK}p${i} >/dev/null 2>/dev/null
+  done
+
+  # Delete the gparts now
+  for i in `gpart show ${DISK} | tr -s ' ' | cut -d ' ' -f 4`
+  do
+   if [ "${i}" != "ad0" -a "${i}" != "-" ] ; then
+     rc_nohalt "gpart delete -i ${i} ${DISK}"
+   fi
+  done
+};
+
+# Function to export all zpools before starting an install
+stop_all_zfs()
+{
+  # Export all zpools again, so that we can overwrite these partitions potentially
+  for i in `zpool list -H -o name`
+  do
+    zpool export -f ${i}
+  done
+};
+
 # Function which stops all gmirrors before doing any disk manipulation
 stop_all_gmirror()
 {
@@ -15,8 +47,6 @@
       echo_log "Stopping mirror $gprov $DISK"
       rc_nohalt "gmirror remove $gprov $DISK"
       rc_nohalt "dd if=/dev/zero of=/dev/${DISK} count=4096"
-      rc_nohalt "fdisk -I /dev/${DISK}"
-      rc_nohalt "dd if=/dev/zero of=/dev/${DISK} count=4096"
     fi
   done
 };
@@ -76,6 +106,9 @@
        # Make sure we stop any geli stuff on this disk
        stop_all_geli ${DISK}
 
+       # Make sure we don't have any zpools loaded
+       stop_all_zfs
+
      fi
 
      # Lets look if this device will be mirrored on another disk
@@ -150,12 +183,14 @@
        if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ]
        then
          case ${PTYPE} in
-                   all|ALL) tmpSLICE="${DISK}s1"  
-                        run_fdisk_full "${DISK}" "${BMANAGER}" ;;
+                   all|ALL) tmpSLICE="${DISK}p1"  
+                        run_gpart_full "${DISK}" "${BMANAGER}" ;;
            s1|s2|s3|s4) tmpSLICE="${DISK}${PTYPE}" 
-                        run_fdisk_slice "${DISK}" "${BMANAGER}" "${PTYPE}" ;;
+                        # Get the number of the slice we are working on
+                        s="`echo ${PTYPE} | awk '{print substr($0,length,1)}'`" 
+                        run_gpart_slice "${DISK}" "${BMANAGER}" "${s}" ;;
                  free|FREE) tmpSLICE="${DISK}s${LASTSLICE}"
-                        run_fdisk_free "${DISK}" "${LASTSLICE}" "${BMANAGER}" ;;
+                        run_gpark_free "${DISK}" "${LASTSLICE}" "${BMANAGER}" ;;
                      *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;;
          esac
 
@@ -186,8 +221,8 @@
 
 };
 
-# Function which runs fdisk and creates a single large slice
-run_fdisk_full()
+# Function which runs gpart and creates a single large slice
+run_gpart_full()
 {
   DISK=$1
   if [ ! -z "$2" ]
@@ -211,23 +246,24 @@
     done
   fi
 
+  # Remove any existing partitions
+  delete_all_gpart "${DISK}"
+
   #Erase any existing bootloader
   echo_log "Cleaning up ${DISK}"
   rc_halt "dd if=/dev/zero of=/dev/${DISK} count=2048"
 
   sleep 2
 
-  echo_log "Running fdisk on ${DISK}"
-  rc_halt "fdisk -I /dev/${DISK}"
+  echo_log "Running gpart on ${DISK}"
+  rc_halt "gpart create -s GPT ${DISK}"
+  rc_halt "gpart add -s 128 -t freebsd-boot ${DISK}"
+  
+  echo_log "Stamping boot sector on ${DISK}"
+  rc_halt "gpart bootcode -b /boot/pmbr ${DISK}"
 
-  if [ "${BMANAGER}" = "bsd" ]
-  then
-    echo_log "Stamping boot sector on ${DISK}"
-    rc_halt "gpart bootcode -b /boot/boot0 ${DISK}"
-  fi
+  slice="${DISK}-1-gpt"
 
-  slice="${DISK}s1"
-
   # Lets save our slice, so we know what to look for in the config file later on
   if [ -z "$WORKINGSLICES" ]
   then
@@ -239,8 +275,8 @@
   fi
 };
 
-# Function which runs fdisk on a specified s1-4 slice
-run_fdisk_slice()
+# Function which runs gpart on a specified s1-4 slice
+run_gpart_slice()
 {
   DISK=$1
   if [ ! -z "$2" ]
@@ -248,13 +284,14 @@
     BMANAGER="$2"
   fi
 
-  slice="${1}${3}"
+  # Set the slice we will use later
+  slice="${1}s${3}"
  
   # Set our sysctl so we can overwrite any geom using drives
   sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT}
 
   # Get the number of the slice we are working on
-  slicenum="`echo ${slice} | awk '{print substr($0,length,1)}'`"
+  slicenum="$3"
 
   # Check if we need to shutdown any journals on this slice
   ls /dev/${slice}*.journal* >/dev/null 2>/dev/null
@@ -277,26 +314,14 @@
    swapoff ${slice}b.eli >/dev/null 2>/dev/null
   fi
 
-  # Slice already exists, lets mark it as 165 for FreeBSD
-  # Get the fdisk -s output of this disk
-  fdisk -s /dev/${DISK} | grep -v "/dev/${DISK}:" | grep "${slicenum}:" | tr -s " " > ${TMPDIR}/fdiskblk
-  startblock="`cat ${TMPDIR}/fdiskblk | cut -d ' ' -f 3`"
-  sizeblock="`cat ${TMPDIR}/fdiskblk | cut -d ' ' -f 4`"
-  rm ${TMPDIR}/fdiskblk
-
-  # Create the new fdiskconfig file now to set this partition to type 165
-  echo "p       ${slicenum}     165     ${startblock}   ${sizeblock}" >${TMPDIR}/fdiskconfig
-
-  sleep 4
-
-  # Install new partition setup
-  echo_log "Running fdisk on ${DISK}"
-  rc_halt "fdisk -f ${TMPDIR}/fdiskconfig /dev/${DISK}"
+  # Modify partition type
+  echo_log "Running gpart modify on ${DISK}"
+  rc_halt "gpart modify -t freebsd -i ${slicenum} ${DISK}"
   sleep 2
 
   # Clean up old partition
   echo_log "Cleaning up $slice"
-  rc_halt "dd if=/dev/zero of=/dev/${slice} count=1024"
+  rc_halt "dd if=/dev/zero of=/dev/${DISK}s${slicenum} count=1024"
 
   sleep 1
 
@@ -306,6 +331,9 @@
     rc_halt "gpart bootcode -b /boot/boot0 ${DISK}"
   fi
 
+  # Set the slice to the format we'll be using for gpart later
+  slice="${1}-${3}-mbr"
+
   # Lets save our slice, so we know what to look for in the config file later on
   if [ -z "$WORKINGSLICES" ]
   then
@@ -317,8 +345,8 @@
   fi
 };
 
-# Function which runs fdisk and creates a new slice from free disk space
-run_fdisk_free()
+# Function which runs gpart and creates a new slice from free disk space
+run_gpart_free()
 {
   DISK=$1
   SLICENUM=$2
@@ -366,16 +394,11 @@
   # Now set the ending block to the total disk block size
   sizeblock="`expr ${totalblocks} - ${startblock}`"
 
-
-  # Create the new fdiskconfig file now to set this partition to type 165
-  echo "p       ${slicenum}     165     ${startblock}   ${sizeblock}" > ${TMPDIR}/fdiskconfig
-
   # Install new partition setup
-  echo_log "Running fdisk on ${DISK}"
-  rc_halt "fdisk -f ${TMPDIR}/fdiskconfig /dev/${DISK}"
+  echo_log "Running gpart on ${DISK}"
+  rc_halt "gpart add -b ${startblock} -s ${sizeblock} -t freebsd -i ${slicenum} ${DISK}"
   sleep 2
-
-  # Clean up old partition
+  
   echo_log "Cleaning up $slice"
   rc_halt "dd if=/dev/zero of=/dev/${slice} count=1024"
 
@@ -387,6 +410,7 @@
     rc_halt "gpart bootcode -b /boot/boot0 ${DISK}"
   fi
 
+  slice="${DISK}-${SLICENUM}-mbr"
   # Lets save our slice, so we know what to look for in the config file later on
   if [ -z "$WORKINGSLICES" ]
   then

Modified: pcbsd/trunk/pc-sysinstall/backend/functions-localize.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-localize.sh	2010-02-26 19:30:57 UTC (rev 6306)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-localize.sh	2010-02-26 21:10:30 UTC (rev 6307)
@@ -391,9 +391,12 @@
     fi
   done <${CFGF}
 
-  # Do our keyboard localization
-  localize_x_keyboard "${KEYMOD}" "${KEYLAYOUT}" "${KEYVAR}"
+  if [ "${INSTALLTYPE}" != "FreeBSD" ] ; then
+    # Do our X keyboard localization
+    localize_x_keyboard "${KEYMOD}" "${KEYLAYOUT}" "${KEYVAR}"
+  fi
 
+
   # Update the login.conf db, even if we didn't localize, its a good idea to make sure its up2date
   run_chroot_cmd "/usr/bin/cap_mkdb /etc/login.conf" >/dev/null 2>/dev/null
 

Modified: pcbsd/trunk/pc-sysinstall/backend/functions-mountdisk.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-mountdisk.sh	2010-02-26 19:30:57 UTC (rev 6306)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-mountdisk.sh	2010-02-26 21:10:30 UTC (rev 6307)
@@ -22,30 +22,41 @@
     MNTFLAGS="-o rw,${MNTFLAGS}"
   fi
 
-  # First make sure we create the mount point
-  if [ ! -d "${FSMNT}${MNTPOINT}" ]
-  then
-    mkdir -p ${FSMNT}${MNTPOINT} >>${LOGOUT} 2>>${LOGOUT}
-  fi
 
   #We are on ZFS, lets setup this mount-point
   if [ "${PARTFS}" = "ZFS" ]
   then
 
-    if [ "${MNTPOINT}" = "/" ]
+     # Check if we have multiple zfs mounts specified
+     for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'`
+     do
+       # First make sure we create the mount point
+       if [ ! -d "${FSMNT}${ZMNT}" ] ; then
+         mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT}
+       fi
+
+       if [ "${ZMNT}" = "/" ] ; then
+         ZNAME=""
+       else
+         ZNAME="${ZMNT}"
+         echo_log "zfs create ${PART}${ZNAME}"
+         rc_halt "zfs create ${PART}${ZNAME}"
+       fi
+       sleep 2
+       rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${PART}${ZNAME}"
+
+       # Disable atime for this zfs partition, speed increase
+       rc_nohalt "zfs set atime=off ${PART}${ZNAME}"
+     done 
+
+  else
+  # If we are not on ZFS, lets do the mount now
+    # First make sure we create the mount point
+    if [ ! -d "${FSMNT}${MNTPOINT}" ]
     then
-      ZNAME=""
-    else
-      ZNAME="${MNTPOINT}"
-      echo_log "zfs create ${PART}${ZNAME}"
-      rc_halt "zfs create ${PART}${ZNAME}"
-      echo_log "zfs set mountpoint=${FSMNT}${MNTPOINT} ${PART}${ZNAME}"
+      mkdir -p ${FSMNT}${MNTPOINT} >>${LOGOUT} 2>>${LOGOUT}
     fi
-    sleep 2
-    rc_halt "zfs set mountpoint=${FSMNT}${MNTPOINT} ${PART}${ZNAME}"
 
-  else
-  # If we are not on ZFS, lets do the mount now
     echo_log "mount ${MNTFLAGS} /dev/${PART} -> ${FSMNT}${MNTPOINT}"
     sleep 2
     rc_halt "mount ${MNTFLAGS} /dev/${PART} ${FSMNT}${MNTPOINT}"
@@ -79,7 +90,9 @@
       EXT=""
     fi
 
-    if [ "$PARTMNT" = "/" ]
+    # Check for root partition for mounting, including ZFS "/,/usr" type 
+    echo "$PARTMNT" | grep "/," >/dev/null
+    if [ "$?" = "0" -o "$PARTMNT" = "/" ]
     then
       case ${PARTFS} in
          UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
@@ -118,7 +131,8 @@
      fi
 
      # Check if we've found "/" again, don't need to mount it twice
-     if [ "$PARTMNT" != "/" ]
+     echo "$PARTMNT" | grep "/," >/dev/null
+     if [ "$?" != "0" -a "$PARTMNT" != "/" ]
      then
        case ${PARTFS} in
          UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"

Modified: pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh	2010-02-26 19:30:57 UTC (rev 6306)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh	2010-02-26 21:10:30 UTC (rev 6307)
@@ -9,23 +9,31 @@
   PARTFS="$2"
   PARTMNT="$3"
   EXT="$4"
+  PARTGEOM="$5"
   ROOTSLICE="`echo ${PART} | rev | cut -b 2- | rev`"
   rc_halt "zpool create -m none -f ${PART} ${PART}${EXT}"
 
   # Disable atime for this zfs partition, speed increase
   rc_nohalt "zfs set atime=off ${PART}"
 
-  # Check if we ended up with needing a zfs bootable partition
-  if [ "${PARTMNT}" = "/" -o "${PARTMNT}" = "/boot" ]
-  then
-    # Lets stamp the proper ZFS boot loader
-    echo_log "Setting up ZFS boot loader support" 
-    rc_halt "zpool set bootfs=${PART} ${PART}"
-    rc_halt "zpool export ${PART}"
-    rc_halt "dd if=/boot/zfsboot of=/dev/${ROOTSLICE} count=1"
-    rc_halt "dd if=/boot/zfsboot of=/dev/${PART}${EXT} skip=1 seek=1024"
-    rc_halt "zpool import ${PART}"
-  fi
+  # 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 [ "${PARTGEOM}" = "MBR" ]
+      then
+        # Lets stamp the proper ZFS boot loader
+        echo_log "Setting up ZFS boot loader support" 
+        rc_halt "zpool set bootfs=${PART} ${PART}"
+        rc_halt "zpool export ${PART}"
+        rc_halt "dd if=/boot/zfsboot of=/dev/${ROOTSLICE} count=1"
+        rc_halt "dd if=/boot/zfsboot of=/dev/${PART}${EXT} skip=1 seek=1024"
+        rc_halt "zpool import ${PART}"
+      fi
+    fi
+  done 
 
 };
 
@@ -50,6 +58,7 @@
      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`"
 
      # Make sure journaling isn't enabled on this device
      if [ -e "/dev/${PART}.journal" ]
@@ -104,7 +113,7 @@
               sleep 2
               ;;
          ZFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}" 
-              setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}"
+              setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}"
               ;;
         SWAP) rc_halt "sync"
               rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" 

Modified: pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh	2010-02-26 19:30:57 UTC (rev 6306)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh	2010-02-26 21:10:30 UTC (rev 6307)
@@ -23,7 +23,7 @@
 unmount_all_filesystems()
 {
    # Copy the logfile to disk before we unmount
-   cp ${LOGOUT} ${FSMNT}/pc-sysinstall.log
+   cp ${LOGOUT} ${FSMNT}/root/pc-sysinstall.log
    cd /
 
    # Start by unmounting any ZFS partitions



More information about the Commits mailing list