[PC-BSD Commits] r4788 - in pcbsd/trunk/pc-sysinstall: . backend
svn at pcbsd.org
svn at pcbsd.org
Tue Oct 27 11:07:45 PST 2009
Author: kris
Date: 2009-10-27 12:07:45 -0700 (Tue, 27 Oct 2009)
New Revision: 4788
Modified:
pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh
pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh
pcbsd/trunk/pc-sysinstall/pcinstall.cfg
Log:
Update to the pc-sysinstaller backend, supports ZFS on root now, and added bits for generating
/etc/fstab, and post-install cleanup
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh 2009-10-27 14:07:58 UTC (rev 4787)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh 2009-10-27 19:07:45 UTC (rev 4788)
@@ -127,16 +127,17 @@
#Erase any existing bootloader
echo "Wiping ${DISK} with dd" >>${LOGOUT}
- dd if=/dev/zero of=/dev/${DISK} count=1024 >>${LOGOUT} 2>>${LOGOUT}
+ dd if=/dev/zero of=/dev/${DISK} count=2048 >>${LOGOUT} 2>>${LOGOUT}
sleep 2
+
echo "Running fdisk on ${DISK}" >>${LOGOUT}
fdisk -I /dev/${DISK} >>${LOGOUT} 2>>${LOGOUT}
if [ "${BMANAGER}" = "bsd" ]
then
echo "Stamping boot sector on ${DISK}" >>${LOGOUT}
- boot0cfg -B -v -o packet /dev/${DISK} >>${LOGOUT} 2>>${LOGOUT}
+ gpart bootcode -b /boot/boot0 ${DISK} >>${LOGOUT} 2>>${LOGOUT}
fi
slice="${DISK}s1"
@@ -215,7 +216,7 @@
if [ "${BMANAGER}" = "bsd" ]
then
echo "Stamping boot sector on ${DISK}" >>${LOGOUT}
- boot0cfg -B -v -o packet /dev/${DISK} >>${LOGOUT} 2>>${LOGOUT}
+ gpart bootcode -b /boot/boot0 ${DISK} >>${LOGOUT} 2>>${LOGOUT}
fi
# Lets save our slice, so we know what to look for in the config file later on
@@ -296,7 +297,7 @@
if [ "${BMANAGER}" = "bsd" ]
then
echo "Stamping boot sector on ${DISK}" >>${LOGOUT}
- boot0cfg -B -v -o packet /dev/${DISK} >>${LOGOUT} 2>>${LOGOUT}
+ gpart bootcode -b /boot/boot0 ${DISK} >>${LOGOUT} 2>>${LOGOUT}
fi
# Lets save our slice, so we know what to look for in the config file later on
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh 2009-10-27 14:07:58 UTC (rev 4787)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh 2009-10-27 19:07:45 UTC (rev 4788)
@@ -2,9 +2,36 @@
# Functions related to disk operations using newfs
+# Function which performs the ZFS magic
+setup_zfs_filesystem()
+{
+ PART="$1"
+ PARTFS="$2"
+ PARTMNT="$3"
+ ROOTSLICE="`echo ${PART} | rev | cut -b 2- | rev`"
+ zpool create -f ${PART} ${PART} >>${LOGOUT} 2>>${LOGOUT}
+
+ # Check if we ended up with needing a zfs bootable partition
+ if [ "${PARTMNT}" = "/" -o "${PARTMNT}" = "/boot" ]
+ then
+ # Lets stamp the proper ZFS boot loader
+ echo "Setting up ZFS boot loader support"
+ echo "Setting up ZFS boot loader support" >>${LOGOUT}
+ zpool set bootfs=${PART} ${PART} >>${LOGOUT} 2>>${LOGOUT}
+ zpool export ${PART} >>${LOGOUT} 2>>${LOGOUT}
+ dd if=/boot/zfsboot of=/dev/${ROOTSLICE} count=1 >>${LOGOUT} 2>>${LOGOUT}
+ dd if=/boot/zfsboot of=/dev/${PART} skip=1 seek=1024 >>${LOGOUT} 2>>${LOGOUT}
+ zpool import ${PART} >>${LOGOUT} 2>>${LOGOUT}
+ fi
+
+ # Unmount this pool, don't need it auto-mounted by ZFS
+ umount /${PART}
+};
+
# Runs newfs on all the partiions which we've setup with bsdlabel
setup_filesystems()
{
+
# Lets go ahead and read through the saved partitions we created, and determine if we need to run
# newfs on any of them
for PART in `ls ${PARTDIR}`
@@ -37,12 +64,11 @@
newfs -O 2 -J /dev/${PART}.journal >>${LOGOUT} 2>>${LOGOUT}
;;
ZFS) echo "NEWFS: /dev/${PART} - ${PARTFS}"
- zpool create ${PART} ${PART} >>${LOGOUT} 2>>${LOGOUT}
+ setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}"
;;
SWAP) ;;
*) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
esac
-
done
};
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh 2009-10-27 14:07:58 UTC (rev 4787)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-unmount.sh 2009-10-27 19:07:45 UTC (rev 4788)
@@ -1,9 +1,97 @@
#!/bin/sh
# Functions which unmount all mounted disk filesystems
+# Finishes up with ZFS setup before unmounting
+zfs_cleanup()
+{
+ # 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}`
+ do
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+
+ 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
+
+};
+
# 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
##################################################################
for PART in `ls ${PARTDIR}`
@@ -12,8 +100,13 @@
PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+ if [ "${PARTFS}" = "SWAP" ]
+ then
+ swapoff /dev/${PART}
+ fi
+
# Check if we've found "/" again, don't need to mount it twice
- if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" ]
+ if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
then
umount ${FSMNT}${PARTMNT} >/dev/null 2>/dev/null
if [ "$?" != "0" ]
@@ -31,4 +124,7 @@
exit_err "ERROR: Failed to unmount ${FSMNT}"
fi
+ # Unmount our CDMNT
+ umount ${CDMNT} >/dev/null 2>/dev/null
+
};
Modified: pcbsd/trunk/pc-sysinstall/pcinstall.cfg
===================================================================
--- pcbsd/trunk/pc-sysinstall/pcinstall.cfg 2009-10-27 14:07:58 UTC (rev 4787)
+++ pcbsd/trunk/pc-sysinstall/pcinstall.cfg 2009-10-27 19:07:45 UTC (rev 4788)
@@ -12,10 +12,10 @@
# Setup the disk label
# All sizes are expressed in MB
-# Avail FS Types, UFS, UFS+S, UFS+J, ZFS
-disk0-part=UFS 500 /
+# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP
+disk0-part=ZFS 500 /
disk0-part=SWAP 2000 none
-disk0-part=UFS+S 0 /usr
+disk0-part=ZFS 0 /usr
# Size 0 means use the rest of the slice size
# Do it now!
commitDiskLabel
More information about the Commits
mailing list