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

svn at pcbsd.org svn at pcbsd.org
Thu Dec 3 11:42:15 PST 2009


Author: kris
Date: 2009-12-03 11:42:15 -0800 (Thu, 03 Dec 2009)
New Revision: 5222

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

Updated pc-sysinstall to now use glabel when creating partitions (excluding zfs, and gmirror), creates the label
when the file-system is setup, and sets up /etc/fstab using this label as well. This corrects issues with
device names getting switched around during boot and causing a failure



Modified: pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh	2009-12-03 17:36:17 UTC (rev 5221)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh	2009-12-03 19:42:15 UTC (rev 5222)
@@ -1,7 +1,45 @@
 #!/bin/sh
 # Functions related to disk operations using bsdlabel
 
+# Function which creates a unique label name for the specified mount
+gen_glabel_name()
+{
+  MOUNT="$1"
+  NUM="0"
+  MAXNUM="20"
 
+  # Check if we are doing /, and rename it
+  if [ "$MOUNT" = "/" ]
+  then
+    NAME="rootfs"
+  else
+    NAME="`echo $MOUNT | sed 's|/||g' | sed 's| ||g'`"
+  fi
+
+  # Loop through and break when we find our first available label
+  while
+  Z=1
+  do
+    glabel status | grep "${NAME}${NUM}" >/dev/null 2>/dev/null
+    if [ "$?" != "0" ]
+    then
+      break
+    else
+      NUM="`expr ${NUM} + 1`"
+    fi
+
+    if [ $NUM -gt $MAXNUM ]
+    then
+      exit_err "Cannot allocate additional glabel name for $NAME"
+      break
+    fi
+  done 
+   
+
+  VAL="${NAME}${NUM}" 
+  export VAL
+}
+
 # Reads through the config and sets up a BSDLabel for the given slice
 populate_disk_label()
 {
@@ -112,8 +150,12 @@
         fi
       fi
 
+      # Generate a unique label name for this mount
+      gen_glabel_name "${MNT}"
+      PLABEL="${VAL}"
+
       # Save this data to our partition config dir
-      echo "${FS}:${MNT}:${ENC}" >${PARTDIR}/${WRKSLICE}${PARTLETTER}
+      echo "${FS}:${MNT}:${ENC}:${PLABEL}" >${PARTDIR}/${WRKSLICE}${PARTLETTER}
 
       # This partition letter is used, get the next one
       case ${PARTLETTER} in

Modified: pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.sh	2009-12-03 17:36:17 UTC (rev 5221)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.sh	2009-12-03 19:42:15 UTC (rev 5222)
@@ -66,6 +66,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`"
 
     DRIVE="`echo ${PART} | rev | cut -b 4- | rev`"
     # Check if this device is being mirrored
@@ -75,12 +76,13 @@
       MDRIVE="mirror/`cat ${MIRRORCFGDIR}/${DRIVE} | cut -d ':' -f 3`"
       TMP="`echo ${PART} | rev | cut -b -3 | rev`"
       PART="${MDRIVE}${TMP}"
+      PARTLABEL=""
     fi
 
     # Unset EXT
     EXT=""
 
-
+    # Only create non-zfs partitions
     if [ "${PARTFS}" != "ZFS" ]
     then
       if [ "${PARTENC}" = "ON" ]
@@ -93,13 +95,24 @@
         setup_gjournal
         EXT="${EXT}.journal"
       fi
+
+      # Figure out if we are using a glabel, or the mirror name for this entry
+      if [ ! -z "${PARTLABEL}" ]
+      then
+        DEVICE="label/${PARTLABEL}"
+      else
+        DEVICE="${PART}${EXT}"
+      fi
+
+      # Echo out the fstab entry now
       if [ "${PARTFS}" = "SWAP" ]
       then
-        echo "/dev/${PART}${EXT}	none		swap		sw	0	0" >> ${FSTAB}
+        echo "/dev/${DEVICE}	none		swap		sw	0	0" >> ${FSTAB}
       else
-        echo "/dev/${PART}${EXT}	${PARTMNT}		ufs		rw		1	1" >> ${FSTAB}
+        echo "/dev/${DEVICE}	${PARTMNT}		ufs		rw		1	1" >> ${FSTAB}
       fi
-    fi
+
+    fi # End of ZFS Check
   done
 
 };

Modified: pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh	2009-12-03 17:36:17 UTC (rev 5221)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh	2009-12-03 19:42:15 UTC (rev 5222)
@@ -46,6 +46,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`"
 
      # Make sure journaling isn't enabled on this device
      if [ -e "/dev/${PART}.journal" ]
@@ -71,10 +72,12 @@
          UFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
               sleep 2
               rc_halt "newfs /dev/${PART}${EXT}"
+              rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
               ;;
        UFS+S) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
               sleep 2
               rc_halt "newfs -U /dev/${PART}${EXT}"
+              rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
               ;;
        UFS+J) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
               sleep 2
@@ -83,11 +86,13 @@
               rc_halt "gjournal label -f /dev/${PART}${EXT}"
               sleep 2
               rc_halt "newfs -O 2 -J /dev/${PART}${EXT}.journal"
+              rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal"
               ;;
          ZFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}" 
               setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}"
               ;;
-        SWAP) ;;
+        SWAP) rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" 
+              ;;
            *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
      esac
 



More information about the Commits mailing list