[PC-BSD Commits] r4790 - in pcbsd/trunk/pc-sysinstall: . backend conf
svn at pcbsd.org
svn at pcbsd.org
Tue Oct 27 13:26:44 PST 2009
Author: kris
Date: 2009-10-27 14:26:43 -0700 (Tue, 27 Oct 2009)
New Revision: 4790
Added:
pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.sh
pcbsd/trunk/pc-sysinstall/pcinstall.cfg.zfs
Modified:
pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh
pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
pcbsd/trunk/pc-sysinstall/backend/functions-parse.sh
pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh
pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh
pcbsd/trunk/pc-sysinstall/conf/pc-sysinstall.conf
pcbsd/trunk/pc-sysinstall/pcinstall.cfg
Log:
Added support to backend for gmirror of a disk or disk(s), still has some bugs, but getting
closer to being finished :)
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh 2009-10-27 19:19:47 UTC (rev 4789)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh 2009-10-27 21:26:43 UTC (rev 4790)
@@ -12,9 +12,6 @@
exit_err "ERROR: populate_disk_label() called without argument!"
fi
- # Make our tmpdir with slice info
- SLICECFGDIR="${TMPDIR}/.slice-cfg"
-
if [ -e "${SLICECFGDIR}/${WRKSLICE}" ]
then
DISKTAG="`cat ${SLICECFGDIR}/${WRKSLICE}`"
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh 2009-10-27 19:19:47 UTC (rev 4789)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh 2009-10-27 21:26:43 UTC (rev 4790)
@@ -2,13 +2,35 @@
# Functions related to disk operations using fdisk
+# Function which stops all gmirrors before doing any disk manipulation
+stop_all_gmirror()
+{
+ gmirror list | grep "mirror/" | cut -d "." -f 1 >${TMPDIR}/.oldgnum
+ while read num
+ do
+ GPROV="`gmirror list | grep "^${num}. Name" | grep mirror | cut -d '/' -f 2`"
+ GDEV="`gmirror list | grep "^${num}. Name" | grep -v mirror | cut -d ':' -f 2 | sed 's|^ ||g'`"
+ for i in $GDEV
+ do
+ gmirror remove $GPROV $i #>>${LOGOUT} 2>>${LOGOUT}
+ done
+ done <${TMPDIR}/.oldgnum
+
+ rm ${TMPDIR}/.oldgnum
+};
+
# Function which reads in the disk slice config, and performs it
setup_disk_slice()
{
- # Make our tmpdir with slice info
- SLICECFGDIR="${TMPDIR}/.slice-cfg"
+
+ # Make sure we stop any gmirrors before doing the install, wrecks havoc with fdisk and such
+ stop_all_gmirror
+
+ # Cleanup any slice / mirror dirs
rm -rf ${SLICECFGDIR} >/dev/null 2>/dev/null
mkdir ${SLICECFGDIR}
+ rm -rf ${MIRRORCFGDIR} >/dev/null 2>/dev/null
+ mkdir ${MIRRORCFGDIR}
# Start with disk0
disknum="0"
@@ -32,6 +54,34 @@
fi
fi
+ # Lets look if this device will be mirrored on another disk
+ echo $line | grep "^mirror=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+
+ # Found a disk= entry, lets get the disk we are working on
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ MIRRORDISK="$VAL"
+
+ # Before we go further, lets confirm this disk really exists
+ if [ ! -e "/dev/${MIRRORDISK}" ]
+ then
+ exit_err "ERROR: The mirror disk ${MIRRORDISK} does not exist!"
+ fi
+ fi
+
+ # Lets see if we have been given a mirror balance choice
+ echo $line | grep "^mirrorbal=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+
+ # Found a disk= entry, lets get the disk we are working on
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ MIRRORBAL="$VAL"
+ fi
+
echo $line | grep "^partition=" >/dev/null 2>/dev/null
if [ "$?" = "0" ]
then
@@ -84,12 +134,24 @@
run_fdisk_free "${DISK}" "${LASTSLICE}" "${BMANAGER}" ;;
*) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;;
esac
- unset BMANAGER PTYPE DISK
# Now save which disk<num> this is, so we can parse it later during slice partition setup
echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE
- # Increment our disk counter to look for next disk
+ # Save any mirror config
+ if [ ! -z "$MIRRORDISK" ]
+ then
+ # Default to round-robin if the user didn't specify
+ if [ -z "$MIRRORBAL" ]
+ then
+ MIRRORBAL="round-robin"
+ fi
+ echo "$MIRRORDISK:$MIRRORBAL" >${MIRRORCFGDIR}/$DISK
+ fi
+
+
+ # Increment our disk counter to look for next disk and unset
+ unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL
disknum="`expr $disknum + 1`"
else
exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-parse.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-parse.sh 2009-10-27 19:19:47 UTC (rev 4789)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-parse.sh 2009-10-27 21:26:43 UTC (rev 4790)
@@ -46,12 +46,10 @@
done
if [ "$VALID" = "1" ]
then
- echo "Error: ${1} is set to unknown value $VAL"
- exit 1
+ exit_err "Error: ${1} is set to unknown value $VAL"
fi
else
- echo "Error: Did we forgot to supply a string to parse and setting to grab?"
- exit 1
+ exit_err "Error: Did we forgot to supply a string to parse and setting to grab?"
fi
};
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh 2009-10-27 19:19:47 UTC (rev 4789)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh 2009-10-27 21:26:43 UTC (rev 4790)
@@ -1,83 +1,20 @@
#!/bin/sh
# Functions which unmount all mounted disk filesystems
-# Finishes up with ZFS setup before unmounting
-zfs_cleanup()
+# Script that adds our gmirror devices for syncing
+start_gmirror_sync()
{
- # Loop through our FS and see if we have any ZFS partitions to cleanup
- for PART in `ls ${PARTDIR}`
- do
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- if [ "$PARTFS" = "ZFS" ]
- then
- if [ "${PARTMNT}" = "/" ]
- then
- zfs set mountpoint=legacy ${PART}/root >>${LOGOUT} 2>>${LOGOUT}
- echo "vfs.root.mountfrom=\"zfs:${PART}/root\"" >> ${FSMNT}/boot/loader.conf
- else
- umount ${FSMNT}/${PARTMNT}
- zfs set mountpoint=${PARTMNT} ${PART}/${PARTMNT} >>${LOGOUT} 2>>${LOGOUT}
- fi
- FOUNDZFS="1"
- fi
- done
-
- if [ ! -z "${FOUNDZFS}" ]
- then
- # Check if we need to add our ZFS flags to rc.conf, src.conf and loader.conf
- cat ${FSMNT}/boot/loader.conf >/dev/null 2>/dev/null | grep 'zfs_load="YES"' >/dev/null 2>/dev/null
- if [ "$?" != "0" ]
- then
- echo 'zfs_load="YES"' >>${FSMNT}/boot/loader.conf
- fi
- cat ${FSMNT}/etc/rc.conf >/dev/null 2>/dev/null | grep 'zfs_enable="YES"' >/dev/null 2>/dev/null
- if [ "$?" != "0" ]
- then
- echo 'zfs_enable="YES"' >>${FSMNT}/etc/rc.conf
- fi
-
- # Copy over any ZFS cache data
- cp /boot/zfs/* ${FSMNT}/boot/zfs/
-
- # Copy the hostid so that our zfs cache works
- cp /etc/hostid ${FSMNT}/etc/hostid
- fi
-
-
-};
-
-# Function which creates the /etc/fstab for the installed system
-setup_fstab()
-{
- FSTAB="${FSMNT}/etc/fstab"
- rm ${FSTAB} >/dev/null 2>/dev/null
-
- # Create the header
- echo "# Device Mountpoint FStype Options Dump Pass#" >> ${FSTAB}
-
- # Loop through the partitions, and start creating /etc/fstab
- for PART in `ls ${PARTDIR}`
+ cd ${MIRRORCFGDIR}
+ for DISK in `ls *`
do
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+ MIRRORDISK="`cat ${DISK} | cut -d ':' -f 1`"
+ MIRRORBAL="`cat ${DISK} | cut -d ':' -f 2`"
+ MIRRORNAME="`cat ${DISK} | cut -d ':' -f 3`"
+
+ # Start the mirroring service
+ gmirror insert ${MIRRORNAME} /dev/${MIRRORDISK}
- if [ "${PARTFS}" != "ZFS" ]
- then
- if [ "${PARTFS}" = "UFS+J" ]
- then
- EXT=".journal"
- else
- EXT=""
- fi
- if [ "${PARTFS}" = "SWAP" ]
- then
- echo "/dev/${PART}${EXT} none swap sw 0 0" >> ${FSTAB}
- else
- echo "/dev/${PART}${EXT} ${FSMNT} ufs rw 1 1" >> ${FSTAB}
- fi
- fi
done
};
@@ -85,14 +22,7 @@
# Unmounts all our mounted file-systems
unmount_all_filesystems()
{
- # Lets start by creating our /etc/fstab file
- setup_fstab
-
- # Lets do a quick check to see if we have any ZFS partitions that
- # need cleanup
- zfs_cleanup
-
- # Lets read our partition list again, and unmount each
+ # Lets read our partition list, and unmount each
##################################################################
for PART in `ls ${PARTDIR}`
do
@@ -127,4 +57,12 @@
# Unmount our CDMNT
umount ${CDMNT} >/dev/null 2>/dev/null
+ # Check if we need to run any gmirror syncing
+ ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Lets start syncing now
+ start_gmirror_sync
+ fi
+
};
Modified: pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh 2009-10-27 19:19:47 UTC (rev 4789)
+++ pcbsd/trunk/pc-sysinstall/backend/parseconfig.sh 2009-10-27 21:26:43 UTC (rev 4790)
@@ -13,6 +13,7 @@
. ${BACKEND}/functions-installcomponents.sh
. ${BACKEND}/functions-runcommands.sh
. ${BACKEND}/functions-localize.sh
+. ${BACKEND}/functions-cleanup.sh
. ${BACKEND}/functions-unmount.sh
# Check that the config file exists
@@ -43,6 +44,7 @@
check_value installMedium "dvd usb ftp"
check_value packageType "lzma uzip tar"
check_value partition "all s1 s2 s3 s4 free"
+check_value mirrorbal "load prefer round-robin split"
# We passed all sanity checks! Yay, lets start the install
echo "File Sanity Check -> OK"
@@ -88,6 +90,9 @@
# Do any localization in configuration
run_localize
+ # Do any last cleanup / setup before unmounting
+ run_final_cleanup
+
# Unmount and finish up
unmount_all_filesystems
Modified: pcbsd/trunk/pc-sysinstall/conf/pc-sysinstall.conf
===================================================================
--- pcbsd/trunk/pc-sysinstall/conf/pc-sysinstall.conf 2009-10-27 19:19:47 UTC (rev 4789)
+++ pcbsd/trunk/pc-sysinstall/conf/pc-sysinstall.conf 2009-10-27 21:26:43 UTC (rev 4790)
@@ -14,6 +14,14 @@
PARTDIR="${TMPDIR}/part-info"
export PARTDIR
+# Set the SLICECFGDIR
+SLICECFGDIR="${TMPDIR}/.slice-cfg"
+export SLICECFGDIR
+
+# Set the MIRRORCFGDIR
+MIRRORCFGDIR="${TMPDIR}/.mirror-cfg"
+export MIRRORCFGDIR
+
# Set the FTP file we use to test if we have a working internet connection
FTPTEST="ftp.pcbsd.org/pub/README"
export FTPTEST
Modified: pcbsd/trunk/pc-sysinstall/pcinstall.cfg
===================================================================
--- pcbsd/trunk/pc-sysinstall/pcinstall.cfg 2009-10-27 19:19:47 UTC (rev 4789)
+++ pcbsd/trunk/pc-sysinstall/pcinstall.cfg 2009-10-27 21:26:43 UTC (rev 4790)
@@ -6,6 +6,8 @@
# Set the disk parameters
disk0=ad0
+mirror=ad1
+mirrorbal=split
partition=all
bootManager=bsd
commitDiskPart
@@ -13,14 +15,13 @@
# Setup the disk label
# All sizes are expressed in MB
# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP
-disk0-part=ZFS 500 /
+disk0-part=UFS+S 500 /
disk0-part=SWAP 2000 none
-disk0-part=ZFS 0 /usr
+disk0-part=UFS+S 0 /usr
# Size 0 means use the rest of the slice size
# Do it now!
commitDiskLabel
-
# Set if we are installing via optical, USB, or FTP
installType=FreeBSD
installMedium=dvd
More information about the Commits
mailing list