summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorjpaetzel <jpaetzel@FreeBSD.org>2012-03-12 21:32:43 +0000
committerjpaetzel <jpaetzel@FreeBSD.org>2012-03-12 21:32:43 +0000
commit1f39c522b6640b045a8332fc5534be9cc2d52de7 (patch)
tree2b7fac050ef8e07d479321c26b2c517ec0fd4a4d /usr.sbin
parent67de24ef241ec77adb295b189d1d99e5b63ffafc (diff)
downloadFreeBSD-src-1f39c522b6640b045a8332fc5534be9cc2d52de7.zip
FreeBSD-src-1f39c522b6640b045a8332fc5534be9cc2d52de7.tar.gz
Add the ability to use a varity of ZFS dataset options.
While here fix a bug causing zpools with /tmp mount-points to fail Submitted by: kris Obtained from: PC-BSD
Diffstat (limited to 'usr.sbin')
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh16
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-cleanup.sh29
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-mountdisk.sh52
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-newfs.sh14
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-unmount.sh14
5 files changed, 78 insertions, 47 deletions
diff --git a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
index f1cdf01..0c1e787 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
@@ -50,14 +50,14 @@ get_fs_line_xvars()
ACTIVEDEV="${1}"
LINE="${2}"
- echo $LINE | grep -q ' (' 2>/dev/null
+ echo $LINE | cut -d ' ' -f 4 | grep -q ' (' 2>/dev/null
if [ $? -eq 0 ] ; then
# See if we are looking for ZFS specific options
echo $LINE | grep -q '^ZFS' 2>/dev/null
if [ $? -eq 0 ] ; then
ZTYPE="NONE"
- ZFSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`"
+ ZFSVARS="`echo $LINE | cut -d ' ' -f 4 |cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`"
echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null
if [ $? -eq 0 ] ; then
@@ -126,9 +126,9 @@ gen_glabel_name()
NUM="0"
MAXNUM="20"
- # Check if we are doing /, and rename it
- if [ "$MOUNT" = "/" ]
- then
+ if [ "$TYPE" = "ZFS" ] ; then
+ NAME="zpool"
+ elif [ "$MOUNT" = "/" ] ; then
NAME="rootfs"
else
# If doing a swap partition, also rename it
@@ -341,7 +341,7 @@ setup_gpart_partitions()
# Save this data to our partition config dir
if [ "${_pType}" = "gpt" ] ; then
_dFile="`echo $_pDisk | sed 's|/|-|g'`"
- echo "${FS}:${MNT}:${ENC}:${PLABEL}:GPT:${XTRAOPTS}" >${PARTDIR}/${_dFile}p${CURPART}
+ echo "${FS}#${MNT}#${ENC}#${PLABEL}#GPT#${XTRAOPTS}" >${PARTDIR}/${_dFile}p${CURPART}
# Clear out any headers
sleep 2
@@ -354,7 +354,7 @@ setup_gpart_partitions()
else
# MBR Partition or GPT slice
_dFile="`echo $_wSlice | sed 's|/|-|g'`"
- echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${_dFile}${PARTLETTER}
+ echo "${FS}#${MNT}#${ENC}#${PLABEL}#MBR#${XTRAOPTS}#${IMAGE}" >${PARTDIR}/${_dFile}${PARTLETTER}
# Clear out any headers
sleep 2
dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 2>/dev/null
@@ -409,7 +409,7 @@ setup_gpart_partitions()
fi
# Found our flag to commit this label setup, check that we found at least 1 partition
- if [ "${CURPART}" = "2" ] ; then
+ if [ "${CURPART}" = "1" ] ; then
exit_err "ERROR: commitDiskLabel was called without any partition entries for it!"
fi
diff --git a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh b/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
index d69135a..255dbc8 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
@@ -34,8 +34,8 @@ zfs_cleanup_unmount()
for PART in `ls ${PARTDIR}`
do
PARTDEV=`echo $PART | sed 's|-|/|g'`
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
ZPOOLNAME=$(get_zpool_name "${PARTDEV}")
if [ "$PARTFS" = "ZFS" ]
@@ -84,9 +84,9 @@ zfs_cleanup_unmount()
for PART in `ls ${PARTDIR}`
do
PARTDEV=`echo $PART | sed 's|-|/|g'`
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
ZPOOLNAME=$(get_zpool_name "${PARTDEV}")
if [ "$PARTFS" = "ZFS" ]
@@ -101,17 +101,20 @@ zfs_cleanup_unmount()
# Check if we have multiple zfs mounts specified
for ZMNT in `echo ${PARTMNT} | sed 's|,| |g'`
do
+ ZMNT="`echo $ZMNT | cut -d '(' -f 1`"
PARTMNTREV="${ZMNT} ${PARTMNTREV}"
done
for ZMNT in ${PARTMNTREV}
do
- if [ "${ZMNT}" != "/" ]
- then
- rc_halt "zfs set mountpoint=${ZMNT} ${ZPOOLNAME}${ZMNT}"
+ if [ "${ZMNT}" = "/" ] ; then continue ; fi
+ # Some ZFS like /swap aren't mounted, and dont need unmounting
+ mount | grep -q "${FSMNT}${ZMNT}"
+ if [ $? -eq 0 ] ; then
rc_halt "zfs unmount ${ZPOOLNAME}${ZMNT}"
- sleep 2
+ rc_halt "zfs set mountpoint=${ZMNT} ${ZPOOLNAME}${ZMNT}"
fi
+ sleep 2
done
fi
done
@@ -154,10 +157,10 @@ setup_fstab()
for PART in `ls ${PARTDIR}`
do
PARTDEV=`echo $PART | sed 's|-|/|g'`
- 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`"
+ 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`"
# Unset EXT
EXT=""
diff --git a/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh b/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
index 9ca9df6..6d785b9 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
@@ -57,24 +57,52 @@ mount_partition()
# Check if we have multiple zfs mounts specified
for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'`
do
+ # Check for any ZFS specific mount options
+ ZMNTOPTS="`echo $ZMNT | cut -d '(' -f 2 | cut -d ')' -f 1`"
+ if [ "$ZMNTOPTS" = "$ZMNT" ] ; then ZMNTOPTS="" ; fi
+
+ # Reset ZMNT with options removed
+ ZMNT="`echo $ZMNT | cut -d '(' -f 1`"
+
# First make sure we create the mount point
if [ ! -d "${FSMNT}${ZMNT}" ] ; then
mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT}
fi
+ # Check for any volsize args
+ zcopt=""
+ for ZOPT in `echo $ZMNTOPTS | sed 's/|/ /g'`
+ do
+ echo "$ZOPT" | grep -q volsize
+ if [ $? -eq 0 ] ; then
+ volsize=`echo $ZOPT | cut -d '=' -f 2`
+ zcopt="-V $volsize"
+ fi
+ done
+
if [ "${ZMNT}" = "/" ] ; then
ZNAME=""
else
ZNAME="${ZMNT}"
- echo_log "zfs create -p ${ZPOOLNAME}${ZNAME}"
- rc_halt "zfs create -p ${ZPOOLNAME}${ZNAME}"
+ echo_log "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
+ rc_halt "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
fi
sleep 2
- rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
+ if [ -z "$zcopt" ] ; then
+ rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
+ fi
+
+ # If no ZFS options, we can skip
+ if [ -z "$ZMNTOPTS" ] ; then continue ; fi
- # Disable atime for this zfs partition, speed increase
- rc_nohalt "zfs set atime=off ${ZPOOLNAME}${ZNAME}"
- done
+ # Parse any ZFS options now
+ for ZOPT in `echo $ZMNTOPTS | sed 's/|/ /g'`
+ do
+ echo "$ZOPT" | grep -q volsize
+ if [ $? -eq 0 ] ; then continue ; fi
+ rc_halt "zfs set $ZOPT ${ZPOOLNAME}${ZNAME}"
+ done
+ done # End of adding ZFS mounts
else
# If we are not on ZFS, lets do the mount now
@@ -107,9 +135,9 @@ mount_all_filesystems()
exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?"
fi
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
if [ "${PARTENC}" = "ON" ]
then
@@ -144,9 +172,9 @@ mount_all_filesystems()
exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?"
fi
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
if [ "${PARTENC}" = "ON" ]
then
diff --git a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
index d5edff1..7be9bf3 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
@@ -95,13 +95,13 @@ setup_filesystems()
exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?"
fi
- 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`"
- PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d ':' -f 5`"
- PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 6`"
- PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d ':' -f 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`"
+ PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d '#' -f 5`"
+ PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 6`"
+ PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d '#' -f 7`"
# Make sure journaling isn't enabled on this device
if [ -e "${PARTDEV}.journal" ]
diff --git a/usr.sbin/pc-sysinstall/backend/functions-unmount.sh b/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
index 57a417e..a61a5e6 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
@@ -72,10 +72,10 @@ unmount_all_filesystems()
for PART in `ls ${PARTDIR}`
do
PARTDEV=`echo $PART | sed 's|-|/|g'`
- 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`"
+ 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`"
if [ "${PARTENC}" = "ON" ]
then
@@ -168,9 +168,9 @@ unmount_all_filesystems_failure()
for PART in `ls ${PARTDIR}`
do
PARTDEV=`echo $PART | sed 's|-|/|g'`
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
if [ "${PARTFS}" = "SWAP" ]
then
OpenPOWER on IntegriCloud