summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorjpaetzel <jpaetzel@FreeBSD.org>2011-04-21 06:25:12 +0000
committerjpaetzel <jpaetzel@FreeBSD.org>2011-04-21 06:25:12 +0000
commit582666352393e5b7a5a00ec55b4c3f44dbedc556 (patch)
tree1928c68175bbb582e55c99428e2b88df779b80e9 /usr.sbin
parentb6d230d6e1d79f2d8c4821ca274b3ac4ee7cc1eb (diff)
downloadFreeBSD-src-582666352393e5b7a5a00ec55b4c3f44dbedc556.zip
FreeBSD-src-582666352393e5b7a5a00ec55b4c3f44dbedc556.tar.gz
- Allows using full device name paths, such as /dev/ad0 or /dev/mirror/gm0 in config files
- Fixes some issues creating gmirror devices, including on GPT partitions - Bugfixes for ZFS mirroring - Enhanced GELI to work with a passphrase only, or key-file only - Bugfix to prevent crashing of PC-BSD Live media when checking for upgrade partitions Submitted by: Kris Moore <kmoore@freebsd.org> Approved by: kib (mentor) Sponsored by: iXsystems
Diffstat (limited to 'usr.sbin')
-rwxr-xr-xusr.sbin/pc-sysinstall/backend-query/update-part-list.sh43
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh37
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-cleanup.sh80
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-disk.sh91
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-mountdisk.sh48
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-newfs.sh71
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-unmount.sh53
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions.sh1
8 files changed, 215 insertions, 209 deletions
diff --git a/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh b/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh
index 54f28c6..298609b 100755
--- a/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh
+++ b/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh
@@ -37,16 +37,22 @@ FSMNT="/mnt"
# Get the freebsd version on this partition
get_fbsd_ver()
{
-
- VER="`file ${FSMNT}/bin/sh | grep 'for FreeBSD' | sed 's|for FreeBSD |;|g' | cut -d ';' -f 2 | cut -d ',' -f 1`"
- if [ "$?" = "0" ] ; then
- file ${FSMNT}/bin/sh | grep '32-bit' >/dev/null 2>/dev/null
- if [ "${?}" = "0" ] ; then
- echo "${1}: FreeBSD ${VER} (32bit)"
- else
- echo "${1}: FreeBSD ${VER} (64bit)"
+ sFiles="/bin/sh /boot/kernel/kernel"
+ for file in $sFiles
+ do
+ if [ ! -e "${FSMNT}/$file" ] ; then continue ; fi
+
+ VER="`file ${FSMNT}/$file | grep 'for FreeBSD' | sed 's|for FreeBSD |;|g' | cut -d ';' -f 2 | cut -d ',' -f 1`"
+ if [ "$?" = "0" ] ; then
+ file ${FSMNT}/$file | grep '32-bit' >/dev/null 2>/dev/null
+ if [ "${?}" = "0" ] ; then
+ echo "${1}: FreeBSD ${VER} (32bit)"
+ else
+ echo "${1}: FreeBSD ${VER} (64bit)"
+ fi
fi
- fi
+ break
+ done
}
@@ -86,25 +92,8 @@ do
fi
mount -o ro ${_dsk} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
- if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then
+ if [ $? -eq 0 ] ; then
get_fbsd_ver "`echo ${_dsk} | sed 's|/dev/||g'`"
umount -f ${FSMNT} >/dev/null 2>/dev/null
fi
done
-
-# Now search for any ZFS root partitions
-zpool import -o altroot=${FSMNT} -a
-
-# Unmount any auto-mounted stuff
-umount_all_dir "${FSMNT}"
-
-# Get pools
-_zps="`zpool list | grep -v 'NAME' | cut -d ' ' -f 1`"
-for _zpools in ${_zps}
-do
- mount -o ro -t zfs ${_zpools} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
- if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then
- get_fbsd_ver "${_zpools}"
- umount -f ${FSMNT} >/dev/null 2>/dev/null
- fi
-done
diff --git a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
index 2e413be..e819d74 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
@@ -101,7 +101,6 @@ setup_zfs_mirror_parts()
if [ $? -eq 0 ] ; then
echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT}
init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null
- rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${_zvars}" >/dev/null 2>/dev/null
rc_halt "gpart add -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null
_nZFS="$_nZFS ${_zvars}p2"
else
@@ -319,7 +318,8 @@ setup_gpart_partitions()
# Save this data to our partition config dir
if [ "${_pType}" = "gpt" ] ; then
- echo "${FS}:${MNT}:${ENC}:${PLABEL}:GPT:${XTRAOPTS}" >${PARTDIR}/${_pDisk}p${CURPART}
+ _dFile="`echo $_pDisk | sed 's|/|-|g'`"
+ echo "${FS}:${MNT}:${ENC}:${PLABEL}:GPT:${XTRAOPTS}" >${PARTDIR}/${_dFile}p${CURPART}
# Clear out any headers
sleep 2
@@ -327,18 +327,19 @@ setup_gpart_partitions()
# If we have a enc password, save it as well
if [ -n "${ENCPASS}" ] ; then
- echo "${ENCPASS}" >${PARTDIR}-enc/${_pDisk}p${CURPART}-encpass
+ echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}p${CURPART}-encpass
fi
else
# MBR Partition
- echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${_wSlice}${PARTLETTER}
+ _dFile="`echo $_wSlice | sed 's|/|-|g'`"
+ 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
# If we have a enc password, save it as well
if [ -n "${ENCPASS}" ] ; then
- echo "${ENCPASS}" >${PARTDIR}-enc/${_wSlice}${PARTLETTER}-encpass
+ echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}${PARTLETTER}-encpass
fi
fi
@@ -404,28 +405,28 @@ populate_disk_label()
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`"
+ diskid="`echo $1 | cut -d ':' -f 1`"
+ disk="`echo $1 | cut -d ':' -f 1 | sed 's|-|/|g'`"
+ 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}"
+ wrkslice="${diskid}s${slicenum}"
fi
if [ "$type" = "gpt" ] ; then
- wrkslice="${disk}p${slicenum}"
+ wrkslice="${diskid}p${slicenum}"
fi
- if [ -e "${SLICECFGDIR}/${wrkslice}" ]
- then
- disktag="`cat ${SLICECFGDIR}/${wrkslice}`"
- else
+ if [ ! -e "${SLICECFGDIR}/${wrkslice}" ] ; then
exit_err "ERROR: Missing SLICETAG data. This shouldn't happen - please let the developers know"
fi
-
+ disktag="`cat ${SLICECFGDIR}/${wrkslice}`"
+ slicedev="`echo $wrkslice | sed 's|-|/|g'`"
+
# Setup the partitions with gpart
- setup_gpart_partitions "${disktag}" "${disk}" "${wrkslice}" "${slicenum}" "${type}"
+ setup_gpart_partitions "${disktag}" "${disk}" "${slicedev}" "${slicenum}" "${type}"
};
@@ -444,10 +445,10 @@ setup_disk_label()
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
+ if [ "$type" = "mbr" -a ! -e "${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
+ if [ "$type" = "gpt" -a ! -e "${disk}p${pnum}" ] ; then
exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!"
fi
done
diff --git a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh b/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
index ca06cb2..97386f8 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
@@ -33,9 +33,10 @@ zfs_cleanup_unmount()
# Loop through our FS and see if we have any ZFS partitions to cleanup
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`"
- ZPOOLNAME=$(get_zpool_name "${PART}")
+ ZPOOLNAME=$(get_zpool_name "${PARTDEV}")
if [ "$PARTFS" = "ZFS" ]
then
@@ -82,13 +83,21 @@ zfs_cleanup_unmount()
# Loop through our FS and see if we have any ZFS partitions to cleanup
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`"
- ZPOOLNAME=$(get_zpool_name "${PART}")
+ ZPOOLNAME=$(get_zpool_name "${PARTDEV}")
if [ "$PARTFS" = "ZFS" ]
then
+
+ # Create a list of zpool names we can export
+ echo $ZPOOLEXPORTS | grep -q "$ZPOOLNAME "
+ if [ $? -ne 0 ] ; then
+ export ZPOOLEXPORTS="$ZPOOLNAME $ZPOOLEXPORTS"
+ fi
+
# Check if we have multiple zfs mounts specified
for ZMNT in `echo ${PARTMNT} | sed 's|,| |g'`
do
@@ -122,8 +131,8 @@ setup_dedicated_boot_part()
rc_halt "mkdir -p ${FSMNT}/${BOOTMNT}/boot"
rc_halt "mv ${FSMNT}/boot/* ${FSMNT}${BOOTMNT}/boot/"
rc_halt "mv ${FSMNT}${BOOTMNT}/boot ${FSMNT}/boot/"
- rc_halt "umount /dev/${BOOTFS}"
- rc_halt "mount /dev/${BOOTFS} ${FSMNT}${BOOTMNT}"
+ rc_halt "umount ${BOOTFS}"
+ rc_halt "mount ${BOOTFS} ${FSMNT}${BOOTMNT}"
rc_halt "rmdir ${FSMNT}/boot"
# Strip the '/' from BOOTMNT before making symlink
@@ -144,22 +153,12 @@ setup_fstab()
# Loop through the partitions, and start creating /etc/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`"
- DRIVE="`echo ${PART} | rev | cut -b 4- | rev`"
- # Check if this device is being mirrored
- if [ -e "${MIRRORCFGDIR}/${DRIVE}" ]
- then
- # This device is apart of a gmirror, lets reset PART to correct value
- 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=""
@@ -184,7 +183,7 @@ setup_fstab()
if [ "${PARTFS}" = "UFS+J" ] ; then
EXT="${EXT}.journal"
fi
- DEVICE="${PART}${EXT}"
+ DEVICE="${PARTDEV}${EXT}"
fi
@@ -193,7 +192,7 @@ setup_fstab()
if [ $? -eq 0 ] ; then
if [ "${PARTFS}" = "ZFS" ] ; then
ROOTFSTYPE="zfs"
- XPOOLNAME=$(get_zpool_name "${PART}")
+ XPOOLNAME=$(get_zpool_name "${PARTDEV}")
ROOTFS="${ZPOOLNAME}"
else
ROOTFS="${DEVICE}"
@@ -212,7 +211,7 @@ setup_fstab()
# Save the BOOTFS for call at the end
if [ "${PARTMNT}" = "/boot" ] ; then
- BOOTFS="${PART}${EXT}"
+ BOOTFS="${PARTDEV}${EXT}"
BOOTMNT="${BOOT_PART_MOUNT}"
PARTMNT="${BOOTMNT}"
fi
@@ -245,28 +244,6 @@ setup_fstab()
# Setup our disk mirroring with gmirror
setup_gmirror()
{
- NUM="0"
-
- cd ${MIRRORCFGDIR}
- for DISK in `ls *`
- do
- MIRRORDISK="`cat ${DISK} | cut -d ':' -f 1`"
- MIRRORBAL="`cat ${DISK} | cut -d ':' -f 2`"
-
- # Create this mirror device
- gmirror label -vb $MIRRORBAL gm${NUM} /dev/${DISK}
-
- sleep 3
-
- # Save the gm<num> device in our config
- echo "${MIRRORDISK}:${MIRRORBAL}:gm${NUM}" > ${DISK}
-
- sleep 3
-
- NUM=$((NUM+1))
- done
-
-
cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_mirror_load="YES"' 2>/dev/null
if [ $? -ne 0 ]
then
@@ -283,24 +260,25 @@ setup_geli_loading()
mkdir -p ${FSMNT}/boot/keys >/dev/null 2>/dev/null
cd ${GELIKEYDIR}
- for KEYFILE in `ls *`
+ for KEYFILE in `ls`
do
# Figure out the partition name based on keyfile name removing .key
PART="`echo ${KEYFILE} | cut -d '.' -f 1`"
+ PARTDEV="`echo ${PART} | sed 's|-|/|g'`"
+ PARTNAME="`echo ${PART} | sed 's|-dev-||g'`"
+
+ rc_halt "geli configure -b ${PARTDEV}"
- # Add the entries to loader.conf to start this geli provider at boot
- echo "geli_${PART}_keyfile0_load=\"YES\"" >> ${FSMNT}/boot/loader.conf
- echo "geli_${PART}_keyfile0_type=\"${PART}:geli_keyfile0\"" >> ${FSMNT}/boot/loader.conf
- echo "geli_${PART}_keyfile0_name=\"/boot/keys/${KEYFILE}\"" >> ${FSMNT}/boot/loader.conf
+ # If no passphrase, setup key files
+ if [ ! -e "${PARTDIR}-enc/${PART}-encpass" ] ; then
+ echo "geli_${PARTNAME}_keyfile0_load=\"YES\"" >> ${FSMNT}/boot/loader.conf
+ echo "geli_${PARTNAME}_keyfile0_type=\"${PARTNAME}:geli_keyfile0\"" >> ${FSMNT}/boot/loader.conf
+ echo "geli_${PARTNAME}_keyfile0_name=\"/boot/keys/${PARTNAME}.key\"" >> ${FSMNT}/boot/loader.conf
- # If we have a passphrase, set it up now
- if [ -e "${PARTDIR}-enc/${PART}-encpass" ] ; then
- geli setkey -J ${PARTDIR}-enc/${PART}-encpass -n 0 -p -k ${KEYFILE} -K ${KEYFILE} ${PART}
- geli configure -b ${PART}
+ # Copy the key to the disk
+ rc_halt "cp ${GELIKEYDIR}/${KEYFILE} ${FSMNT}/boot/keys/${PARTNAME}.key"
fi
- # Copy the key to the disk
- cp ${KEYFILE} ${FSMNT}/boot/keys/${KEYFILE}
done
# Make sure we have geom_eli set to load at boot
diff --git a/usr.sbin/pc-sysinstall/backend/functions-disk.sh b/usr.sbin/pc-sysinstall/backend/functions-disk.sh
index faeab0d..94fb436 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-disk.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-disk.sh
@@ -241,16 +241,15 @@ delete_all_gpart()
local DISK="$1"
# Check for any swaps to stop
- for i in `gpart show ${DISK} 2>/dev/null | grep 'freebsd-swap' | tr -s ' ' | cut -d ' ' -f 4`
+ for i in `swapctl -l | grep "$DISK" | awk '{print $1}'`
do
- swapoff /dev/${DISK}s${i}b >/dev/null 2>/dev/null
- swapoff /dev/${DISK}p${i} >/dev/null 2>/dev/null
+ swapoff ${i} >/dev/null 2>/dev/null
done
# Delete the gparts now
for i in `gpart show ${DISK} 2>/dev/null | tr -s ' ' | cut -d ' ' -f 4`
do
- if [ "${i}" != "${DISK}" -a "${i}" != "-" ] ; then
+ if [ "/dev/${i}" != "${DISK}" -a "${i}" != "-" ] ; then
rc_nohalt "gpart delete -i ${i} ${DISK}"
fi
done
@@ -262,7 +261,7 @@ delete_all_gpart()
clear_backup_gpt_table "${DISK}"
# Wipe out front of disk
- rc_nohalt "dd if=/dev/zero of=/dev/${DISK} count=3000"
+ rc_nohalt "dd if=/dev/zero of=${DISK} count=3000"
};
@@ -279,7 +278,7 @@ stop_all_zfs()
# Function which stops all gmirrors before doing any disk manipulation
stop_all_gmirror()
{
- DISK="${1}"
+ local DISK="`echo ${1} | sed 's|/dev/||g'`"
GPROV="`gmirror list | grep ". Name: mirror/" | cut -d '/' -f 2`"
for gprov in $GPROV
do
@@ -296,7 +295,7 @@ stop_all_gmirror()
# Make sure we don't have any geli providers active on this disk
stop_all_geli()
{
- _geld="${1}"
+ local _geld="`echo ${1} | sed 's|/dev/||g'`"
cd /dev
for i in `ls ${_geld}*`
@@ -321,8 +320,9 @@ setup_disk_slice()
rm -rf ${MIRRORCFGDIR} >/dev/null 2>/dev/null
mkdir ${MIRRORCFGDIR}
- # Start with disk0
+ # Start with disk0 and gm0
disknum="0"
+ gmnum="0"
# Make sure all zpools are exported
export_all_zpools
@@ -338,10 +338,12 @@ setup_disk_slice()
get_value_from_string "${line}"
strip_white_space "$VAL"
DISK="$VAL"
+
+ echo "${DISK}" | grep -q '^/dev/'
+ if [ $? -ne 0 ] ; then DISK="/dev/$DISK" ; fi
# Before we go further, lets confirm this disk really exists
- if [ ! -e "/dev/${DISK}" ]
- then
+ if [ ! -e "${DISK}" ] ; then
exit_err "ERROR: The disk ${DISK} does not exist!"
fi
@@ -354,7 +356,7 @@ setup_disk_slice()
# Make sure we don't have any zpools loaded
stop_all_zfs
- fi
+ fi
# Lets look if this device will be mirrored on another disk
echo $line | grep -q "^mirror=" 2>/dev/null
@@ -365,9 +367,11 @@ setup_disk_slice()
get_value_from_string "${line}"
strip_white_space "$VAL"
MIRRORDISK="$VAL"
+ echo "${MIRRORDISK}" | grep -q '^/dev/'
+ if [ $? -ne 0 ] ; then MIRRORDISK="/dev/$MIRRORDISK" ; fi
# Before we go further, lets confirm this disk really exists
- if [ ! -e "/dev/${MIRRORDISK}" ]
+ if [ ! -e "${MIRRORDISK}" ]
then
exit_err "ERROR: The mirror disk ${MIRRORDISK} does not exist!"
fi
@@ -458,8 +462,22 @@ setup_disk_slice()
# Found our flag to commit this disk setup / lets do sanity check and do it
if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ]
then
+
case ${PTYPE} in
all)
+ # If we have a gmirror, lets set it up
+ if [ -n "$MIRRORDISK" ]; then
+ # Default to round-robin if the user didn't specify
+ if [ -z "$MIRRORBAL" ]; then MIRRORBAL="round-robin" ; fi
+
+ echo "$MIRRORDISK:$MIRRORBAL:gm${gmnum}" >${MIRRORCFGDIR}/$DISK
+ init_gmirror "$gmnum" "$MIRRORBAL" "$DISK" "$MIRRORDISK"
+
+ # Reset DISK to the gmirror device
+ DISK="/dev/mirror/gm${gmnum}"
+ gmnum=$((gmknum+1))
+ fi
+
if [ "$PSCHEME" = "MBR" -o -z "$PSCHEME" ] ; then
PSCHEME="MBR"
tmpSLICE="${DISK}s1"
@@ -511,18 +529,8 @@ setup_disk_slice()
# Now save which disk<num> this is, so we can parse it later during slice partition setup
if [ -z "${IMAGE}" ]
then
- echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE
- fi
-
- # Save any mirror config
- if [ -n "$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
+ _sFile=`echo $tmpSLICE | sed 's|/|-|g'`
+ echo "disk${disknum}" >${SLICECFGDIR}/$_sFile
fi
# Increment our disk counter to look for next disk and unset
@@ -537,10 +545,25 @@ setup_disk_slice()
};
+
+# Init the gmirror device
+init_gmirror()
+{
+ local _mNum=$1
+ local _mBal=$2
+ local _mDisk=$3
+
+ # Create this mirror device
+ rc_halt "gmirror label -vb ${_mBal} gm${_mNum} /dev/${_mDisk}"
+
+ sleep 3
+
+}
+
# Stop all gjournals on disk / slice
stop_gjournal()
{
- _gdsk="$1"
+ _gdsk="`echo $1 | sed 's|/dev/||g'`"
# Check if we need to shutdown any journals on this drive
ls /dev/${_gdsk}*.journal >/dev/null 2>/dev/null
if [ $? -eq 0 ]
@@ -634,8 +657,8 @@ init_mbr_full_disk()
sec="${VAL}"
# Multiply them all together to get our total blocks
- totalblocks="`expr ${cyl} \* ${head}`"
- totalblocks="`expr ${totalblocks} \* ${sec}`"
+ totalblocks="`expr ${cyl} \* ${head} 2>/dev/null`"
+ totalblocks="`expr ${totalblocks} \* ${sec} 2>/dev/null`"
if [ -z "${totalblocks}" ]
then
totalblocks=`gpart show "${_intDISK}"|tail -2|head -1|awk '{ print $2 }'`
@@ -650,7 +673,7 @@ init_mbr_full_disk()
sleep 2
echo_log "Cleaning up ${_intDISK}s1"
- rc_halt "dd if=/dev/zero of=/dev/${_intDISK}s1 count=1024"
+ rc_halt "dd if=/dev/zero of=${_intDISK}s1 count=1024"
if [ "$_intBOOT" = "bsd" ] ; then
echo_log "Stamping boot0 on ${_intDISK}"
@@ -671,10 +694,10 @@ run_gpart_full()
if [ "$SCHEME" = "MBR" ] ; then
init_mbr_full_disk "$DISK" "$BOOT"
- slice="${DISK}-1-mbr"
+ slice=`echo "${DISK}:1:mbr" | sed 's|/|-|g'`
else
init_gpt_full_disk "$DISK"
- slice="${DISK}-1-gpt"
+ slice=`echo "${DISK}:1:gpt" | sed 's|/|-|g'`
fi
# Lets save our slice, so we know what to look for in the config file later on
@@ -723,7 +746,7 @@ run_gpart_slice()
# Clean up old partition
echo_log "Cleaning up $slice"
- rc_halt "dd if=/dev/zero of=/dev/${DISK}s${slicenum} count=1024"
+ rc_halt "dd if=/dev/zero of=${DISK}s${slicenum} count=1024"
sleep 1
@@ -734,7 +757,7 @@ run_gpart_slice()
fi
# Set the slice to the format we'll be using for gpart later
- slice="${1}-${3}-mbr"
+ slice=`echo "${1}:${3}:mbr" | sed 's|/|-|g'`
# Lets save our slice, so we know what to look for in the config file later on
if [ -z "$WORKINGSLICES" ]
@@ -811,7 +834,7 @@ run_gpart_free()
sleep 2
echo_log "Cleaning up $slice"
- rc_halt "dd if=/dev/zero of=/dev/${slice} count=1024"
+ rc_halt "dd if=/dev/zero of=${slice} count=1024"
sleep 1
@@ -821,7 +844,7 @@ run_gpart_free()
rc_halt "gpart bootcode -b /boot/boot0 ${DISK}"
fi
- slice="${DISK}-${SLICENUM}-mbr"
+ slice=`echo "${DISK}:${SLICENUM}:mbr" | sed 's|/|-|g'`
# Lets save our slice, so we know what to look for in the config file later on
if [ -z "$WORKINGSLICES" ]
then
diff --git a/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh b/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
index 5aa7a2b..9ca9df6 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
@@ -84,9 +84,9 @@ mount_partition()
mkdir -p ${FSMNT}${MNTPOINT} >>${LOGOUT} 2>>${LOGOUT}
fi
- echo_log "mount ${MNTFLAGS} /dev/${PART} -> ${FSMNT}${MNTPOINT}"
+ echo_log "mount ${MNTFLAGS} ${PART} -> ${FSMNT}${MNTPOINT}"
sleep 2
- rc_halt "mount ${MNTFLAGS} /dev/${PART} ${FSMNT}${MNTPOINT}"
+ rc_halt "mount ${MNTFLAGS} ${PART} ${FSMNT}${MNTPOINT}"
fi
};
@@ -101,9 +101,10 @@ mount_all_filesystems()
#########################################################
for PART in `ls ${PARTDIR}`
do
- if [ ! -e "/dev/${PART}" ]
+ PARTDEV=`echo $PART | sed 's|-|/|g'`
+ if [ ! -e "${PARTDEV}" ]
then
- exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
+ exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?"
fi
PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
@@ -122,12 +123,12 @@ mount_all_filesystems()
if [ "$?" = "0" -o "$PARTMNT" = "/" ]
then
case ${PARTFS} in
- UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
- UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
- UFS+SUJ) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
- UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;;
- ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
- IMAGE) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
+ UFS) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+S) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+SUJ) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+J) mount_partition ${PARTDEV}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;;
+ ZFS) mount_partition ${PARTDEV} ${PARTFS} ${PARTMNT} ;;
+ IMAGE) mount_partition ${PARTDEV} ${PARTFS} ${PARTMNT} ;;
*) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
esac
fi
@@ -137,9 +138,10 @@ mount_all_filesystems()
##################################################################
for PART in `ls ${PARTDIR}`
do
- if [ ! -e "/dev/${PART}" ]
+ PARTDEV=`echo $PART | sed 's|-|/|g'`
+ if [ ! -e "${PARTDEV}" ]
then
- exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
+ exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?"
fi
PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
@@ -158,23 +160,23 @@ mount_all_filesystems()
if [ "$?" != "0" -a "$PARTMNT" != "/" ]
then
case ${PARTFS} in
- UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
- UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
- UFS+SUJ) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
- UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;;
- ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
+ UFS) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+S) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+SUJ) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+J) mount_partition ${PARTDEV}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;;
+ ZFS) mount_partition ${PARTDEV} ${PARTFS} ${PARTMNT} ;;
SWAP)
# Lets enable this swap now
if [ "$PARTENC" = "ON" ]
then
- echo_log "Enabling encrypted swap on /dev/${PART}"
- rc_halt "geli onetime -d -e 3des ${PART}"
+ echo_log "Enabling encrypted swap on ${PARTDEV}"
+ rc_halt "geli onetime -d -e 3des ${PARTDEV}"
sleep 5
- rc_halt "swapon /dev/${PART}.eli"
+ rc_halt "swapon ${PARTDEV}.eli"
else
- echo_log "swapon ${PART}"
+ echo_log "swapon ${PARTDEV}"
sleep 5
- rc_halt "swapon /dev/${PART}"
+ rc_halt "swapon ${PARTDEV}"
fi
;;
IMAGE)
@@ -182,7 +184,7 @@ mount_all_filesystems()
then
mkdir -p "${PARTMNT}"
fi
- mount_partition ${PART} ${PARTFS} ${PARTMNT}
+ mount_partition ${PARTDEV} ${PARTFS} ${PARTMNT}
;;
*) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
esac
diff --git a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
index 1c2b023..96ca49b 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
@@ -68,8 +68,8 @@ setup_zfs_filesystem()
echo_log "Setting up ZFS boot loader support"
rc_halt "zpool set bootfs=${ZPOOLNAME} ${ZPOOLNAME}"
rc_halt "zpool export ${ZPOOLNAME}"
- 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 "dd if=/boot/zfsboot of=${ROOTSLICE} count=1"
+ rc_halt "dd if=/boot/zfsboot of=${PART}${EXT} skip=1 seek=1024"
rc_halt "zpool import ${ZPOOLNAME}"
fi
fi
@@ -89,9 +89,10 @@ setup_filesystems()
# newfs on any of them
for PART in `ls ${PARTDIR}`
do
- if [ ! -e "/dev/${PART}" ]
+ PARTDEV="`echo $PART | sed 's|-|/|g'`"
+ if [ ! -e "${PARTDEV}" ]
then
- exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
+ exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?"
fi
PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
@@ -103,19 +104,29 @@ setup_filesystems()
PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d ':' -f 7`"
# Make sure journaling isn't enabled on this device
- if [ -e "/dev/${PART}.journal" ]
+ if [ -e "${PARTDEV}.journal" ]
then
- rc_nohalt "gjournal stop -f ${PART}.journal"
- rc_nohalt "gjournal clear ${PART}"
+ rc_nohalt "gjournal stop -f ${PARTDEV}.journal"
+ rc_nohalt "gjournal clear ${PARTDEV}"
fi
# Setup encryption if necessary
if [ "${PARTENC}" = "ON" -a "${PARTFS}" != "SWAP" ]
then
- echo_log "Creating geli provider for ${PART}"
- rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1"
- rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key /dev/${PART}"
- rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key /dev/${PART}"
+ echo_log "Creating geli provider for ${PARTDEV}"
+
+ if [ -e "${PARTDIR}-enc/${PART}-encpass" ] ; then
+ # Using a passphrase
+ rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1"
+ rc_halt "geli init -J ${PARTDIR}-enc/${PART}-encpass ${PARTDEV}"
+ rc_halt "geli attach -j ${PARTDIR}-enc/${PART}-encpass ${PARTDEV}"
+ else
+ # No Encryption password, use key file
+ rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1"
+ rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key ${PARTDEV}"
+ rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key ${PARTDEV}"
+
+ fi
EXT=".eli"
else
@@ -125,12 +136,12 @@ setup_filesystems()
case ${PARTFS} in
UFS)
- echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
sleep 2
- rc_halt "newfs /dev/${PART}${EXT}"
+ rc_halt "newfs ${PARTDEV}${EXT}"
sleep 2
rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"
rc_halt "sync"
# Set flag that we've found a boot partition
@@ -141,12 +152,12 @@ setup_filesystems()
;;
UFS+S)
- echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
sleep 2
- rc_halt "newfs -U /dev/${PART}${EXT}"
+ rc_halt "newfs -U ${PARTDEV}${EXT}"
sleep 2
rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"
rc_halt "sync"
# Set flag that we've found a boot partition
if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
@@ -156,15 +167,15 @@ setup_filesystems()
;;
UFS+SUJ)
- echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
sleep 2
- rc_halt "newfs -U /dev/${PART}${EXT}"
+ rc_halt "newfs -U ${PARTDEV}${EXT}"
sleep 2
rc_halt "sync"
- rc_halt "tunefs -j enable /dev/${PART}${EXT}"
+ rc_halt "tunefs -j enable ${PARTDEV}${EXT}"
sleep 2
rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"
rc_halt "sync"
# Set flag that we've found a boot partition
if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
@@ -175,16 +186,16 @@ setup_filesystems()
UFS+J)
- echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
sleep 2
- rc_halt "newfs /dev/${PART}${EXT}"
+ rc_halt "newfs ${PARTDEV}${EXT}"
sleep 2
- rc_halt "gjournal label -f /dev/${PART}${EXT}"
+ rc_halt "gjournal label -f ${PARTDEV}${EXT}"
sleep 2
- rc_halt "newfs -O 2 -J /dev/${PART}${EXT}.journal"
+ rc_halt "newfs -O 2 -J ${PARTDEV}${EXT}.journal"
sleep 2
rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal"
+ rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}.journal"
rc_halt "sync"
# Set flag that we've found a boot partition
if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
@@ -194,19 +205,19 @@ setup_filesystems()
;;
ZFS)
- echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
- setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}" "${PARTXTRAOPTS}"
+ echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
+ setup_zfs_filesystem "${PARTDEV}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}" "${PARTXTRAOPTS}"
;;
SWAP)
rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"
rc_halt "sync"
sleep 2
;;
IMAGE)
- write_image "${PARTIMAGE}" "${PART}"
+ write_image "${PARTIMAGE}" "${PARTDEV}"
sleep 2
;;
diff --git a/usr.sbin/pc-sysinstall/backend/functions-unmount.sh b/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
index 5e80985..ce0db9b 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
@@ -42,7 +42,7 @@ umount_all_dir()
start_gmirror_sync()
{
- cd ${MIRRORCFGDIR}
+ cd ${MIRRORCFGDIR}
for DISK in `ls *`
do
MIRRORDISK="`cat ${DISK} | cut -d ':' -f 1`"
@@ -50,6 +50,7 @@ start_gmirror_sync()
MIRRORNAME="`cat ${DISK} | cut -d ':' -f 3`"
# Start the mirroring service
+ rc_nohalt "gmirror forget ${MIRRORNAME}"
rc_halt "gmirror insert ${MIRRORNAME} /dev/${MIRRORDISK}"
done
@@ -70,7 +71,7 @@ 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`"
@@ -83,24 +84,24 @@ unmount_all_filesystems()
EXT=""
fi
- #if [ "${PARTFS}" = "SWAP" ]
- #then
- # rc_nohalt "swapoff /dev/${PART}${EXT}"
- #fi
+ if [ "${PARTFS}" = "SWAP" ]
+ then
+ rc_nohalt "swapoff ${PARTDEV}${EXT}"
+ fi
# Check if we've found "/", and unmount that last
if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
then
- rc_halt "umount -f /dev/${PART}${EXT}"
+ rc_halt "umount -f ${PARTDEV}${EXT}"
# Re-check if we are missing a label for this device and create it again if so
if [ ! -e "/dev/label/${PARTLABEL}" ]
then
case ${PARTFS} in
- UFS) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
- UFS+S) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
- UFS+SUJ) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
- UFS+J) glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal ;;
+ UFS) glabel label ${PARTLABEL} ${PARTDEV}${EXT} ;;
+ UFS+S) glabel label ${PARTLABEL} ${PARTDEV}${EXT} ;;
+ UFS+SUJ) glabel label ${PARTLABEL} ${PARTDEV}${EXT} ;;
+ UFS+J) glabel label ${PARTLABEL} ${PARTDEV}${EXT}.journal ;;
*) ;;
esac
fi
@@ -112,10 +113,10 @@ unmount_all_filesystems()
if [ ! -e "/dev/label/${PARTLABEL}" ]
then
case ${PARTFS} in
- UFS) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
- UFS+S) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
- UFS+SUJ) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
- UFS+J) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" ;;
+ UFS) ROOTRELABEL="glabel label ${PARTLABEL} ${PARTDEV}${EXT}" ;;
+ UFS+S) ROOTRELABEL="glabel label ${PARTLABEL} ${PARTDEV}${EXT}" ;;
+ UFS+SUJ) ROOTRELABEL="glabel label ${PARTLABEL} ${PARTDEV}${EXT}" ;;
+ UFS+J) ROOTRELABEL="glabel label ${PARTLABEL} ${PARTDEV}${EXT}.journal" ;;
*) ;;
esac
fi
@@ -166,25 +167,25 @@ unmount_all_filesystems_failure()
then
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`"
- #if [ "${PARTFS}" = "SWAP" ]
- #then
- # if [ "${PARTENC}" = "ON" ]
- # then
- # rc_nohalt "swapoff /dev/${PART}.eli"
- # else
- # rc_nohalt "swapoff /dev/${PART}"
- # fi
- #fi
+ if [ "${PARTFS}" = "SWAP" ]
+ then
+ if [ "${PARTENC}" = "ON" ]
+ then
+ rc_nohalt "swapoff ${PARTDEV}.eli"
+ else
+ rc_nohalt "swapoff ${PARTDEV}"
+ fi
+ fi
# Check if we've found "/" again, don't need to mount it twice
if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
then
- rc_nohalt "umount -f /dev/${PART}"
+ rc_nohalt "umount -f ${PARTDEV}"
rc_nohalt "umount -f ${FSMNT}${PARTMNT}"
fi
done
diff --git a/usr.sbin/pc-sysinstall/backend/functions.sh b/usr.sbin/pc-sysinstall/backend/functions.sh
index 56ffa86..4987bf4 100755
--- a/usr.sbin/pc-sysinstall/backend/functions.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions.sh
@@ -277,6 +277,7 @@ get_zpool_name()
# Need to generate a zpool name for this device
NUM=`ls ${TMPDIR}/.zpools/ | wc -l | sed 's| ||g'`
NEWNAME="${BASENAME}${NUM}"
+ mkdir -p ${TMPDIR}/.zpools/`dirname $DEVICE`
echo "$NEWNAME" >${TMPDIR}/.zpools/${DEVICE}
echo "${NEWNAME}"
return
OpenPOWER on IntegriCloud