[PC-BSD Commits] r18576 - pcbsd/current/build-files/scripts

svn at pcbsd.org svn at pcbsd.org
Wed Aug 22 11:04:53 PDT 2012


Author: kris
Date: 2012-08-22 18:04:53 +0000 (Wed, 22 Aug 2012)
New Revision: 18576

Modified:
   pcbsd/current/build-files/scripts/makemfs-resizeusb.sh
   pcbsd/current/build-files/scripts/rc-resizeusb
Log:

Update the livefs mfsroot / resize / growfs stuff. Now we will use workaround
to set "real" device name in fstab. This means if it changes from the initial name
such as "da0" it will fail at bootup, but its the best we can do until growfs / glabel
issues are fixed upstream. 



Modified: pcbsd/current/build-files/scripts/makemfs-resizeusb.sh
===================================================================
--- pcbsd/current/build-files/scripts/makemfs-resizeusb.sh	2012-08-22 18:03:21 UTC (rev 18575)
+++ pcbsd/current/build-files/scripts/makemfs-resizeusb.sh	2012-08-22 18:04:53 UTC (rev 18576)
@@ -32,7 +32,7 @@
 cp rc tmpmnt/etc/rc
 
 # Create the FS now
-makefs -b 4000 -o label=USBRESIZE mfsroot tmpmnt
+makefs -b 6000 -o label=USBRESIZE mfsroot tmpmnt
 gzip -9 mfsroot
 mv mfsroot.gz /boot/
 

Modified: pcbsd/current/build-files/scripts/rc-resizeusb
===================================================================
--- pcbsd/current/build-files/scripts/rc-resizeusb	2012-08-22 18:03:21 UTC (rev 18575)
+++ pcbsd/current/build-files/scripts/rc-resizeusb	2012-08-22 18:04:53 UTC (rev 18576)
@@ -25,6 +25,43 @@
 # SUCH DAMAGE.
 #
 
+resize_media()
+{
+  dev="$1"
+  rdev=`echo $dev | rev | cut -c 2- | rev`
+  echo "Resizing file-system $dev on $rdev, this may take a few minutes..."
+  sleep 5 
+  echo "Adjusting partition tables on $rdev..."
+  gpart resize -i 1 $rdev >/dev/null 2>/dev/null
+  sleep 5 
+  echo "Running growfs on $dev..."
+  growfs -y /dev/$dev >/dev/null 2>/dev/null
+}
+
+disable_mfs()
+{
+  local odev="$1"
+  local ndev="$2"
+
+  echo "Cleaning up..."
+  sleep 5 
+  # Disable this mfsroot utility from running again
+  mount $ndev /mnt
+  sed -i '' 's|rootfs_load="YES"||g' /mnt/boot/loader.conf
+  sed -i '' 's|rootfs_type="mfs_root"||g' /mnt/boot/loader.conf
+  sed -i '' 's|rootfs_name="/boot/mfsroot"||g' /mnt/boot/loader.conf
+  sed -i '' 's|vfs.root.mountfrom="ufs:md0"||g' /mnt/boot/loader.conf
+
+  # If we are changing device names
+  # KPM - This will go away, once they fix growfs / glabel issue
+  if [ "$ndev" != "$odev" ] ; then
+    sed -i '' "s|$odev|$ndev|g" /mnt/etc/fstab
+  fi
+
+  umount /mnt
+}
+
+
 stty status '^T'
 
 # Set shell to ignore SIGINT (2), but not children;
@@ -37,41 +74,31 @@
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export HOME PATH
 
-# Mount MFSROOT RW
-mount -o rw /
-
 #
 # Running LIVE USB image, lets resize
 #
 
-/bin/sh
+odev="/dev/ufs/PCBSDUSB"
+ndev="/dev/ufs/PCBSDUSB"
 
 dev=`glabel status | grep PCBSDUSB | awk '{print $3}'`
 if [ -n "$dev" ] ; then
-  rdev=`echo $dev | rev | cut -c 2- | rev`
-  echo "Resizing file-system $dev on $rdev, this may take a few minutes..."
-  sleep 5 
-  gpart resize -i 1 $rdev >/dev/null 2>/dev/null
-  sleep 5 
-  growfs -y /dev/$dev >/dev/null 2>/dev/null
-
-  echo "Cleaning up..."
-  sleep 5 
-
-  # Relabel the file-system
-  glabel clear ${dev}
-  glabel label USBLIVE ${dev}
+  echo "Do you want to expand the file-system for this LIVE media?"
+  echo "This process may take 5-15~ minutes."
+  echo -e "Resize? (y/n):\c"
+  read ans
+  case $ans in
+     y|Y) resize_media "$dev"
+          odev="/dev/ufs/PCBSDUSB"
+          ndev="/dev/$dev"
+          ;;
+       *) ;;
+  esac 
 else
   echo "Unable to resize file-system.. Rebooting into live image.."
 fi
 
-# Disable this mfsroot utility from running again
-mount /dev/ufs/USBLIVE /mnt
-sed -i '' 's|rootfs_load="YES"||g' /mnt/boot/loader.conf
-sed -i '' 's|rootfs_type="mfs_root"||g' /mnt/boot/loader.conf
-sed -i '' 's|rootfs_name="/boot/mfsroot"||g' /mnt/boot/loader.conf
-sed -i '' 's|vfs.root.mountfrom="ufs:md0"||g' /mnt/boot/loader.conf
-umount /mnt
+disable_mfs "$odev" "$ndev"
 
 echo "Rebooting..."
 reboot



More information about the Commits mailing list