[PC-BSD Commits] r6361 - in pcbsd/trunk/pc-sysinstall: backend conf
svn at pcbsd.org
svn at pcbsd.org
Fri Mar 5 12:57:38 PST 2010
Author: kris
Date: 2010-03-05 12:57:38 -0800 (Fri, 05 Mar 2010)
New Revision: 6361
Modified:
pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh
pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.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/conf/pc-sysinstall.conf
Log:
Large update, pc-sysinstall can create and use "/boot" partitions properly now, even when using ZFS
as the "/" mount. This will allow us to enable encrypted "/" and other partitions with a boot password soon
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh 2010-03-05 10:03:41 UTC (rev 6360)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-bsdlabel.sh 2010-03-05 20:57:38 UTC (rev 6361)
@@ -93,7 +93,7 @@
VAL="${NAME}${NUM}"
export VAL
-}
+};
# Function to setup / stamp a legacy MBR bsdlabel
setup_mbr_partitions()
@@ -144,9 +144,9 @@
# Check if the user tried to setup / as an encrypted partition
if [ "${MNT}" = "/" -a "${ENC}" = "ON" ]
then
- exit_err "ERROR: Encrypted root partitions are not supported at this time."
- fi
-
+ USINGENCROOT="0" ; export USINGENCROOT
+ fi
+
# Now check that these values are sane
case $FS in
UFS|UFS+S|UFS+J|ZFS|SWAP) ;;
@@ -184,13 +184,37 @@
fi
# Check if we found a valid root partition
- for CHECKMNT in `echo ${MNT} | sed 's|,| |g'`
- do
- if [ "${CHECKMNT}" = "/" ] ; then
+ check_for_mount "${MNT}" "/"
+ if [ "$?" = "0" ] ; then
FOUNDROOT="0" ; export FOUNDROOT
+ fi
+
+ # Check if we have a "/boot" instead
+ check_for_mount "${MNT}" "/boot"
+ if [ "${?}" = "0" ] ; then
+ USINGBOOTPART="0" ; export USINGBOOTPART
+ if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" ]
+ then
+ exit_err "/boot partition must be formatted with UFS"
fi
- done
+ fi
+
else
+ # Done with the a: partitions
+
+ # Check if we found a valid root partition not on a:
+ check_for_mount "${MNT}" "/"
+ if [ "${?}" = "0" ] ; then
+ FOUNDROOT="1" ; export FOUNDROOT
+ fi
+
+ # Check if we have a /boot partition, and fail since its not first
+ check_for_mount "${MNT}" "/boot"
+ if [ "${?}" = "0" ] ; then
+ exit_err "/boot partition must be first partition"
+ fi
+
+
if [ "$FS" = "SWAP" ]
then
echo "${PARTLETTER}: ${SOUT} * swap" >>${BSDLABEL}
@@ -287,7 +311,7 @@
# Check if the user tried to setup / as an encrypted partition
if [ "${MNT}" = "/" -a "${ENC}" = "ON" ]
then
- exit_err "ERROR: Encrypted root partitions are not supported at this time."
+ USINGENCROOT="0" ; export USINGENCROOT
fi
# Now check that these values are sane
@@ -316,13 +340,28 @@
fi
# Check if we found a valid root partition
- for CHECKMNT in `echo ${MNT} | sed 's|,| |g'`
- do
- if [ "${CHECKMNT}" = "/" ] ; then
+ check_for_mount "${MNT}" "/"
+ if [ "${?}" = "0" ] ; then
+ if [ "${FOUNDDISKPARTS}" = "1" ] ; then
FOUNDROOT="0" ; export FOUNDROOT
+ else
+ FOUNDROOT="1" ; export FOUNDROOT
fi
- done
+ fi
+ check_for_mount "${MNT}" "/boot"
+ if [ "${?}" = "0" ] ; then
+ if [ "${CURPART}" = "2" ] ; then
+ USINGBOOTPART="0" ; export USINGBOOTPART
+ if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" ]
+ then
+ exit_err "/boot partition must be formatted with UFS"
+ fi
+ else
+ exit_err "/boot partition must be first partition"
+ fi
+ fi
+
# Generate a unique label name for this mount
gen_glabel_name "${MNT}" "${FS}"
PLABEL="${VAL}"
@@ -453,8 +492,15 @@
rm $LABELLIST >/dev/null 2>/dev/null
# Set our flag to determine if we've got a valid root partition in this setup
- FOUNDROOT="1"
+ FOUNDROOT="-1"
export FOUNDROOT
+
+ # Check if we are using a /boot partition
+ USINGBOOTPART="1"
+ export USINGBOOTPART
+
+ # Set encryption on root check
+ USINGENCROOT="1" ; export USINGENCROOT
# Make the tmp directory where we'll store FS info & mount-points
rm -rf ${PARTDIR} >/dev/null 2>/dev/null
@@ -466,9 +512,20 @@
done
# Check if we made a root partition
- if [ "$FOUNDROOT" = "1" ]
+ if [ "$FOUNDROOT" = "-1" ]
then
exit_err "ERROR: No root (/) partition specified!!"
fi
+
+ # Check if we made a root partition
+ if [ "$FOUNDROOT" = "1" -a "${USINGBOOTPART}" != "0" ]
+ then
+ exit_err "ERROR: (/) partition isn't first partition on disk!"
+ fi
+
+ if [ "${USINGENCROOT}" = "0" -a "${USINGBOOTPART}" != "0" ]
+ then
+ exit_err "ERROR: Can't encrypt (/) with no (/boot) partition!"
+ fi
};
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.sh 2010-03-05 10:03:41 UTC (rev 6360)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-cleanup.sh 2010-03-05 20:57:38 UTC (rev 6361)
@@ -4,7 +4,6 @@
# Finishes up with ZFS setup before unmounting
zfs_cleanup_unmount()
{
-
# Loop through our FS and see if we have any ZFS partitions to cleanup
for PART in `ls ${PARTDIR}`
do
@@ -20,8 +19,13 @@
do
if [ "${ZMNT}" = "/" ]
then
- echo "vfs.root.mountfrom=\"zfs:${ZPOOLNAME}\"" >> ${FSMNT}/boot/loader.conf
- FOUNDZFSROOT="${ZPOOLNAME}"
+ # Make sure we haven't already added the zfs boot line when
+ # Creating a dedicated "/boot" partition
+ cat ${FSMNT}/boot/loader.conf | grep "vfs.root.mountfrom=" >/dev/null 2>/dev/null
+ if [ "$?" != "0" ] ; then
+ echo "vfs.root.mountfrom=\"zfs:${ZPOOLNAME}\"" >> ${FSMNT}/boot/loader.conf
+ fi
+ FOUNDZFSROOT="${ZPOOLNAME}" ; export FOUNDZFSROOT
fi
done
FOUNDZFS="1"
@@ -79,12 +83,29 @@
fi
done
- # If are using a ZFS on "/" set it to legacy
- if [ ! -z "${FOUNDZFSROOT}" ]
- then
- rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}"
- fi
+};
+# Function which performs the specific setup for using a /boot partition
+setup_dedicated_boot_part()
+{
+ ROOTFS="${1}"
+ ROOTFSTYPE="${2}"
+ BOOTFS="${3}"
+ BOOTMNT="${4}"
+
+ # Set the root mount in loader.conf
+ echo "vfs.root.mountfrom=\"${ROOTFSTYPE}:${ROOTFS}\"" >> ${FSMNT}/boot/loader.conf
+ 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 "rmdir ${FSMNT}/boot"
+
+ # Strip the '/' from BOOTMNT before making symlink
+ BOOTMNTNS="`echo ${BOOTMNT} | sed 's|/||g'`"
+ rc_halt "chroot ${FSMNT} ln -s ${BOOTMNTNS}/boot /boot"
+
};
# Function which creates the /etc/fstab for the installed system
@@ -118,6 +139,37 @@
# Unset EXT
EXT=""
+ # Figure out if we are using a glabel, or the raw name for this entry
+ if [ ! -z "${PARTLABEL}" ]
+ then
+ DEVICE="label/${PARTLABEL}"
+ else
+ # Check if using encryption
+ if [ "${PARTENC}" = "ON" ] ; then
+ EXT=".eli"
+ fi
+
+ if [ "${PARTFS}" = "UFS+J" ] ; then
+ EXT="${EXT}.journal"
+ fi
+ DEVICE="${PART}${EXT}"
+ fi
+
+
+ # Set our ROOTFSTYPE for loader.conf if necessary
+ check_for_mount "${PARTMNT}" "/"
+ if [ "$?" = "0" ] ; then
+ if [ "${PARTFS}" = "ZFS" ] ; then
+ ROOTFSTYPE="zfs"
+ get_zpool_name "${PART}"
+ ZPOOLNAME="${VAL}"
+ ROOTFS="${ZPOOLNAME}"
+ else
+ ROOTFS="${DEVICE}"
+ ROOTFSTYPE="ufs"
+ fi
+ fi
+
# Only create non-zfs partitions
if [ "${PARTFS}" != "ZFS" ]
then
@@ -127,21 +179,11 @@
setup_gjournal
fi
- # Figure out if we are using a glabel, or the raw name for this entry
- if [ ! -z "${PARTLABEL}" ]
- then
- DEVICE="label/${PARTLABEL}"
- else
- # Check if using encryption
- if [ "${PARTENC}" = "ON" ] ; then
- EXT=".eli"
- fi
-
- if [ "${PARTFS}" = "UFS+J" ] ; then
- EXT="${EXT}.journal"
- fi
-
- DEVICE="${PART}${EXT}"
+ # Save the BOOTFS for call at the end
+ if [ "${PARTMNT}" = "/boot" ] ; then
+ BOOTFS="${PART}${EXT}"
+ BOOTMNT="${BOOT_PART_MOUNT}"
+ PARTMNT="${BOOTMNT}"
fi
# Echo out the fstab entry now
@@ -163,6 +205,11 @@
echo "tmpfs /tmp tmpfs rw,mode=1777 0 0" >> ${FSTAB}
fi
+ # If we have a dedicated /boot, run the post-install setup of it now
+ if [ ! -z "${BOOTMNT}" ] ; then
+ setup_dedicated_boot_part "${ROOTFS}" "${ROOTFSTYPE}" "${BOOTFS}" "${BOOTMNT}"
+ fi
+
};
# Setup our disk mirroring with gmirror
@@ -324,13 +371,13 @@
setup_geli_loading
fi
- # Generate the fstab for the installed system
- setup_fstab
-
# Set a hostname on the install system
setup_hostname
# Set the root_pw if it is specified
set_root_pw
+ # Generate the fstab for the installed system
+ setup_fstab
+
};
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh 2010-03-05 10:03:41 UTC (rev 6360)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh 2010-03-05 20:57:38 UTC (rev 6361)
@@ -22,6 +22,9 @@
rc_nohalt "gpart delete -i ${i} ${DISK}"
fi
done
+
+ rc_nohalt "dd if=/dev/zero of=/dev/${DISK} count=3000"
+
};
# Function to export all zpools before starting an install
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-parse.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-parse.sh 2010-03-05 10:03:41 UTC (rev 6360)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-parse.sh 2010-03-05 20:57:38 UTC (rev 6361)
@@ -164,3 +164,19 @@
};
+# Loop to check for a specified mount-point in a list
+check_for_mount()
+{
+ MNTS="${1}"
+ FINDMNT="${2}"
+
+ # Check if we found a valid root partition
+ for CHECKMNT in `echo ${MNTS} | sed 's|,| |g'`
+ do
+ if [ "${CHECKMNT}" = "${FINDMNT}" ] ; then
+ return 0
+ fi
+ done
+
+ return 1
+};
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh 2010-03-05 10:03:41 UTC (rev 6360)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh 2010-03-05 20:57:38 UTC (rev 6361)
@@ -54,7 +54,7 @@
# Check if we've found "/", and unmount that last
if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
then
- rc_nohalt "umount -f ${FSMNT}${PARTMNT}"
+ rc_halt "umount -f /dev/${PART}"
# Re-check if we are missing a label for this device and create it again if so
if [ ! -e "/dev/label/${PARTLABEL}" ]
@@ -86,6 +86,14 @@
# Last lets the /mnt partition
#########################################################
rc_nohalt "umount -f ${FSMNT}"
+
+ # If are using a ZFS on "/" set it to legacy
+ if [ ! -z "${FOUNDZFSROOT}" ]
+ then
+ rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}"
+ fi
+
+ # If we need to relabel "/" do it now
if [ ! -z "${ROOTRELABEL}" ]
then
${ROOTRELABEL}
@@ -137,6 +145,7 @@
# 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 ${FSMNT}${PARTMNT}"
fi
done
Modified: pcbsd/trunk/pc-sysinstall/conf/pc-sysinstall.conf
===================================================================
--- pcbsd/trunk/pc-sysinstall/conf/pc-sysinstall.conf 2010-03-05 10:03:41 UTC (rev 6360)
+++ pcbsd/trunk/pc-sysinstall/conf/pc-sysinstall.conf 2010-03-05 20:57:38 UTC (rev 6361)
@@ -38,7 +38,8 @@
CDMNT="/cdmnt-install"
FSMNT="/mnt"
UZIP_DIR="/usr"
-export FSMNT CDMNT UZIP_DIR
+BOOT_PART_MOUNT="/boot-mount"
+export FSMNT CDMNT UZIP_DIR BOOT_PART_MOUNT
# Set the location of component files on DVD / usb / ftp
# Relative to CDMNT or the FTP root
More information about the Commits
mailing list