[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#857047: [PATCH] live-build binary_hdd enablement for ppc64el



This patch enables the building of an HDD live image with persistence.

OVERVIEW
----------------------------------------------------------------------

If the LB_PERSIST variable is set to "auto" (config/binary) then a
secondary partition will be automatically created and configured
as a persistent storage device (you still need to add "persistence"
on LB_BOOTAPPEND_LIVE).

Using LB_PERSIST set to "auto" with LB_HDD_SIZE set to "auto"
(LB_HDD_SIZE is the primary partition size) then the same minimum
size will be used as both the primary partition size and the
persistent storage size partition (so two partitions are created
with the same minimum size each).

If a specific size is desired for LB_HDD_SIZE (the primary partition),
then setting LB_HDD_SIZE to the desired size will then be replicated
for the auto sizing of the LB_PERSIST persistent storage size.

If differing sizes are desired then use the LB_HDD_SIZE for defining
the first partition size and LB_PERSIST to define the persistent
storage size of the second partition, e.g. LB_HDD_SIZE=2048 and
LB_PERSIST=4096 (sizes in MB).

If no persistent storage is desired set LB_PERSIST to a non-numeric
string not equal to "auto", e.g. "noauto".

See the build log for output on values picked up during building:

	sudo lb build 2>&1 | tee /home/myuid/build.log
	grep "Image" /home/myuid/build.log

Another handy grep in the build log is:

	grep "binary_hdd" /home/myuid/build.log

Example usage (these tweaks expect that you already have
live-build installed and building properly with this patch):

config/build:
Type: hdd

config/binary:
LB_BOOTAPPEND_LIVE="boot=live persistence"
	Note: these are just adds for this feature

LB_BOOTLOADERS="grub-efi"

LB_HDD_SIZE="auto"

LB_PERSIST="auto"

LB_BOOTLOADER_PARTITION_SIZE="auto"

LB_HDD_PARTITION_TABLE_TYPE="auto"

LB_BOOTLOADER_PARTITION_TYPE="auto"

BUILDING
----------------------------------------------------------------------

IMPORTANT:
1 - You must build the ppc64el HDD image on a ppc64el host.
2 - You need to have grub2-common 2.02 or later.

TESTING

----------------------------------------------------------------------
Burn to a USB (be sure to replace sdX with your USB device name):

ppc64el platform ->
sudo dd if=/home/myid/live-image-ppc64el.img of=/dev/sdX && sync

amd64 platform ->
sudo dd if=/home/myid/live-image-amd64.img of=/dev/sdX && sync

----------------------------------------------------------------------

TEST ppc64el image (from ppc64el KVM Host):

sudo kvm -m 2G -hda live-image-ppc64el.img -nographic
-nodefaults -serial stdio

TEST ppc64el image (from x86_64 KVM Host or ppc64el KVM Host):

sudo apt-get install qemu-system-ppc

sudo qemu-system-ppc64 -m 2G -hda live-image-ppc64el.img -nographic
-nodefaults -serial stdio

----------------------------------------------------------------------

TEST amd64 ESP image (from x86_64 KVM Host):

sudo apt-get install qemu-system-x86
sudo apt-get install ovmf

sudo cp /usr/share/OVMF/OVMF_VARS.fd ~/live_OVMF_VARS.fd

sudo qemu-system-x86_64 -m 2G -enable-kvm
-vga qxl
-hda live-image-amd64.img
-drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd
-drive if=pflash,format=raw,file=live_OVMF_VARS.fd

----------------------------------------------------------------------

TEST amd64 bios_grub image (from x86_64 KVM Host):

sudo qemu-system-x86_64 -m 2G -hda live-image-amd64.img

----------------------------------------------------------------------

Signed-off-by: Deb McLemore <debmc@linux.vnet.ibm.com>
---
 functions/architectures.sh               |  10 +-
 functions/defaults.sh                    |  39 +-
 functions/losetup.sh                     |   6 +-
 functions/packages.sh                    |  15 +-
 scripts/build/binary_grub-efi            | 234 +++++++-----
 scripts/build/binary_grub-pc             |  11 +-
 scripts/build/binary_hdd                 | 611 ++++++++++++++++++++++++-------
 scripts/build/binary_iso                 | 113 +++---
 scripts/build/binary_linux-image         |   3 +-
 scripts/build/binary_loopback_cfg        |  80 +++-
 scripts/build/binary_netboot             |   5 +
 scripts/build/binary_rootfs              |   3 +-
 scripts/build/binary_syslinux            |  31 +-
 scripts/build/config                     |  75 +++-
 scripts/build/efi-image                  | 129 ++++---
 scripts/build/grub-cpmodules             |  27 +-
 scripts/build/installer_debian-installer |   6 +-
 17 files changed, 1019 insertions(+), 379 deletions(-)

diff --git a/functions/architectures.sh b/functions/architectures.sh
index 7c6c48c..452e99e 100755
--- a/functions/architectures.sh
+++ b/functions/architectures.sh
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -42,7 +43,7 @@ Check_architectures ()
 
 	if [ "${VALID}" = "false" ]
 	then
-		Echo_warning "skipping %s, foreign architecture(s)." "${0}"
+		Echo_warning "skipping %s, foreign architecture(s) - ${LB_ARCHITECTURES}." "${0}"
 		exit 0
 	fi
 }
@@ -65,11 +66,16 @@ Check_crossarchitectures ()
 			CROSS="powerpc ppc64"
 			;;
 
+		ppc64el)
+			CROSS="ppc64el"
+			;;
+
 		*)
 			CROSS="${HOST}"
 			;;
 	esac
 
+
 	if [ "${LB_ARCHITECTURES}" = "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" ]
 	then
 
@@ -112,7 +118,7 @@ Check_multiarchitectures ()
 						DESTDIR_INSTALL="${DESTDIR_INSTALL}.386"
 						;;
 
-					powerpc)
+					powerpc|ppc64el)
 						DESTDIR="${DESTDIR}.ppc"
 						DESTDIR_LIVE="${DESTDIR_LIVE}.ppc"
 						DESTDIR_INSTALL="${DESTDIR_INSTALL}.ppc"
diff --git a/functions/defaults.sh b/functions/defaults.sh
index de3bb24..36092df 100755
--- a/functions/defaults.sh
+++ b/functions/defaults.sh
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -443,7 +444,7 @@ Set_defaults ()
 			esac
 			;;
 
-		powerpc)
+		powerpc|powerpc64)
 			case "${LB_MODE}" in
 				progress-linux)
 					Echo_error "Architecture ${LB_ARCHITECTURES} not supported in the ${LB_MODE} mode."
@@ -456,6 +457,19 @@ Set_defaults ()
 			esac
 			;;
 
+		ppc64el)
+			case "${LB_MODE}" in
+				progress-linux)
+					Echo_error "Architecture ${LB_ARCHITECTURES} not supported in the ${LB_MODE} mode."
+					exit 1
+					;;
+
+				*)
+					LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS:-generic}"
+					;;
+			esac
+			;;
+
 		s390x)
 			case "${LB_MODE}" in
 				progress-linux)
@@ -532,7 +546,10 @@ Set_defaults ()
 	then
 		case "${LB_ARCHITECTURES}" in
 			amd64|i386)
-				LB_BOOTLOADERS="syslinux,grub-efi"
+				LB_BOOTLOADERS="syslinux"
+				;;
+			ppc64el)
+				LB_BOOTLOADERS="grub-efi"
 				;;
 		esac
 	fi
@@ -678,6 +695,24 @@ Set_defaults ()
 	# Setting hdd size
 	LB_HDD_SIZE="${LB_HDD_SIZE:-auto}"
 
+	# Setting hdd partition start
+	LB_HDD_PARTITION_START="${LB_HDD_PARTITION_START:-auto}"
+
+	# Setting persistence storage
+	LB_PERSIST="${LB_PERSIST:-auto}"
+
+	# Setting bootloader partition size
+	LB_BOOTLOADER_PARTITION_SIZE="${LB_BOOTLOADER_PARTITION_SIZE:-auto}"
+
+	# Setting hdd partition table type
+	LB_HDD_PARTITION_TABLE_TYPE="${LB_HDD_PARTITION_TABLE_TYPE:-auto}"
+
+	# Set the type of the bootloader partition
+	LB_BOOTLOADER_PARTITION_TYPE="${LB_BOOTLOADER_PARTITION_TYPE:-auto}"
+
+	# Set the sleep interval for timing between read/write, mount operations
+	LB_SLEEP_INTERVAL="${LB_SLEEP_INTERVAL:-1}"
+
 	# Setting iso volume
 	case "${LB_MODE}" in
 		debian)
diff --git a/functions/losetup.sh b/functions/losetup.sh
index 0346ff6..530d3d0 100755
--- a/functions/losetup.sh
+++ b/functions/losetup.sh
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -85,12 +86,13 @@ Calculate_partition_size_without_journal ()
 	WITHOUT_JOURNAL_ORIGINAL_SIZE="${1}"
 	WITHOUT_JOURNAL_FILESYSTEM="${2}"
 
+	# Making PERCENT minimum 15 percent since random hits at lower values caused bad i/o
 	case "${WITHOUT_JOURNAL_FILESYSTEM}" in
 		ext2|ext3|ext4)
-			PERCENT="6"
+			PERCENT="15"
 			;;
 		*)
-			PERCENT="3"
+			PERCENT="15"
 			;;
 	esac
 
diff --git a/functions/packages.sh b/functions/packages.sh
index c2f7cfa..1c16af0 100755
--- a/functions/packages.sh
+++ b/functions/packages.sh
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -41,6 +42,16 @@ Install_package ()
 				Chroot chroot "aptitude install --without-recommends ${APTITUDE_OPTIONS} ${_LB_PACKAGES}"
 				;;
 		esac
+	else
+		case "${LB_APT}" in
+			apt|apt-get)
+				apt-get install -o APT::Install-Recommends=false ${APT_OPTIONS} ${_LB_PACKAGES}
+				;;
+
+			aptitude)
+				aptitude install --without-recommends ${APTITUDE_OPTIONS} ${_LB_PACKAGES}
+				;;
+		esac
 	fi
 }
 
@@ -82,11 +93,11 @@ Check_installed ()
 	else
 		if which dpkg-query > /dev/null 2>&1
 		then
-			if dpkg-query -s "${PACKAGE}" 2> /dev/null | grep -qs "Status: install"
+			if dpkg-query -s ${PACKAGE} | grep -qs "Status: install"
 			then
 				INSTALL_STATUS=0
 			else
-				INSTALL_STATUS=1
+				INSTALL_STATUS=2
 			fi
 		else
 			if [ ! -e "${FILE}" ]
diff --git a/scripts/build/binary_grub-efi b/scripts/build/binary_grub-efi
index 6d158cd..7301a48 100755
--- a/scripts/build/binary_grub-efi
+++ b/scripts/build/binary_grub-efi
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2016 Adrian Gibanel Lopez <adrian15sgd@gmail.com>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -26,7 +27,7 @@ Set_defaults
 
 Check_Any_Bootloader_Role "grub-efi"
 
-Echo_message "Begin preparing Grub based EFI support..."
+Echo_message "Begin preparing Grub Images for BIOS, UEFI or PReP ..."
 
 # Requiring stage file
 Require_stagefile .build/config .build/bootstrap
@@ -41,7 +42,7 @@ Check_lockfile .lock
 Create_lockfile .lock
 
 # Check architecture
-Check_architectures amd64 i386
+Check_architectures amd64 i386 ppc64el
 Check_crossarchitectures
 
 # Checking depends
@@ -49,59 +50,74 @@ case "${LB_BUILD_WITH_CHROOT}" in
 	true)
 		_CHROOT_DIR=""
 
-		Check_package chroot /usr/lib/grub/x86_64-efi/configfile.mod grub-efi-amd64-bin
-		Check_package chroot /usr/lib/grub/i386-efi/configfile.mod grub-efi-ia32-bin
+		case "${LB_ARCHITECTURES}" in
+			amd64|i386)
+				case "${LB_BOOTLOADER_PARTITION_TYPE}" in
+					esp)
+						Check_package chroot /usr/lib/grub/x86_64-efi/configfile.mod grub-efi-amd64-bin
+						Check_package chroot /usr/lib/grub/i386-efi/configfile.mod grub-efi-ia32-bin
+						_TARGET_FORMAT="esp"
+						;;
+					bios_grub)
+						Check_package chroot /usr/lib/grub/i386-pc/configfile.mod grub-pc-bin
+						Check_package host /usr/sbin/grub-bios-setup grub-pc
+						_TARGET_FORMAT="i386-pc"
+						;;
+					*)
+						if [ -d /sys/firmware/efi ]
+						then
+							Check_package chroot /usr/lib/grub/x86_64-efi/configfile.mod grub-efi-amd64-bin
+							Check_package chroot /usr/lib/grub/i386-efi/configfile.mod grub-efi-ia32-bin
+							_TARGET_FORMAT="esp"
+						else
+							Check_package chroot /usr/lib/grub/i386-pc/configfile.mod grub-pc-bin
+							Check_package host /usr/sbin/grub-bios-setup grub-pc
+							_TARGET_FORMAT="i386-pc"
+						fi
+						;;
+				esac
+				;;
+			ppc64el)
+				Check_package chroot /usr/lib/grub/powerpc-ieee1275/configfile.mod grub-ieee1275
+				_TARGET_FORMAT="powerpc-ieee1275"
+				;;
+			*)
+				Echo_error "Architecture of ${LB_ARCHITECTURES} not supported for binary_grub-efi."
+				exit 1
+				;;
+		esac
+
 		Check_package chroot /usr/bin/grub-mkimage grub-common
 		Check_package chroot /usr/bin/mcopy mtools
 		Check_package chroot /sbin/mkfs.msdos dosfstools
-		;;
-
-	false)
-		_CHROOT_DIR="chroot"
-
-		if [ ! -e /usr/lib/grub/x86_64-efi ]
-		then
-			# grub-efi-amd64-bin
-			Echo_error "/usr/lib/grub/x86_64-efi - no such directory"
-			exit 1
-		fi
-
-		if [ ! -e /usr/lib/grub/i386-efi ]
-		then
-			# grub-efi-ia32-bin
-			Echo_error "/usr/lib/grub/i386-efi - no such directory"
-			exit 1
-		fi
-
-		if [ ! -e /usr/bin/grub-mkimage ]
-		then
-			# grub-common
-			Echo_error "/usr/bin/grub-mkimage - no such file."
-			exit 1
-		fi
 
-		if [ ! -e /usr/bin/mcopy ]
-		then
-			# mtools
-			Echo_error "/usr/bin/mcopy - no such file."
-			exit 1
-		fi
-
-		if [ ! -e /sbin/mkfs.msdos ]
-		then
-			# dosfstools
-			Echo_error "/sbin/mkfs.msdos - no such file."
-			exit 1
-		fi
 		;;
+
+	*)
+		Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported in binary_grub-efi without building \
+			with LB_BUILD_WITH_CHROOT set to \"true\"."
+		exit 1
 esac
 
 # Setting destination directory
 case "${LIVE_IMAGE_TYPE}" in
+        iso*)
+                case "${LB_INITRAMFS}" in
+                        live-boot)
+                                DESTDIR_LIVE="binary/live"
+                                ;;
+
+                        *) # this case as placeholder to work on non-live-boot path
+                                DESTDIR_LIVE="binary/live"
+                                ;;
+                esac
+
+                DESTDIR_INSTALL="binary/install"
+                ;;
+
 	hdd*|netboot)
-		Echo_warning "Bootloader in this image type not yet supported by live-build."
-		Echo_warning "This would produce a not bootable image, aborting (FIXME)."
-		exit 1
+		DESTDIR_LIVE="binary/live"
+		Echo_message "LB_BOOTLOADERS of ${LB_BOOTLOADERS} in binary_grub-efi of LIVE_IMAGE_TYPE of ${LIVE_IMAGE_TYPE} on architecture of ${LB_ARCHITECTURES} is in alpha-test for binary_grub-efi (Architecture of ppc64el being actively tested Jan 2017)."
 	;;
 esac
 
@@ -111,21 +127,36 @@ Restore_cache cache/packages.binary
 # Installing depends
 Install_package
 
-# Cleanup files that we generate
-rm -rf binary/boot/efi.img binary/boot/grub/i386-efi/ binary/boot/grub/x86_64-efi
+# Cleanup files that we generate to restore fresh state
+case "${LB_ARCHITECTURES}" in
+	ppc64el)
+		rm -rf binary/boot/grub/powerpc-ieee1275-efi
+		;;
+	amd64|i386)
+		rm -rf binary/boot/grub/x86_64-efi/
+		rm -rf binary/boot/grub/i386-efi/
+		rm -rf binary/boot/grub/i386-pc/
+		;;
+esac
 
 # This is workaround till both efi-image and grub-cpmodules are put into a binary package
 case "${LB_BUILD_WITH_CHROOT}" in
-        true)
+	true)
 		if [ ! -e "${LIVE_BUILD}" ] ; then
 			LIVE_BUILD_PATH="/usr/lib/live/build"
 		else
 			LIVE_BUILD_PATH="${LIVE_BUILD}/scripts/build"
 		fi
 		mkdir -p chroot/${LIVE_BUILD_PATH}
+		case "${LB_ARCHITECTURES}" in
+			ppc64el)
+				mkdir -p binary/boot/grub
+				mkdir -p binary/ppc/chrp
+				;;
+		esac
 		cp "${LIVE_BUILD_PATH}/efi-image" "chroot/${LIVE_BUILD_PATH}"
 		cp "${LIVE_BUILD_PATH}/grub-cpmodules" "chroot/${LIVE_BUILD_PATH}"
-        ;;
+		;;
 esac
 #####
 cat >binary.sh <<END
@@ -133,48 +164,40 @@ cat >binary.sh <<END
 
 set -e
 
-PRE_EFI_IMAGE_PATH="${PATH}"
 if [ ! -e "${LIVE_BUILD}" ] ; then
-	LIVE_BUILD_PATH="/usr/lib/live/build"
+        LIVE_BUILD_PATH="/usr/lib/live/build"
 else
-	LIVE_BUILD_PATH="${LIVE_BUILD}/scripts/build"
+        LIVE_BUILD_PATH="${LIVE_BUILD}/scripts/build"
 fi
 
-PATH="${PATH}:\${LIVE_BUILD_PATH}" # Make sure grub-cpmodules is used as if it was installed in the system
-
-"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-x86_64-efi/" "x86_64-efi" "x64" "debian-live/amd64"
-mkdir -p ${_CHROOT_DIR}/grub-efi-temp/efi/boot
-mcopy -n -i ${_CHROOT_DIR}/grub-efi-temp-x86_64-efi/efi.img '::efi/boot/boot*.efi' ${_CHROOT_DIR}/grub-efi-temp/efi/boot
-cp -r "${_CHROOT_DIR}"/grub-efi-temp-x86_64-efi/* "${_CHROOT_DIR}/grub-efi-temp/"
-
-"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-i386-efi/" "i386-efi" "ia32" "debian-live/i386"
-PATH="\${PRE_EFI_IMAGE_PATH}"
-mkdir -p ${_CHROOT_DIR}/grub-efi-temp/efi/boot
-mcopy -n -i ${_CHROOT_DIR}/grub-efi-temp-i386-efi/efi.img '::efi/boot/boot*.efi' ${_CHROOT_DIR}/grub-efi-temp/efi/boot
-cp -r "${_CHROOT_DIR}"/grub-efi-temp-i386-efi/* "${_CHROOT_DIR}/grub-efi-temp/"
-
-# The code below is adapted from tools/boot/jessie/boot-x86
-# in debian-cd
-
-# Stuff the EFI boot files into a FAT filesystem, making it as
-# small as possible.  24KiB headroom seems to be enough;
-# (x+31)/32*32 rounds up to multiple of 32.
-# This is the same as in efi-image, but we need to redo it here in
-# the case of a multi-arch amd64/i386 image
-
-size=0
-for file in ${_CHROOT_DIR}/grub-efi-temp/efi/boot/boot*.efi; do
-	size=\$((\$size + \$(stat -c %s "\$file")))
-done
-
-blocks=\$(((\$size / 1024 + 55) / 32 * 32 ))
-
-rm -f ${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img
-mkfs.msdos -C "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" \$blocks >/dev/null
-mmd -i "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" ::efi
-mmd -i "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" ::efi/boot
-mcopy -o -i "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" ${_CHROOT_DIR}/grub-efi-temp/efi/boot/boot*.efi \
-	"::efi/boot"
+case "${LB_ARCHITECTURES}" in
+        amd64|i386)
+		case "${_TARGET_FORMAT}" in
+			i386-pc)
+				"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-i386-pc/boot/grub" "i386-pc" "i386-pc" "core.img"
+				"\${LIVE_BUILD_PATH}/grub-cpmodules" "${_CHROOT_DIR}/grub-efi-temp-i386-pc/boot/grub" "i386-pc"
+				;;
+			esp)
+				"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-x86_64-efi/boot/grub" "x86_64-efi" "x64" "x86_64-efi.efi"
+				"\${LIVE_BUILD_PATH}/grub-cpmodules" "${_CHROOT_DIR}/grub-efi-temp-x86_64-efi/boot/grub" "x86_64-efi"
+
+				"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-i386-efi/boot/grub" "i386-efi" "ia32" "i386-efi.efi"
+				"\${LIVE_BUILD_PATH}/grub-cpmodules" "${_CHROOT_DIR}/grub-efi-temp-i386-efi/boot/grub" "i386-efi"
+				;;
+		esac
+		;;
+
+	ppc64el)
+		"\${LIVE_BUILD_PATH}/efi-image" "${_CHROOT_DIR}/grub-efi-temp-powerpc-ieee1275-efi/boot/grub" "powerpc-ieee1275" "powerpc" "debian-live/ppc64el"
+		"\${LIVE_BUILD_PATH}/grub-cpmodules" "${_CHROOT_DIR}/grub-efi-temp-powerpc-ieee1275-efi/boot/grub" "powerpc-ieee1275"
+		;;
+
+	*)
+		echo "ERROR: can't provide EFI boot support to architecture ${LB_ARCHITECTURES}" >&2
+		exit 1
+		;;
+esac
+
 END
 
 case "${LB_BUILD_WITH_CHROOT}" in
@@ -196,15 +219,36 @@ case "${LB_BUILD_WITH_CHROOT}" in
 		;;
 esac
 
-# Remove unnecessary files
-rm -f chroot/grub-efi-temp/bootnetia32.efi
-rm -f chroot/grub-efi-temp/bootnetx64.efi
+case "${LB_ARCHITECTURES}" in
+	ppc64el)
+		# binary/ppc/bootinfo.txt is placed for a PReP boot
+		cp chroot/usr/lib/grub/powerpc-ieee1275/bootinfo.txt binary/ppc
+		cp chroot/usr/share/grub/unicode.pf2 binary/boot/grub
+		cp -r chroot/grub-efi-temp-powerpc-ieee1275-efi/* binary
+		;;
+	amd64|i386)
+		cp chroot/usr/share/grub/unicode.pf2 binary/boot/grub
+		case "${_TARGET_FORMAT}" in
+			esp)
+				cp -r chroot/grub-efi-temp-x86_64-efi/* binary
+				cp -r chroot/grub-efi-temp-i386-efi/*   binary
+				;;
+			*)
+				cp -r chroot/grub-efi-temp-i386-pc/* binary
+				;;
+		esac
+esac
 
-mkdir -p binary
-cp -r chroot/grub-efi-temp/* binary/
-rm -rf chroot/grub-efi-temp-x86_64-efi
-rm -rf chroot/grub-efi-temp-i386-efi
-rm -rf chroot/grub-efi-temp
+case "${LB_ARCHITECTURES}" in
+	ppc64el)
+		rm -rf chroot/grub-efi-temp-powerpc-ieee1275-efi
+		;;
+	amd64|i386)
+		rm -rf chroot/grub-efi-temp-i386-pc
+		rm -rf chroot/grub-efi-temp-x86_64-efi
+		rm -rf chroot/grub-efi-temp-i386-efi
+		;;
+esac
 
 # We rely on: binary_loopback_cfg to generate grub.cfg and other configuration files
 
diff --git a/scripts/build/binary_grub-pc b/scripts/build/binary_grub-pc
index 6d111a7..d949e3b 100755
--- a/scripts/build/binary_grub-pc
+++ b/scripts/build/binary_grub-pc
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -41,9 +42,17 @@ Check_lockfile .lock
 Create_lockfile .lock
 
 # Check architecture
-Check_architectures amd64 i386
+# Need to include ppc64el in checks to stop processing if defined
+Check_architectures amd64 i386 ppc64el
 Check_crossarchitectures
 
+case "${LB_ARCHITECTURES}" in
+	ppc*)
+		Echo_error "Architecture ${LB_ARCHITECTURES} is not supported in binary_grub-pc (try LB_BOOTLOADERS of \"grub-efi\" in config/binary)."
+		exit 1
+		;;
+esac
+
 # Checking depends
 Check_package chroot /usr/bin/grub-mkimage grub-pc
 
diff --git a/scripts/build/binary_hdd b/scripts/build/binary_hdd
index 400403c..7bcef63 100755
--- a/scripts/build/binary_hdd
+++ b/scripts/build/binary_hdd
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -14,7 +15,7 @@ set -e
 [ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
 
 # Setting static variables
-DESCRIPTION="$(Echo 'build binary image')"
+DESCRIPTION="$(Echo 'build binary Image')"
 HELP=""
 USAGE="${PROGRAM} [--force]"
 
@@ -29,7 +30,7 @@ then
 	exit 0
 fi
 
-Echo_message "Begin building binary hdd image..."
+Echo_message "Begin building binary hdd Image..."
 
 # Requiring stage file
 Require_stagefile .build/config .build/bootstrap .build/chroot_proc
@@ -56,20 +57,19 @@ esac
 
 Check_package chroot /usr/share/doc/mtools mtools
 Check_package chroot /sbin/parted parted
+Check_package host /sbin/kpartx kpartx
+Check_package host /sbin/sgdisk gdisk
 
-echo "${LB_BOOTLOADERS}" | \
-while IFS="," read -r BOOTLOADER
-do
-	case "${BOOTLOADER}" in
-		grub)
-			Check_package chroot /usr/sbin/grub grub
+case "${LB_FIRST_BOOTLOADER}" in
+		syslinux)
+			Check_package host /usr/bin/syslinux syslinux
+			Check_package host /usr/bin/extlinux extlinux
 			;;
-	esac
-done
+esac
 
-case ${LB_FIRST_BOOTLOADER} in
+case "${LB_FIRST_BOOTLOADER}" in
 		syslinux)
-			case ${LB_BINARY_FILESYSTEM} in
+			case "${LB_BINARY_FILESYSTEM}" in
 				fat*|ntfs)
 					_BOOTLOADER=syslinux
 					;;
@@ -77,11 +77,41 @@ case ${LB_FIRST_BOOTLOADER} in
 					_BOOTLOADER=extlinux
 					;;
 				*)
-					Echo_error "syslinux/extlinux doesn't support ${LB_BINARY_FILESYSTEM}"
+					Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported for LB_BINARY_FILESYSTEM of ${LB_BINARY_FILESYSTEM} with LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} in binary_hdd."
+					exit 1
+					;;
+			esac
+			case "${LB_ARCHITECTURES}" in
+				amd64|i386)
+					Check_package chroot /usr/bin/${_BOOTLOADER} ${_BOOTLOADER}
+					;;
+				ppc64el)
+					Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported for LB_BINARY_FILESYSTEM of ${LB_BINARY_FILESYSTEM} with LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} in binary_hdd (try LB_BOOTLOADERS of \"grub-efi\" in config/binary)."
+					exit 1
+					;;
+				*)
+					Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported for LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} in binary_hdd."
+					exit 1
+					;;
+			esac
+			;;
+		grub-efi)
+			case "${LB_ARCHITECTURES}" in
+				ppc64el)
+					Echo_warning "Architecture of ${LB_ARCHITECTURES} with LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} is in alpha-test for binary_hdd  (Architecture of ppc64el being actively tested Jan 2017)."
+					;;
+				amd64|i386)
+					Echo_warning "Architecture of ${LB_ARCHITECTURES} with LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} is in alpha-test for binary_hdd  (Architecture of i386-pc being actively tested Jan 2017)."
+					;;
+				*)
+					Echo_error "Architecture of ${LB_ARCHITECTURES} with LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} in LB_BOOTLOADERS of ${LB_BOOTLOADERS} is not supported for LIVE_IMAGE_TYPE of ${LIVE_IMAGE_TYPE} in binary_hdd, try LB_BOOTLOADERS of \"syslinux\" (config/binary)."
 					exit 1
 					;;
 			esac
-			Check_package chroot /usr/bin/${_BOOTLOADER} ${_BOOTLOADER}
+			;;
+		*)
+			Echo_error "LB_FIRST_BOOTLOADER of ${LB_FIRST_BOOTLOADER} in LB_BOOTLOADERS of ${LB_BOOTLOADERS} is not supported for LIVE_IMAGE_TYPE of ${LIVE_IMAGE_TYPE} in binary_hdd."
+			exit 1
 			;;
 esac
 
@@ -106,7 +136,7 @@ then
 	export LB_BINARY_FILESYSTEM
 fi
 
-# Enforce fat32 if we have images in total bigger than 2GB
+# Enforce fat32 if we have Images in total bigger than 2GB
 if [ "${LB_BINARY_FILESYSTEM}" = "fat16" ] && [ "$(du -s binary | awk '{ print $1 }')" -gt "1900000" ]
 then
 	Echo_warning "FAT16 doesn't support partitions larger than 2GB, automatically enforcing FAT32"
@@ -124,29 +154,217 @@ then
 	export LB_BINARY_FILESYSTEM
 fi
 
-# Everything which comes here needs to be cleaned up,
-if [ "$LB_HDD_SIZE" = "auto" ];
+DU_DIM="$(du -ms binary | cut -f1)"
+REAL_DIM="$(Calculate_partition_size ${DU_DIM} ${LB_BINARY_FILESYSTEM})"
+ORIG_REAL_DIM=$REAL_DIM
+# really just placeholder to account for space needed by MBR in overall size calculations MB
+MBR_SPACE=1
+# HDD buffer is extra space needed to help account for alignment and available space for partition table overhead
+HDD_BUFFER=2
+
+# sizes in MB
+PREP_DEFAULT_SIZE=8
+
+# ESP's recommend
+ESP_DEFAULT_SIZE=550
+
+# BIOS_GRUB recommends
+BIOS_GRUB_DEFAULT_SIZE=2
+
+# For now lets limit the number of partitions to 4, need to re-visit code to support more than 4
+_MAX_PART_NUMS=4
+
+case "${LB_HDD_PARTITION_TABLE_TYPE}" in
+	auto|gpt)
+		if [ "${LB_FIRST_BOOTLOADER}" != "syslinux" ]
+		then
+			_GPT="true"
+		else
+			_GPT="false"
+			Echo_message "binary_hdd is going to use LB_HDD_PARTITION_TABLE_TYPE of \"msdos\" since the LB_FIRST_BOOTLOADER of \"${LB_FIRST_BOOTLOADER}\" was specified (since syslinux installs its bootloader into the MBR sector).  If some other layout is desired, please specify LB_BOOTLOADERS in config/binary with \"grub-efi\" to allow for GPT as the LB_HDD_PARTITION_TABLE_TYPE and to allow the installation of the grub bootloader."
+		fi
+		;;
+	*) # msdos falls in this branch
+		_GPT="false"
+		;;
+esac
+
+# first test to make sure an integer
+if [ "$LB_SLEEP_INTERVAL" -eq "$LB_SLEEP_INTERVAL" > /dev/null 2>&1 ]
 then
-	DU_DIM="$(du -ms binary | cut -f1)"
-	REAL_DIM="$(Calculate_partition_size ${DU_DIM} ${LB_BINARY_FILESYSTEM})"
+	LB_SLEEP_INTERVAL=$(($LB_SLEEP_INTERVAL))
 else
-	REAL_DIM=$LB_HDD_SIZE
+	LB_SLEEP_INTERVAL=1
 fi
 
-dd if=/dev/zero of=chroot/binary.img bs=1024k count=0 seek=${REAL_DIM}
-FREELO="$(${LB_LOSETUP} -f)"
-if [ ! -b chroot/${FREELO} ]
+case "${LB_BOOTLOADER_PARTITION_TYPE}" in
+	esp)
+		_TARGET_FORMAT="esp"
+		;;
+	bios_grub)
+		_TARGET_FORMAT="bios_grub"
+		;;
+	*)
+		if [ -d /sys/firmware/efi ]
+		then
+			_TARGET_FORMAT="esp"
+		else
+			_TARGET_FORMAT="bios_grub"
+		fi
+		;;
+esac
+
+case "${LB_BOOTLOADER_PARTITION_SIZE}" in
+	auto)
+		case "${LB_ARCHITECTURES}" in
+			ppc64el)
+				_BOOTLOADER_PART_SIZE=$PREP_DEFAULT_SIZE
+				;;
+			*)
+				if [ "${_TARGET_FORMAT}" = "esp" ]
+				then
+					_BOOTLOADER_PART_SIZE=$ESP_DEFAULT_SIZE
+				else
+					_BOOTLOADER_PART_SIZE=$BIOS_GRUB_DEFAULT_SIZE
+				fi
+				;;
+		esac
+		;;
+	*)
+		# first test to make sure an integer
+		if [ "$LB_BOOTLOADER_PARTITION_SIZE" -eq "$LB_BOOTLOADER_PARTITION_SIZE" > /dev/null 2>&1 ]
+		then
+			if [ "$LB_BOOTLOADER_PARTITION_SIZE" -gt "0" > /dev/null 2>&1 ]
+			then
+				_BOOTLOADER_PART_SIZE=$(($LB_BOOTLOADER_PARTITION_SIZE))
+			else
+				_BOOTLOADER_PART_SIZE=$PREP_DEFAULT_SIZE
+				# if a non-numeric value was given set to a valid value cross platform
+				# PReP default size used as a fail-safe value since anything greater is a problem on ppc64el
+				Echo_warning "binary_hdd the value given for LB_BOOTLOADER_PARTITION_SIZE \"${LB_BOOTLOADER_PARTITION_SIZE}\" was not \"auto\" or a valid numeric integer value, so ignoring and using the \"auto\" calculations.  If this is not desired, please update LB_BOOTLOADER_PARTITION_SIZE."
+			fi
+		else
+			_BOOTLOADER_PART_SIZE=$PREP_DEFAULT_SIZE
+			# if a non-numeric value was given set to a valid value cross platform
+			# PReP default size used as a fail-safe value since anything greater is a problem on ppc64el
+			Echo_warning "binary_hdd the value given for LB_BOOTLOADER_PARTITION_SIZE \"${LB_BOOTLOADER_PARTITION_SIZE}\" was not \"auto\" or a valid numeric integer value, so ignoring and using the \"auto\" calculations.  If this is not desired, please update LB_BOOTLOADER_PARTITION_SIZE."
+		fi
+		;;
+esac
+
+Echo_message "Image sizes and partition starts are input parameters used for creating partition layouts, however optimal settings are used which may alter these actual values to allow better alignments.  Using tools such as parted or gdisk will identify the actual physical layout."
+
+
+# first test to make sure an integer
+if [ "$LB_HDD_SIZE" -eq "$LB_HDD_SIZE" > /dev/null 2>&1 ]
 then
-	MAKEDEV="true"
+	if [ "$LB_HDD_SIZE" -ge $(($REAL_DIM+$MBR_SPACE)) ]
+	then
+		REAL_DIM=$LB_HDD_SIZE
+		Echo_message "LB_HDD_SIZE of ${LB_HDD_SIZE} MB will be used for input on creating the partition holding the base Image."
+	else
+		Echo_warning "LB_HDD_SIZE of ${LB_HDD_SIZE} MB is not large enough to hold the base Image plus the boot sector, so the minimum real size of ${ORIG_REAL_DIM} MB plus boot sector of ${MBR_SPACE} MB will be used to create the partition for the base Image."
+	fi
+fi
+
+PRIMARY_SIZE=$REAL_DIM
+PRIMARY_START=$MBR_SPACE
+BOOTLOADER_START=$MBR_SPACE
+REAL_START=$MBR_SPACE
 
-	mv chroot/dev chroot/dev.tmp
-	find /dev | cpio -dmpu chroot
+
+# first test to make sure an integer
+if [ "$LB_HDD_PARTITION_START" -eq "$LB_HDD_PARTITION_START" > /dev/null 2>&1 ]
+then
+	if [ "$LB_HDD_PARTITION_START" -ge "$MBR_SPACE" ]
+	# We use PRIMARY_END to build the Image so no need to check this offset to make sure it will fit
+	then
+		PRIMARY_START=$LB_HDD_PARTITION_START
+		BOOTLOADER_START=$LB_HDD_PARTITION_START
+		REAL_START=$LB_HDD_PARTITION_START
+		Echo_message "LB_HDD_PARTITION_START of ${LB_HDD_PARTITION_START} MB will be used for the desired start of the partition holding the base Image."
+	else
+		Echo_warning "LB_HDD_PARTITION_START of ${LB_HDD_PARTITION_START} MB is not able to be used (the MBR plus some space (e.g. alignment) is ${MBR_SPACE} MB). The Image has a base partition with a size of ${PRIMARY_SIZE} MB, so ignoring the LB_HDD_PARTITION_START value of ${LB_HDD_PARTITION_START} MB."
+	fi
 fi
 
-echo "!!! The following error/warning messages can be ignored !!!"
-Losetup $FREELO chroot/binary.img 0
+PRIMARY_END=$(($PRIMARY_START+$PRIMARY_SIZE))
+IMAGE_SIZE=$(($PRIMARY_SIZE))
+
+# megabytes
+MAKE_PERSIST="false"
+case "${LB_PERSIST}" in
+	auto)
+		PERSIST_START=$(($PRIMARY_END+1))
+		IMAGE_SIZE=$(($PRIMARY_SIZE*2))
+		PERSIST_SIZE=$(($PRIMARY_SIZE))
+		MAKE_PERSIST="true"
+		Echo_message "LB_PERSIST will be automatically creating an additional persistent storage partition of size ${PRIMARY_SIZE} MB in the Image, which is determined by the LB_HDD_SIZE, the LB_PERSIST size or the actual size of ${ORIG_REAL_DIM} MB."
+	;;
+	*)
+		# first test to make sure an integer
+		if [ "$LB_PERSIST" -eq "$LB_PERSIST" > /dev/null 2>&1 ]
+		then
+			if [ "$LB_PERSIST" -gt "0" ]
+			then
+				PERSIST_START=$(($PRIMARY_END+1))
+				PERSIST_SIZE=$(($LB_PERSIST))
+				IMAGE_SIZE=$(($PRIMARY_SIZE+$LB_PERSIST))
+				MAKE_PERSIST="true"
+				Echo_message "LB_PERSIST will be automatically creating an additional persistent storage partition in the Image of size ${LB_PERSIST} MB."
+			fi
+		fi
+	;;
+esac
+
+if [ "$MAKE_PERSIST" = "false" ]
+then
+	Echo_message "LB_PERSIST was not defined as either auto or a size specified in MB, so not adding a persistent storage partition.  The Image will not save changes across boot cycles."
+fi
 
-PARTITION_TABLE_TYPE="msdos"
+PREP_PARTNUM=1
+# Set the initial partnums, but they may get bumped if persist is used
+BOOTLOADER_DEVICE_PARTNUM=1
+PRIMARY_PARTNUM=1
+PERSIST_PARTNUM=2
+
+# Keeping architectures unique cases for now, these may be collapsed in the future
+case "${LB_ARCHITECTURES}" in
+	ppc64el)
+		# Need to add PReP partition
+		HDD_EXTRA_SIZE=$(($_BOOTLOADER_PART_SIZE))
+		# bump the partnum to account for additional PReP partition
+		PRIMARY_START=$(($PRIMARY_START+$_BOOTLOADER_PART_SIZE))
+		PRIMARY_END=$(($PRIMARY_END+$_BOOTLOADER_PART_SIZE))
+		PERSIST_START=$(($PERSIST_START+$_BOOTLOADER_PART_SIZE))
+		PRIMARY_PARTNUM=2
+		PERSIST_PARTNUM=3
+		;;
+	amd64|i386)
+		# Need to add BIOS boot partition or ESP
+		HDD_EXTRA_SIZE=$(($_BOOTLOADER_PART_SIZE))
+		# bump the partnum to account for additional BIOS boot partition
+		PRIMARY_START=$(($PRIMARY_START+$_BOOTLOADER_PART_SIZE))
+		PRIMARY_END=$(($PRIMARY_END+$_BOOTLOADER_PART_SIZE))
+		PERSIST_START=$(($PERSIST_START+$_BOOTLOADER_PART_SIZE))
+		PRIMARY_PARTNUM=2
+		PERSIST_PARTNUM=3
+		;;
+	*)
+		HDD_EXTRA_SIZE=0
+		;;
+esac
+
+# align the sizes
+
+# an additional 2M is appended to the HDD size to compensate for overhead
+REAL_HDD_SIZE=$(($IMAGE_SIZE+$REAL_START+$HDD_EXTRA_SIZE+$HDD_BUFFER))
+Echo_message "The Image size being built is ${REAL_HDD_SIZE} MB, which is determined by LB_HDD_SIZE (or default minimum of ${ORIG_REAL_DIM} MB), the MBR plus some alignment space of ${MBR_SPACE} MB and any automatic persistent storage and any additional extra size of ${HDD_EXTRA_SIZE} MB (which is the architecture specific bootloader space) and a small additional little buffer of ${HDD_BUFFER} MB for other overhead."
+
+dd if=/dev/zero of=chroot/binary.img bs=1024k count=0 seek=${REAL_HDD_SIZE}
+FREELO="$(${LB_LOSETUP} -f)"
+
+losetup ${FREELO} chroot/binary.img
 
 case "${LB_BINARY_FILESYSTEM}" in
 	ext2|ext3|ext4)
@@ -162,74 +380,140 @@ case "${LB_BINARY_FILESYSTEM}" in
 		;;
 
 	*)
-		Echo_error "Unsupported binary filesystem %s" "${LB_BINARY_FILESYSTEM}"
+		Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported for LB_BINARY_FILESYSTEM of ${LB_BINARY_FILESYSTEM} in binary_hdd."
 		exit 1
 		;;
 esac
 
-case "${LB_BUILD_WITH_CHROOT}" in
-	true)
-		Chroot chroot "parted -s ${FREELO} mklabel ${PARTITION_TABLE_TYPE}" || true
-		if [ "x${LB_HDD_PARTITION_START}" = "x" ];
-		then
-			Chroot chroot "parted -a optimal -s ${FREELO} mkpart primary\
-				${PARTITION_TYPE} 0% 100%" || true
-		else
-			Echo_message "using partition start at ${LB_HDD_PARTITION_START}"
-			Chroot chroot "parted -s ${FREELO} mkpart primary ${PARTITION_TYPE}\
-				${LB_HDD_PARTITION_START} 100%" || true
-		fi
-		Chroot chroot "parted -s ${FREELO} set 1 boot on" || true
-		Chroot chroot "parted -s ${FREELO} set 1 lba off" || true
+sgdisk -Z ${FREELO}
+sgdisk -o ${FREELO}
 
-		if [ "${LB_FIRST_BOOTLOADER}" = "syslinux" ]
-		then
-			dd if=chroot/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/mbr.bin of=${FREELO} bs=440 count=1
-		fi
-		;;
-
-	false)
-		parted -s ${FREELO} mklabel ${PARTITION_TABLE_TYPE} || true
-		if [ "x${LB_HDD_PARTITION_START}" = "x" ];
-		then
-			parted -a optimal -s ${FREELO} mkpart primary ${PARTITION_TYPE}\
-				0% 100% || true
-		else
-			Echo_message "using partition start at ${LB_HDD_PARTITION_START}"
-			parted -s ${FREELO} mkpart primary ${PARTITION_TYPE}\
-				${LB_HDD_PARTITION_START} 100% || true
-		fi
-		parted -s "${FREELO}" set 1 boot on || true
-		parted -s "${FREELO}" set 1 lba off || true
+# Prime the conversion partnums, we build the string
+CONVERT_PARTNUMS="1"
 
-		if [ "${LB_FIRST_BOOTLOADER}" = "syslinux" ]
-		then
-			dd if=/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/mbr.bin of=${FREELO} bs=440 count=1
-		fi
+case "${LB_ARCHITECTURES}" in
+	ppc64el)
+		# First partition for PReP install
+		sgdisk  -n ${PREP_PARTNUM}:${BOOTLOADER_START}M:+${_BOOTLOADER_PART_SIZE}M \
+			-t ${PREP_PARTNUM}:4100 -c ${PREP_PARTNUM}:"PowerPC PReP boot" ${FREELO}
+		CONVERT_PARTNUMS="1:2"
+		;;
+	amd64|i386)
+		case "${_TARGET_FORMAT}" in
+			esp)
+		# First partition for bootloader install
+		# This is for future use to help to allow customization post-build, this could be changed to ESP and extra HDD size added to manually customize
+		sgdisk -n ${BOOTLOADER_DEVICE_PARTNUM}:${BOOTLOADER_START}M:+${_BOOTLOADER_PART_SIZE}M -t ${BOOTLOADER_DEVICE_PARTNUM}:EF00 -c ${BOOTLOADER_DEVICE_PARTNUM}:"ESP  boot partition" ${FREELO}
+		CONVERT_PARTNUMS="1:2"
+
+				;;
+			*)
+		# First partition for bootloader install
+		# This is for future use to help to allow customization post-build, this could be changed to ESP and extra HDD size added to manually customize
+		sgdisk -n ${BOOTLOADER_DEVICE_PARTNUM}:${BOOTLOADER_START}M:+${_BOOTLOADER_PART_SIZE}M -t ${BOOTLOADER_DEVICE_PARTNUM}:EF02 -c ${BOOTLOADER_DEVICE_PARTNUM}:"BIOS boot partition" ${FREELO}
+		CONVERT_PARTNUMS="1:2"
+				;;
+		esac
+		;;
+	*)
+		Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported in binary_hdd.  Check your setup for a supported type."
+		exit 1
 		;;
 esac
 
-Lodetach ${FREELO}
+sgdisk -n ${PRIMARY_PARTNUM}:${PRIMARY_START}M:+${PRIMARY_SIZE}M -t ${PRIMARY_PARTNUM}:8300 -c ${PRIMARY_PARTNUM}:"Linux filesystem" ${FREELO}
+
+if [ "$MAKE_PERSIST" = "true" ]
+then
+	# Keeping architectures unique cases for now, may collapse in future
+	case "${LB_ARCHITECTURES}" in
+		amd64|i386)
+			CONVERT_PARTNUMS="1:2:3"
+			;;
+		ppc64el)
+			CONVERT_PARTNUMS="1:2:3"
+			;;
+	esac
+	sgdisk  -n ${PERSIST_PARTNUM}:${PERSIST_START}M:+${PERSIST_SIZE}M \
+		-t ${PERSIST_PARTNUM}:8300 \
+		-c ${PERSIST_PARTNUM}:"Linux filesystem" ${FREELO}
+	_PART_NUMS=3
+else
+	_PART_NUMS=2
+fi
+
+if [ "$_GPT" = "false" ]
+then
+			if [ "$_PART_NUMS" -le "$_MAX_PART_NUMS" ]
+			then
+				sgdisk -m ${CONVERT_PARTNUMS} ${FREELO}
+				case "${LB_ARCHITECTURES}" in
+					ppc64el)
+						MBR_PART_NUM_BOOT_FLAG=1
+						;;
+					*)
+						MBR_PART_NUM_BOOT_FLAG=$PRIMARY_PARTNUM
+						;;
+				esac
+				parted -s ${FREELO} set ${MBR_PART_NUM_BOOT_FLAG} boot on
+				Echo_message "binary_hdd setting MBR boot flag for partition number ${MBR_PART_NUM_BOOT_FLAG} (any EF00 or EF02 type partitions will be reflected as EF type in \"msdos\" partition layout."
+			else
+				Echo_error "Architecture of ${LB_ARCHITECTURES} with LB_BINARY_FILESYSTEM of ${LB_BINARY_FILESYSTEM} and LB_HDD_PARTITION_TABLE_TYPE of ${LB_HDD_PARTITION_TABLE_TYPE} has reached its maximum number of partitions.  You can check LB_HDD_PARTITION_TABLE_TYPE and set it to \"auto\" or \"gpt\" or try setting LB_PERSIST to \"noauto\" in config/binary to remove a partition (however you will lose the persistence feature if LB_PERSIST is set to \"noauto\")."
+				exit 1
+			fi
+else # _GPT = "true"
+	case "${LB_BINARY_FILESYSTEM}" in
+		ext2|ext3|ext4)
+			case "${LB_ARCHITECTURES}" in
+				amd64|i386)
+					sgdisk --attributes=${PRIMARY_PARTNUM}:set:2 ${FREELO}
+					# set bit 2 attribute (legacy BIOS bootable)
+					Echo_message "binary_hdd setting PRIMARY_PARTNUM to active (--attributes=${PRIMARY_PARTNUM}:set:2 ${FREELO}"
+					;;
+			esac
+			;;
+		*)
+			Echo_warning "Architecture of ${LB_ARCHITECTURES} is not supported for LB_BINARY_FILESYSTEM of ${LB_BINARY_FILESYSTEM} with use of GPT Partition Table Type (LB_HDD_PARTITION_TABLE_TYPE of \"${LB_HDD_PARTITION_TABLE_TYPE}\" from config/binary in binary_hdd, we will use LB_BINARY_FILESYSTEM of \"ext2\"."
+			OLD_BINARY_FILESYSTEM=$LB_BINARY_FILESYSTEM
+			LB_BINARY_FILESYSTEM="ext2"
+                        Echo_warning "LB_BINARY_FILESYSTEM is being updated to ${LB_BINARY_FILESYSTEM} (from ${OLD_BINARY_FILESYSTEM}) since the LB_HDD_PARTITION_TABLE_TYPE is being automatically determined (LB_HDD_PARTITION_TABLE_TYPE is \"${LB_HDD_PARTITION_TABLE_TYPE}\").  If this is not desired, please update LB_HDD_PARTITION_TABLE_TYPE to the desired value."
+			case "${LB_ARCHITECTURES}" in
+				amd64|i386)
+					sgdisk --attributes=${PRIMARY_PARTNUM}:set:2 ${FREELO}
+					# set bit 2 attribute (legacy BIOS bootable)
+					Echo_message "binary_hdd setting PRIMARY_PARTNUM to active (--attributes=${PRIMARY_PARTNUM}:set:2 ${FREELO}"
+					;;
+			esac
+			;;
+	esac
+	Echo_message "binary_hdd using GPT for creation of LB_HDD_PARTITION_TABLE_TYPE of \"${LB_HDD_PARTITION_TABLE_TYPE}\"."
+fi
+
+losetup -d ${FREELO}
+Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+sleep $LB_SLEEP_INTERVAL
 
 FREELO="$(${LB_LOSETUP} -f)"
-Losetup $FREELO chroot/binary.img 1
+losetup -P ${FREELO} chroot/binary.img
+Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+sleep $LB_SLEEP_INTERVAL
 
 case "${LB_BINARY_FILESYSTEM}" in
 	ext2|ext3|ext4)
 		MKFS="${LB_BINARY_FILESYSTEM}"
-		MKFS_OPTIONS="-L ${LB_HDD_LABEL} -m 0 -O ^64bit"
+		MKFS_OPTIONS="-b 4096 -L ${LB_HDD_LABEL}"
 		MOUNT_OPTIONS=""
 		;;
 
 	fat16)
 		MKFS="vfat"
-		MKFS_OPTIONS="-F 16 -n ${LB_HDD_LABEL}"
+		MKFS_OPTIONS="-F 16 -I -n ${LB_HDD_LABEL}"
 		MOUNT_OPTIONS=""
 		;;
 
 	fat32)
 		MKFS="vfat"
-		MKFS_OPTIONS="-F 32 -n ${LB_HDD_LABEL}"
+		MKFS_OPTIONS="-F 32 -I -n ${LB_HDD_LABEL}"
 		MOUNT_OPTIONS=""
 		;;
 
@@ -240,15 +524,18 @@ case "${LB_BINARY_FILESYSTEM}" in
 		;;
 esac
 
-case "${LB_BUILD_WITH_CHROOT}" in
-	true)
-		Chroot chroot "mkfs.${MKFS} ${MKFS_OPTIONS} ${FREELO}"
-		;;
+mkfs.${MKFS} ${MKFS_OPTIONS} ${FREELO}p${PRIMARY_PARTNUM}
+Echo_message "binary_hdd mkfs.${MKFS} ${MKFS_OPTIONS} ${FREELO}p${PRIMARY_PARTNUM}"
 
-	false)
-		mkfs.${MKFS} ${MKFS_OPTIONS} ${FREELO}
-		;;
-esac
+Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+sleep $LB_SLEEP_INTERVAL
+Echo_message "Copying binary contents into Image..."
+
+mkdir -p chroot/binary.tmp
+mount ${MOUNT_OPTIONS} ${FREELO}p${PRIMARY_PARTNUM} chroot/binary.tmp
+
+Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+sleep $LB_SLEEP_INTERVAL
 
 case "${LB_BINARY_FILESYSTEM}" in
 	fat*)
@@ -260,78 +547,136 @@ case "${LB_BINARY_FILESYSTEM}" in
 		;;
 esac
 
-Echo_message "Copying binary contents into image..."
-
-mkdir -p chroot/binary.tmp
-mount ${MOUNT_OPTIONS} ${FREELO} chroot/binary.tmp
 cp -T ${CP_OPTIONS} binary/ chroot/binary.tmp
 
-FIXME()
-{
-if [ "${LB_FIRST_BOOTLOADER}" = "grub" ]
-then
-
-cat > chroot/grub.sh << EOF
-cd binary.tmp
-grub --batch << EOM
-find /live/vmlinuz
-EOM
-EOF
-
-	rootpartition="$(Chroot chroot 'sh grub.sh' 2>/dev/null | grep -A 1 'find /live/vmlinuz' | grep -v 'find /live/vmlinuz')"
-	hdddev="$(echo $rootpartition | sed -e 's|,[[:digit:]]||')"
-	echo "Root partition is $rootpartition, device is: $hdddev"
-
-	echo "WAITING..." && read WAIT
-
-#cat > chroot/grub.sh << EOF
-#grub --batch << EOM
-#root $rootpartition
-#setup $hdddev
-#EOM
-#EOF
-
-#Chroot chroot "sh grub.sh"
-
-	rm -f chroot/grub.sh
-fi
-}
+Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+sleep $LB_SLEEP_INTERVAL
 
 case "${_BOOTLOADER}" in
 	syslinux)
-		_SYSLINUX_INSTALLER="syslinux ${FREELO}"
+		_SYSLINUX_INSTALLER="syslinux ${FREELO}p${PRIMARY_PARTNUM}"
 		;;
 	extlinux)
-		_SYSLINUX_INSTALLER="extlinux --install /binary.tmp/boot/extlinux"
+		_SYSLINUX_INSTALLER="extlinux --install chroot/binary.tmp/boot/extlinux"
 		;;
 	*)
 		_SYSLINUX_INSTALLER=""
 		;;
 esac
 
-if [ -n "${_SYSLINUX_INSTALLER}" ]
-then
-	case "${LB_BUILD_WITH_CHROOT}" in
-		true)
-			Chroot chroot "${_SYSLINUX_INSTALLER}"
-			;;
-		false)
-			${_SYSLINUX_INSTALLER}
-			;;
-	esac
-fi
+case "${LB_ARCHITECTURES}" in
+	ppc64el)
+		grub-install --no-nvram --no-floppy --boot-directory=chroot/binary.tmp/boot ${FREELO}p${BOOTLOADER_DEVICE_PARTNUM}
+		Echo_message "binary_hdd is using the default LB_BOOTLOADER_PARTITION_TYPE of \"PReP\" for architecture of \"${LB_ARCHITECTURES}\" (the value specified in LB_BOOTLOADER_PARTITION_TYPE is \"${LB_BOOTLOADER_PARTITION_TYPE}\" in config/binary)."
+		;;
+	amd64|i386)
+		case "${LB_FIRST_BOOTLOADER}" in
+			syslinux)
+				if [ "${_GPT}" = "false" ]
+				then
+					dd if=chroot/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/mbr.bin of=${FREELO} bs=440 count=1
+				else
+					dd if=chroot/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])/gptmbr.bin of=${FREELO} conv=notrunc bs=440 count=1
+				fi
+
+				if [ -n "${_SYSLINUX_INSTALLER}" ]
+				then
+					${_SYSLINUX_INSTALLER}
+					Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+					sleep $LB_SLEEP_INTERVAL
+				fi
+				Echo_message "binary_hdd is using the default LB_HDD_PARTITION_TABLE_TYPE of \"msdos\".  If this is not the desired layout, changing the LB_BOOTLOADERS to \"grub-efi\" will allow flexibility on LB_BOOTLOADER_PARTITION_TYPE (currently specified as \"${LB_BOOTLOADER_PARTITION_TYPE}\" in config/binary)."
+				;;
+			grub-efi)
+				case "${_TARGET_FORMAT}" in
+					esp)
+						if [ -n "${LB_HDD_LABEL}" ]
+						then
+							_ESP_LABEL=$LB_HDD_LABEL
+						else
+							_ESP_LABEL="LB-ESP"
+						fi
+						mkdir -p chroot/binary.esp
+						mkfs.vfat -F 32 -I -n ${_ESP_LABEL} ${FREELO}p${BOOTLOADER_DEVICE_PARTNUM}
+						Echo_message "binary_hdd mkfs.vfat -F 32 -I -n ${_ESP_LABEL} ${FREELO}p${BOOTLOADER_DEVICE_PARTNUM}"
+						mount ${MOUNT_OPTIONS} ${FREELO}p${BOOTLOADER_DEVICE_PARTNUM} chroot/binary.esp
+						mkdir -p chroot/binary.esp/EFI/BOOT
+						mkdir -p chroot/binary.esp/EFI/${_ESP_LABEL}
+						# first copy the default efi's, these get picked up by EFI to boot if nothing found, so a failsafe
+						cp chroot/binary.tmp/boot/grub/x86_64-efi/x86_64-efi.efi chroot/binary.esp/EFI/BOOT/BOOTX64.EFI
+						cp chroot/binary.tmp/boot/grub/i386-efi/i386-efi.efi chroot/binary.esp/EFI/BOOT/BOOTIA32.EFI
+						# next copy the distribution specific efi's (similar content, see efi-image for prefix differences)
+						cp chroot/binary.tmp/boot/grub/x86_64-efi/x86_64-efi.efi-grub chroot/binary.esp/EFI/${_ESP_LABEL}/grubx64.efi
+						cp chroot/binary.tmp/boot/grub/i386-efi/i386-efi.efi-grub chroot/binary.esp/EFI/${_ESP_LABEL}/grubia32.efi
+						# No need to do a grub-install on ESP, and this can be destructive if run from a UEFI Host
+						# grub-install with efi-directory still runs efibootmgr which is executing on the build Host, not in the chroot
+						# efibootmgr will then delete and create a registry entry on EFI which will update the WRONG target
+						# grub-install on efi should allow a by-pass to NOT update the EFI registry
+						#grub-install --no-floppy --efi-directory=chroot/binary.esp/boot/efi
+						#--directory=chroot/binary.tmp/boot/grub/x86_64-efi --boot-directory=chroot/binary.tmp/boot ${FREELO} -v
+						#grub-install --no-floppy --directory=chroot/binary.tmp/boot/grub/i386-efi --boot-directory=chroot/binary.tmp/boot ${FREELO} -v
+						umount chroot/binary.esp
+						rmdir chroot/binary.esp
+						;;
+					*)
+						# --debug-image=all
+						#grub-install --no-floppy --target=i386pc --directory=chroot/usr/lib/grub/i386-pc --boot-directory=chroot/binary.tmp/boot ${FREELO} -v
+						grub-bios-setup --verbose --directory=chroot/binary.tmp/boot/grub/i386-pc ${FREELO} -v
+						;;
+				esac
+				;;
+		esac
 
+		;;
+esac
+
+Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+sleep $LB_SLEEP_INTERVAL
 umount chroot/binary.tmp
 rmdir chroot/binary.tmp
 
-Lodetach ${FREELO}
-
-echo "!!! The above error/warning messages can be ignored !!!"
+losetup -d ${FREELO}
 
-if [ -n "${MAKEDEV}" ]
+if [ "$MAKE_PERSIST" = "true" ]
 then
-	rm -rf chroot/dev
-	mv chroot/dev.tmp chroot/dev
+# these steps are done without chroot since devmapper is needed
+		FREELO_PERSIST="$(${LB_LOSETUP} -f)"
+		# expect kpartx to pick up next free loop device
+		kpartx -a -v chroot/binary.img
+		# take the /dev/loopX and strip off the loopX to use in the devmapper
+		LOOP_STRING="$(echo "${FREELO_PERSIST}" | rev | cut -d"/" -f1 | rev)"
+		# sleep to wait for dev mapper to finish
+		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+		sleep ${LB_SLEEP_INTERVAL}
+
+		mkfs.ext4 -b 4096 -L persistence /dev/mapper/${LOOP_STRING}p${PERSIST_PARTNUM}
+		Echo_message "binary_hdd mkfs.ext4 -b 4096 -L persistence /dev/mapper/${LOOP_STRING}p${PERSIST_PARTNUM}"
+		# We need to make this ext4 to use -L and not sure what type came in
+
+		# sleep to wait for mkfs to finish
+		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+		sleep ${LB_SLEEP_INTERVAL}
+
+		mkdir -p chroot/binary_persist.tmp
+		# expect to use partition 2 for persistence
+		mount /dev/mapper/${LOOP_STRING}p${PERSIST_PARTNUM} chroot/binary_persist.tmp
+		# sleep to wait for mounts
+		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+		sleep ${LB_SLEEP_INTERVAL}
+
+		echo "/ union" > chroot/binary_persist.tmp/persistence.conf
+		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+		sleep ${LB_SLEEP_INTERVAL}
+
+		umount chroot/binary_persist.tmp
+		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+		sleep ${LB_SLEEP_INTERVAL}
+
+		kpartx -d -v chroot/binary.img
+		Echo_message "binary_hdd is sleeping for LB_SLEEP_INTERVAL of ${LB_SLEEP_INTERVAL} seconds.  If needed LB_SLEEP_INTERVAL can be defined in config/binary to tweak the timing on machines (read/write and mounts)."
+		sleep ${LB_SLEEP_INTERVAL}
+
+		rmdir chroot/binary_persist.tmp
 fi
 
 mv chroot/binary.img ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.img
diff --git a/scripts/build/binary_iso b/scripts/build/binary_iso
index 99cae59..5c5e66c 100755
--- a/scripts/build/binary_iso
+++ b/scripts/build/binary_iso
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -30,7 +31,17 @@ case "${LIVE_IMAGE_TYPE}" in
 		;;
 
 	iso-hybrid)
-		IMAGE="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.hybrid.iso"
+		case "${LB_ARCHITECTURES}" in
+			ppc64el)
+				Echo_warning "Architecture of ${LB_ARCHITECTURES} is not supported for LIVE_IMAGE_TYPE of ${LIVE_IMAGE_TYPE}, using type of iso."
+				LIVE_IMAGE_TYPE=iso
+				IMAGE="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.iso"
+				;;
+			*)
+				IMAGE="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.hybrid.iso"
+				;;
+		esac
+
 		;;
 
 	*)
@@ -120,65 +131,77 @@ do
 
 	# If the bootloader number is greater or equal than 2 it means
 	# we are not the first bootloader and thus we need to tell
-	# mkisosfs to add an additional eltorito entry
-	if [ ${BOOTLOADER_NUMBER} -ge 2 ]
-	then
-		XORRISO_OPTIONS="${XORRISO_OPTIONS} -eltorito-alt-boot "
-	fi
-	case "${BOOTLOADER}" in
-		grub)
-			XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
-			XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/stage2_eltorito"
-			XORRISO_EXCLUDE="boot/grub/stage2_eltorito"
-			;;
+	# mkisosfs to add an additional eltorito entry for some platforms
 
-		grub-pc)
-			XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
-			XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/grub_eltorito -J"
-			XORRISO_EXCLUDE="boot/grub/grub_eltorito"
-			;;
-
-		syslinux)
-			case "${LB_MODE}" in
-				progress-linux)
-					XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/boot.bin -c boot/boot.cat"
-					XORRISO_EXCLUDE="boot/boot.bin"
+	case "${LB_ARCHITECTURES}" in
+		ppc64el)
+			case "${BOOTLOADER}" in
+				grub-efi)
+					XORRISO_OPTIONS="${XORRISO_OPTIONS} -chrp-boot-part"
 					;;
-
 				*)
-					XORRISO_OPTIONS="${XORRISO_OPTIONS} -b isolinux/isolinux.bin -c isolinux/boot.cat"
-					XORRISO_EXCLUDE="isolinux/isolinux.bin"
+					Echo_error "Architecture of ${LB_ARCHITECTURES} does not support BOOTLOADER of ${BOOTLOADER} in LB_BOOTLOADERS of binary_iso."
+					exit 1
 					;;
 			esac
 
-			XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table --hardlinks"
 			;;
-
-		grub-efi)
-			if [ -e binary/boot/grub/efi.img ]
+		*)
+			if [ ${BOOTLOADER_NUMBER} -ge 2 ]
 			then
-				XORRISO_OPTIONS="${XORRISO_OPTIONS} -e boot/grub/efi.img -no-emul-boot"
-				XORRISO_OPTIONS="${XORRISO_OPTIONS} -isohybrid-gpt-basdat -isohybrid-apm-hfsplus"
-			else
-				Echo "No EFI boot code to include in the ISO"
+				XORRISO_OPTIONS="${XORRISO_OPTIONS} -eltorito-alt-boot "
 			fi
-			;;
+			case "${BOOTLOADER}" in
+				grub)
+					XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
+					XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/stage2_eltorito"
+					XORRISO_EXCLUDE="boot/grub/stage2_eltorito"
+					;;
 
-		*)
-			Echo_warning "Bootloader on your architecture not yet supported by live-build."
-			Echo_warning "This will produce a most likely not bootable image (Continuing in 5 seconds)."
-			sleep 5
+				grub-pc)
+					XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
+					XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/grub_eltorito -J"
+					XORRISO_EXCLUDE="boot/grub/grub_eltorito"
+					;;
+
+				syslinux)
+					case "${LB_MODE}" in
+						progress-linux)
+							XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/boot.bin -c boot/boot.cat"
+							XORRISO_EXCLUDE="boot/boot.bin"
+							;;
+
+						*)
+							XORRISO_OPTIONS="${XORRISO_OPTIONS} -b isolinux/isolinux.bin -c isolinux/boot.cat"
+							XORRISO_EXCLUDE="isolinux/isolinux.bin"
+							;;
+					esac
+
+					XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
+					;;
+
+				grub-efi)
+					if [ -e binary/boot/grub/efi.img ]
+					then
+						XORRISO_OPTIONS="${XORRISO_OPTIONS} -e boot/grub/efi.img -no-emul-boot"
+						XORRISO_OPTIONS="${XORRISO_OPTIONS} -isohybrid-gpt-basdat -isohybrid-apm-hfsplus"
+					else
+						Echo_warning "No EFI boot code to include in the ISO"
+					fi
+					;;
+
+				*)
+					Echo_error "Architecture of ${LB_ARCHITECTURES} does not support BOOTLOADER of ${BOOTLOADER} in LB_BOOTLOADERS."
+					Echo_error "Try a minimum for LB_BOOTLOADERS of syslinux (use a comma separated list if needed)."
+					exit 1
+					;;
+			esac
 			;;
 	esac
 
 done
 IFS="$OLDIFS"
 
-#if [ "${LB_DEBIAN_INSTALLER}" != "live" ]
-#then
-#	XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}"
-#fi
-
 if [ "${LB_FIRST_BOOTLOADER}" = "grub-pc" ]
 then
 
@@ -216,6 +239,8 @@ cat >> binary.sh << EOF
 xorriso -as mkisofs ${XORRISO_OPTIONS} -o ${IMAGE} binary
 EOF
 
+Echo_message "XORRISO_OPTIONS being used are ${XORRISO_OPTIONS} for LB_BOOTLOADERS of ${LB_BOOTLOADERS} in binary_iso."
+
 case "${LB_BUILD_WITH_CHROOT}" in
 	true)
 		# Moving image
diff --git a/scripts/build/binary_linux-image b/scripts/build/binary_linux-image
index 6227a24..f13cc52 100755
--- a/scripts/build/binary_linux-image
+++ b/scripts/build/binary_linux-image
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -54,7 +55,7 @@ case "${LB_INITRAMFS}" in
 esac
 
 case "${LB_ARCHITECTURES}" in
-	powerpc)
+	powerpc|ppc64el)
 		LINUX="vmlinux"
 		;;
 
diff --git a/scripts/build/binary_loopback_cfg b/scripts/build/binary_loopback_cfg
index 00f537c..07bf122 100755
--- a/scripts/build/binary_loopback_cfg
+++ b/scripts/build/binary_loopback_cfg
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -43,9 +44,22 @@ Check_lockfile .lock
 Create_lockfile .lock
 
 # Check architecture
-Check_architectures amd64 i386
+Check_architectures amd64 i386 ppc64el
 Check_crossarchitectures
 
+# Checking depends
+case "${LB_ARCHITECTURES}" in
+	ppc64el)
+		Check_package host /usr/share/live/build/templates/grub2/grub.cfg live-build
+		;;
+	amd64|i386)
+		Check_package host /usr/share/live/build/templates/grub2/grub.cfg live-build
+		;;
+	*)
+		Echo_warning "Architecture of ${LB_ARCHITECTURES} may need Host packages installed to support LB_BOOTLOADERS of ${LB_BOOTLOADERS}."
+		;;
+esac
+
 # Variable used to embed newlines
 NL="
 "
@@ -130,17 +144,32 @@ menuentry "$LB_MEMTEST" {
 END
 }
 
-if [ -e "config/bootloaders/grub-pc" ]
+case  "${LB_FIRST_BOOTLOADER}" in
+	grub-pc)
+		# binary_syslinux sets other custom bootloaders
+		_BOOTLOADER=grub-pc
+		# _PATH must be on the Host build machine, not in the chroot
+		_PATH=/usr/share/live/build/bootloaders/
+		;;
+	*)
+		# binary_syslinux sets other custom bootloaders
+		# but we need to have some grub.cfg's to allow sed to work later
+		_BOOTLOADER=grub2
+		# _PATH must be on the Host build machine, not in the chroot
+		_PATH=/usr/share/live/build/templates/
+		;;
+esac
+
+if [ -e "config/bootloaders/${_BOOTLOADER}" ]
 then
-	# Internal local copy
-	_SOURCE="config/bootloaders/grub-pc"
+	# Use customizations provided
+	_SOURCE="config/bootloaders/${_BOOTLOADER}"
 else
-	# Internal system copy
 	if [ -n "${LIVE_BUILD}" ]
 	then
-		_SOURCE="${LIVE_BUILD}/share/bootloaders/grub-pc"
+		_SOURCE="${LIVE_BUILD}${_PATH}${_BOOTLOADER}"
 	else
-		_SOURCE="/usr/share/live/build/bootloaders/grub-pc"
+		_SOURCE="${_PATH}${_BOOTLOADER}"
 	fi
 fi
 
@@ -154,6 +183,19 @@ case "${LB_INITRAMFS}" in
 		;;
 esac
 
+case "${LB_ARCHITECTURES}" in
+	amd64|i386)
+		LINUX="vmlinuz"
+		;;
+	ppc64el)
+		LINUX="vmlinux"
+		;;
+	*)
+		Echo_error "Architecture of ${LB_ARCHITECTURES} is not supported in binary_loopback_cfg"
+		exit 1
+		;;
+esac
+
 Check_multiarchitectures
 
 # Setting boot parameters
@@ -170,8 +212,8 @@ fi
 
 # Default entries
 DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')"
-DEFAULT_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})"
-DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinuz-||')"
+DEFAULT_KERNEL="$(basename chroot/boot/${LINUX}-*${DEFAULT_FLAVOUR})"
+DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e "s|${LINUX}-||")"
 
 KERNEL_LIVE="/${INITFS}/${DEFAULT_KERNEL}"
 INITRD_LIVE="/${INITFS}/${DEFAULT_INITRD}"
@@ -189,10 +231,10 @@ done
 
 if [ "${_AMD64_486_NUMBER}" -ge 2 ] ; then
 	# Default entries
-	AMD64_KERNEL="$(basename chroot/boot/vmlinuz-*amd64)"
-	AMD64_INITRD="initrd.img-$(echo ${AMD64_KERNEL} | sed -e 's|vmlinuz-||')"
-	_486_KERNEL="$(basename chroot/boot/vmlinuz-*486)"
-	_486_INITRD="initrd.img-$(echo ${_486_KERNEL} | sed -e 's|vmlinuz-||')"
+	AMD64_KERNEL="$(basename chroot/boot/${LINUX}-*amd64)"
+	AMD64_INITRD="initrd.img-$(echo ${AMD64_KERNEL} | sed -e "s|${LINUX}-||")"
+	_486_KERNEL="$(basename chroot/boot/${LINUX}-*486)"
+	_486_INITRD="initrd.img-$(echo ${_486_KERNEL} | sed -e "s|${LINUX}-||")"
 
 	Grub_live_autodetect_entry "Live system (autodetect)" \
 		"/${INITFS}/${AMD64_KERNEL}" \
@@ -210,14 +252,14 @@ then
 fi
 
 _COUNT=0
-for KERNEL in chroot/boot/vmlinuz-*; do
+for KERNEL in chroot/boot/${LINUX}-*; do
 	_COUNT=$(( $COUNT + 1 ))
 done
 
 if [ $_COUNT -gt 1 ]; then
-	for KERNEL in chroot/boot/vmlinuz-*
+	for KERNEL in chroot/boot/${LINUX}-*
 	do
-		VERSION="$(basename ${KERNEL} | sed -e 's|vmlinuz-||')"
+		VERSION="$(basename ${KERNEL} | sed -e "s|${LINUX}-||")"
 
 		Grub_live_entry "Live system, kernel ${VERSION}" "/${INITFS}/$(basename ${KERNEL})" "/${INITFS}/initrd.img-${VERSION}" "${APPEND_LIVE}"
 
@@ -230,11 +272,11 @@ fi
 # Assembling debian-installer configuration
 if [ "${LB_DEBIAN_INSTALLER}" != "false" ]
 then
-	KERNEL_DI="/install/vmlinuz"
+	KERNEL_DI="/install/${LINUX}"
 	INITRD_DI="/install/initrd.gz"
 	APPEND_DI="vga=normal quiet ${LB_BOOTAPPEND_INSTALL}"
 
-	KERNEL_GI="/install/gtk/vmlinuz"
+	KERNEL_GI="/install/gtk/${LINUX}"
 	INITRD_GI="/install/gtk/initrd.gz"
 	APPEND_GI="video=vesa:ywrap,mtrr vga=788 quiet ${LB_BOOTAPPEND_INSTALL}"
 
@@ -258,7 +300,7 @@ fi
 
 # Copying templates
 mkdir -p binary/boot/grub
-cp -a "${_SOURCE}"/* binary/boot/grub/
+cp -aL "${_SOURCE}"/* binary/boot/grub/
 
 escape_for_sed() {
     echo -n "$1" | perl -npe 's/\n/\\n/gm'
diff --git a/scripts/build/binary_netboot b/scripts/build/binary_netboot
index 7a94b4f..e244e22 100755
--- a/scripts/build/binary_netboot
+++ b/scripts/build/binary_netboot
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -48,6 +49,10 @@ Check_lockfile .lock
 # Creating lock file
 Create_lockfile .lock
 
+# Check architectures
+Check_architectures amd64 i386
+Check_crossarchitectures
+
 # Remove old binary
 rm -f ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.gz ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.bz2 ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.xz ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.xz
 
diff --git a/scripts/build/binary_rootfs b/scripts/build/binary_rootfs
index 6c797ac..a46c260 100755
--- a/scripts/build/binary_rootfs
+++ b/scripts/build/binary_rootfs
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -43,7 +44,7 @@ case "${LB_ARCHITECTURES}" in
 		LINUX="vmlinuz"
 		;;
 
-	powerpc)
+	powerpc|ppc64el)
 		LINUX="vmlinux"
 		;;
 esac
diff --git a/scripts/build/binary_syslinux b/scripts/build/binary_syslinux
index 1347aa2..d551e20 100755
--- a/scripts/build/binary_syslinux
+++ b/scripts/build/binary_syslinux
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -41,9 +42,20 @@ Check_lockfile .lock
 Create_lockfile .lock
 
 # Check architecture
-Check_architectures amd64 i386
+# Need to include ppc64el in checks to stop processing if defined
+Check_architectures amd64 i386 ppc64el
 Check_crossarchitectures
 
+case "${LB_ARCHITECTURES}" in
+	amd64|i386)
+		LINUX="vmlinuz"
+		;;
+	*)
+		Echo_error "Architecture ${LB_ARCHITECTURES} not supported in binary_syslinux (try LB_BOOTLOADERS of \"grub-efi\" in config/binary)."
+		exit 1
+		;;
+esac
+
 case "${LB_INITRAMFS}" in
 	*)
 		_INITRAMFS="live"
@@ -99,6 +111,9 @@ case "${LIVE_IMAGE_TYPE}" in
 		;;
 esac
 
+Check_package host /usr/lib/ISOLINUX/isolinux.bin  isolinux
+
+# Internal system copy
 if [ -e "config/bootloaders/${_BOOTLOADER}" ]
 then
 	# Internal local copy
@@ -163,9 +178,9 @@ case "${LB_BUILD_WITH_CHROOT}" in
 		mkdir -p ${_TARGET}
 
 		# Copy in two steps since the theme can have absolute symlinks and would therefore not be dereferenced correctly
-		cp -a ${_SOURCE} chroot/root
+		cp -aL ${_SOURCE} chroot/root
 		Chroot chroot cp -aL /root/$(basename ${_SOURCE}) /root/$(basename ${_SOURCE}).tmp > /dev/null 2>&1 || true
-		cp -a chroot/root/$(basename ${_SOURCE}).tmp/* ${_TARGET}
+		cp -aL chroot/root/$(basename ${_SOURCE}).tmp/* ${_TARGET}
 		rm -rf chroot/root/$(basename ${_SOURCE}) chroot/root/$(basename ${_SOURCE}).tmp
 		;;
 
@@ -186,11 +201,11 @@ then
 		1)
 			# If multiple initrd images are being generated (by DKMS packages, etc),
 			# we likely only want the latest version.
-			ln $(ls -r1 --sort=version binary/${_INITRAMFS}/vmlinuz-* | head -n 1) binary/${_INITRAMFS}/vmlinuz
+			ln $(ls -r1 --sort=version binary/${_INITRAMFS}/${LINUX}-* | head -n 1) binary/${_INITRAMFS}/${LINUX}
 			ln $(ls -r1 --sort=version binary/${_INITRAMFS}/initrd.img-* | head -n 1) binary/${_INITRAMFS}/initrd.img
 
 			sed -e "s|@FLAVOUR@|${LB_LINUX_FLAVOURS}|g" \
-			    -e "s|@LINUX@|/${_INITRAMFS}/vmlinuz|g" \
+			    -e "s|@LINUX@|/${_INITRAMFS}/${LINUX}|g" \
 			    -e "s|@INITRD@|/${_INITRAMFS}/initrd.img|g" \
 			"${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg"
 
@@ -204,7 +219,7 @@ then
 			do
 				_NUMBER="$((${_NUMBER} + 1))"
 
-				ln binary/${_INITRAMFS}/vmlinuz-*-${_FLAVOUR} binary/${_INITRAMFS}/vmlinuz${_NUMBER}
+				ln binary/${_INITRAMFS}/${LINUX}-*-${_FLAVOUR} binary/${_INITRAMFS}/${LINUX}${_NUMBER}
 				ln binary/${_INITRAMFS}/initrd.img-*-${_FLAVOUR} binary/${_INITRAMFS}/initrd${_NUMBER}.img
 
 				if [ "${_NUMBER}" -gt 1 ]
@@ -216,7 +231,7 @@ then
 				fi
 
 				sed -i -e "s|@FLAVOUR@|${_FLAVOUR}|g" \
-				       -e "s|@LINUX@|/${_INITRAMFS}/vmlinuz${_NUMBER}|g" \
+				       -e "s|@LINUX@|/${_INITRAMFS}/${LINUX}${_NUMBER}|g" \
 				       -e "s|@INITRD@|/${_INITRAMFS}/initrd${_NUMBER}.img|g" \
 				"${_TARGET}/live.cfg"
 			done
@@ -244,7 +259,7 @@ _HOUR="$(date +%H)"
 _MINUTE="$(date +%M)"
 _SECOND="$(date +%S)"
 
-_LINUX_VERSIONS="$(for _LINUX in chroot/boot/vmlinuz-* ; do chroot chroot apt-cache policy $(basename ${_LINUX} | sed -e 's|vmlinuz-|linux-image-|') | awk '/Installed: / { print $2 }' ; done | sort -Vru | tr "\n" " ")"
+_LINUX_VERSIONS="$(for _LINUX in chroot/boot/${LINUX}-* ; do chroot chroot apt-cache policy $(basename ${_LINUX} | sed -e 's|${LINUX}-|linux-image-|') | awk '/Installed: / { print $2 }' ; done | sort -Vru | tr "\n" " ")"
 
 _LIVE_BUILD_VERSION="$(lb --version)"
 _LIVE_BOOT_VERSION="$(chroot chroot apt-cache policy live-boot | awk '/Installed: / { print $2 }')"
diff --git a/scripts/build/config b/scripts/build/config
index c692a92..83b9e9c 100755
--- a/scripts/build/config
+++ b/scripts/build/config
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -123,7 +124,12 @@ USAGE="${PROGRAM}   [--apt apt|aptitude]\n\
 \t    [--win32-loader true|false]\n\
 \t    [--bootstrap-qemu-exclude PACKAGES]\n\
 \t    [--bootstrap-qemu-static PATH]\n\
-\t    [--bootstrap-qemu-arch ARCH]"
+\t    [--bootstrap-qemu-arch ARCH]\n\
+\t    [--persist auto|noauto|MB]\n\
+\t    [--bootloader-part-size auto|noauto|MB]\n\
+\t    [--hdd-part-type auto|msdos|gpt]\n\
+\t    [--bootloader-part-type auto|bios_grub|esp|PReP]\n\
+\t    [--lb-sleep-interval 1|seconds]"
 
 
 Local_arguments ()
@@ -148,7 +154,7 @@ Local_arguments ()
 		net-cow-server:,net-tarball:,firmware-binary:,firmware-chroot:,swap-file-path:,swap-file-size:,
 		loadlin:,win32-loader:,source:,source-images:,breakpoints,conffile:,debug,force,
 		help,ignore-system-defaults,quiet,usage,verbose,version,bootstrap-qemu-static:,bootstrap-qemu-arch:,
-		bootstrap-qemu-exclude:"
+		bootstrap-qemu-exclude:,persist:,bootloader-part-size:,hdd-part-type:,bootloader-part-type:,lb-sleep-interval:"
 	# Remove spaces added by indentation
 	LONG_OPTIONS="$(echo ${LONG_OPTIONS} | tr -d ' ')"
 	ARGUMENTS="$(getopt --longoptions ${LONG_OPTIONS} --name="${PROGRAM}" --options a:f:d:m:l:k:p:b:e:s:c:huv --shell sh -- "${@}")"
@@ -699,6 +705,31 @@ Local_arguments ()
 				shift 2
 				;;
 
+			--persist)
+				LB_PERSIST="${2}"
+				shift 2
+				;;
+
+			--bootloader-part-size)
+				LB_BOOTLOADER_PARTITION_SIZE="${2}"
+				shift 2
+				;;
+
+			--hdd-part-type)
+				LB_HDD_PARTITION_TABLE_TYPE="${2}"
+				shift 2
+				;;
+
+			--bootloader-part-type)
+				LB_BOOTLOADER_PARTITION_TYPE="${2}"
+				shift 2
+				;;
+
+			--lb-sleep-interval)
+				LB_SLEEP_INTERVAL="${2}"
+				shift 2
+				;;
+
 			# config/source
 			--source)
 				LB_SOURCE="${2}"
@@ -1145,6 +1176,9 @@ cat > config/binary << EOF
 
 # \$LB_BINARY_FILESYSTEM: set image filesystem
 # (Default: ${LB_BINARY_FILESYSTEM})
+# If building an HDD image, consider the LB_HDD_PARTITION_TABLE_TYPE
+# with this value.  If using auto on LB_HDD_PARTITION_TABLE_TYPE
+# (which will use GPT) then this value needs to be ext2/ext3/ext4
 LB_BINARY_FILESYSTEM="${LB_BINARY_FILESYSTEM}"
 
 # \$LB_APT_INDICES: set apt/aptitude generic indices
@@ -1160,11 +1194,17 @@ LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE}"
 LB_BOOTAPPEND_INSTALL="${LB_BOOTAPPEND_INSTALL}"
 
 # \$LB_BOOTAPPEND_LIVE_FAILSAFE: set boot parameters
-# (Default: empty)
+# Specify a value of "none" to not have this appear
+# as an option on the boot screens
 LB_BOOTAPPEND_LIVE_FAILSAFE="${LB_BOOTAPPEND_LIVE_FAILSAFE}"
 
 # \$LB_BOOTLOADERS: set bootloaders
 # (Default: ${LB_BOOTLOADERS})
+# For x platforms most typical usage is syslinux.
+# For ppc platforms most typical usage is grub-efi.
+# x platforms can specify grub-efi which gives a grub2 configuration
+# The build type of HDD needs to be defined in config/build to leverage
+# the LB_BOOTLOADER_PARTITION_SIZE and LB_HDD_PARTITION_TABLE_TYPE
 LB_BOOTLOADERS="${LB_BOOTLOADERS}"
 
 # \$LB_CHECKSUMS: set checksums
@@ -1210,12 +1250,39 @@ LB_HDD_LABEL="${LB_HDD_LABEL}"
 
 # \$LB_HDD_SIZE: set hdd filesystem size
 # (Default: ${LB_HDD_SIZE})
+# Sizes defined in MB
 LB_HDD_SIZE="${LB_HDD_SIZE}"
 
-# \$LB_HDD_PARTITION_START: set start of partition for the hdd target for BIOSes that expect a specific boot partition start (e.g. "63s"). If empty, use optimal layout.
+# \$LB_HDD_PARTITION_START: set start of partition for the hdd image
+# These values are defined in MB offsets, values are not absolute,
+# alignments will be done, this is to allow the boot sector
+# to be enlarged for example before any primary partitions
+# are created on the hdd image
 # (Default: ${LB_HDD_PARTITION_START})
 LB_HDD_PARTITION_START="${LB_HDD_PARTITION_START}"
 
+# \$LB_PERSIST: set persistence for hdd
+# (Default: ${LB_PERSIST})
+LB_PERSIST="${LB_PERSIST}"
+
+# \$LB_BOOTLOADER_PARTITION_SIZE: set the size for the bios_grub, esp, or PReP partition size
+# These are usually small values in MB
+# (Default: ${LB_BOOTLOADER_PARTITION_SIZE})
+LB_BOOTLOADER_PARTITION_SIZE="${LB_BOOTLOADER_PARTITION_SIZE}"
+
+# \$LB_HDD_PARTITION_TABLE_TYPE: set the type of partition table schema: msdos or gpt
+# (Default: ${LB_HDD_PARTITION_TABLE_TYPE})
+LB_HDD_PARTITION_TABLE_TYPE="${LB_HDD_PARTITION_TABLE_TYPE}"
+
+# \$LB_BOOTLOADER_PARTITION_TYPE: set the type of the bootloader partition: bios_grub, esp or PReP
+# (Default: ${LB_BOOTLOADER_PARTITION_TYPE})
+LB_BOOTLOADER_PARTITION_TYPE="${LB_BOOTLOADER_PARTITION_TYPE}"
+
+# \$LB_SLEEP_INTERVAL: set the interval value used to sleep between internal operations
+# This interval is for compensation for slower machines between read/write, mount operations
+# (Default: ${LB_SLEEP_INTERVAL})
+LB_SLEEP_INTERVAL="${LB_SLEEP_INTERVAL}"
+
 # \$LB_ISO_APPLICATION: set iso author
 # (Default: ${LB_ISO_APPLICATION})
 LB_ISO_APPLICATION="${LB_ISO_APPLICATION}"
diff --git a/scripts/build/efi-image b/scripts/build/efi-image
index c372327..5bdb1ee 100755
--- a/scripts/build/efi-image
+++ b/scripts/build/efi-image
@@ -3,6 +3,7 @@ set -e
 
 # Copyright (C) 2010, 2011 Canonical Ltd.
 # Author: Colin Watson <cjwatson@ubuntu.com>
+# Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the Free
@@ -28,59 +29,103 @@ fi
 outdir="$1"
 platform="$2"
 efi_name="$3"
-netboot_prefix="$4"
-
-memdisk_img=
-workdir=
-
-cleanup () {
-	[ -z "$memdisk_img" ] || rm -f "$memdisk_img"
-	[ -z "$workdir" ] || rm -rf "$workdir"
-}
-trap cleanup EXIT HUP INT QUIT TERM
+image_name="$4"
 
 rm -rf "$outdir"
-mkdir -p "$outdir"
+mkdir -p "${outdir}/${platform}"
 
-memdisk_img="$(mktemp efi-image.XXXXXX)"
-workdir="$(mktemp -d efi-image.XXXXXX)"
+case "${platform}" in
+	power*)
 
-# Skeleton configuration file which finds the real boot disk.
-mkdir -p "$workdir/boot/grub"
-cat >"$workdir/boot/grub/grub.cfg" <<EOF
+cat >"${outdir}/${platform}/load.cfg" <<EOF
 search --file --set=root /.disk/info
 set prefix=(\$root)/boot/grub
-source \$prefix/$platform/grub.cfg
 EOF
+		grub-mkimage -O "${platform}" -p '()/boot/grub' \
+			--verbose --config="$outdir/$platform/load.cfg" \
+			-o "${outdir}/$efi_name.elf" normal iso9660 \
+			search_fs_file search_fs_uuid search_label search \
+			configfile normal memdisk tar tftp net iso9660 \
+			part_msdos part_gpt msdospart fat ext2 \
+			png jpeg tga all_video gfxterm gettext \
+			video video_colors video_fb videoinfo videotest \
+			gzio xzio probe loadenv \
+			gfxmenu gfxterm_background gfxterm_menu \
+			elf cat disk diskfilter ls cpio echo gfxterm_background
+		;;
+
+	x86_64-efi|i386-efi|i386-pc)
 
-mkdir -p "$outdir/boot/grub/$platform"
-(for i in /usr/lib/grub/$platform/part_*.mod; do
-    i=`echo $i | sed 's?^.*/??g;s?\.mod$??g;'`
-	echo "insmod $i"
- done; \
- echo "source /boot/grub/grub.cfg") >"$outdir/boot/grub/$platform/grub.cfg"
+cat >"${outdir}/${platform}/load.cfg" <<EOF
+search --file --set=root /.disk/info
+set prefix=(\$root)/boot/grub
+EOF
+		# This is running in the chroot, so copy it over to the outdir
 
-# Build the core image.
-(cd "$workdir"; tar -cf - boot) >"$memdisk_img"
-grub-mkimage -O "$platform" -m "$memdisk_img" \
-	-o "$workdir/boot$efi_name.efi" -p '(memdisk)/boot/grub' \
-	search iso9660 configfile normal memdisk tar part_msdos part_gpt fat
+		case "${platform}" in
+			i386-pc)
+				cp /usr/lib/grub/${platform}/boot.img ${outdir}/${platform}
+				# load.cfg is built above to be embedded in the core.img
+				# we use the chroot's /usr/lib/grub path since grub-install needs to use the images and modules from there
+				grub-mkimage --verbose --config="$outdir/$platform/load.cfg" \
+					--format="$platform" \
+					--output="$outdir/$platform/$image_name" \
+					--prefix=/boot/grub \
+					--compression=auto \
+					--directory="/usr/lib/grub/$platform" \
+					search search_fs_file search_fs_uuid search_label \
+					configfile normal memdisk tar tftp net iso9660 \
+					biosdisk part_msdos part_gpt msdospart fat ext2 \
+					pxe png jpeg tga all_video gfxterm gettext play \
+					vbe vga vga_text video video_bochs \
+					video_cirrus video_colors video_fb videoinfo \
+					videotest gzio xzio usb terminfo probe loadenv \
+					gdb gfxmenu gfxterm_background gfxterm_menu \
+					elf cat ls boot cpio echo gfxterm_background
+					;;
+			x86_64-efi|i386-efi)
+				# using this image with p='' for BOOTX64.EFI and BOOTIA32.EFI"
+				grub-mkimage --verbose --config="$outdir/$platform/load.cfg" \
+					--format="$platform" \
+					--output="$outdir/$platform/$image_name" \
+					--prefix='' \
+					--compression=auto \
+					--directory="/usr/lib/grub/$platform" \
+					search search_fs_file search_fs_uuid search_label \
+					configfile normal memdisk tar tftp net iso9660 \
+					part_msdos part_gpt msdospart fat ext2 \
+					png jpeg tga all_video gfxterm gettext play \
+					video video_bochs \
+					video_cirrus video_colors video_fb videoinfo \
+					videotest gzio xzio usb terminfo probe loadenv \
+					gfxmenu gfxterm_background gfxterm_menu \
+					elf cat ls boot cpio echo gfxterm_background
 
-grub-mkimage -O "$platform" \
-	-o "$outdir/bootnet$efi_name.efi" -p "$netboot_prefix/grub" \
-	search configfile normal efinet tftp net
+				# using this image with p=/boot/grub for EFI/ubuntu"
+				grub-mkimage --verbose --config="$outdir/$platform/load.cfg" \
+					--format="$platform" \
+					--output="$outdir/$platform/$image_name-grub" \
+					--prefix="/boot/grub" \
+					--compression=auto \
+					--directory="/usr/lib/grub/$platform" \
+					search search_fs_file search_fs_uuid search_label \
+					configfile normal memdisk tar tftp net iso9660 \
+					part_msdos part_gpt msdospart fat ext2 \
+					png jpeg tga all_video gfxterm gettext play \
+					video video_bochs \
+					video_cirrus video_colors video_fb videoinfo \
+					videotest gzio xzio usb terminfo probe loadenv \
+					gfxmenu gfxterm_background gfxterm_menu \
+					elf cat ls boot cpio echo gfxterm_background
 
-# Stuff it into a FAT filesystem, making it as small as possible.  24KiB
-# headroom seems to be enough; (x+31)/32*32 rounds up to multiple of 32.
-mkfs.msdos -C "$outdir/efi.img" \
-	$(( ($(stat -c %s "$workdir/boot$efi_name.efi") / 1024 + 55) \
-	    / 32 * 32 ))
-mmd -i "$outdir/efi.img" ::efi
-mmd -i "$outdir/efi.img" ::efi/boot
-mcopy -i "$outdir/efi.img" "$workdir/boot$efi_name.efi" \
-	"::efi/boot/boot$efi_name.efi"
+					;;
+		esac
+		;;
 
-grub-cpmodules "$outdir" "$platform"
-cp /usr/share/grub/unicode.pf2 "$outdir/boot/grub/"
+	*)
+		echo "Platform of ${platform} is not supported in efi-image."
+		exit 1
+		;;
+esac
 
 exit 0
diff --git a/scripts/build/grub-cpmodules b/scripts/build/grub-cpmodules
index 437ebdf..df9c7d3 100755
--- a/scripts/build/grub-cpmodules
+++ b/scripts/build/grub-cpmodules
@@ -3,6 +3,7 @@ set -e
 
 # Copyright (C) 2010, 2011 Canonical Ltd.
 # Author: Colin Watson <cjwatson@ubuntu.com>
+# Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the Free
@@ -30,26 +31,10 @@ fi
 outdir="$1"
 platform="$2"
 
-# Copy over GRUB modules, except for those already built in.
-cp -a "/usr/lib/grub/$platform"/*.lst "$outdir/boot/grub/$platform/"
-for x in "/usr/lib/grub/$platform"/*.mod; do
-	# TODO: Some of these exclusions are based on knowledge of module
-	# dependencies.  It would be nice to have a way to read the module
-	# list directly out of the image.
-	case $(basename "$x" .mod) in
-	    configfile|fshelp|iso9660|memdisk|search|search_fs_file|search_fs_uuid|search_label|tar)
-		# included in boot image
-		;;
-	    affs|afs|afs_be|befs|befs_be|minix|nilfs2|sfs|zfs|zfsinfo)
-		# unnecessary filesystem modules
-		;;
-	    example_functional_test|functional_test|hello)
-		# other cruft
-		;;
-	    *)
-		cp -a "$x" "$outdir/boot/grub/$platform/"
-		;;
-	esac
-done
+# Copy over GRUB modules since grub-mkimages vary in contents
+# we want to have all modules available to be loaded post-build
+#
+# Need to use $outdir/$platform to allow customizations
+cp -a "/usr/lib/grub/$platform"/* "${outdir}/${platform}"
 
 exit 0
diff --git a/scripts/build/installer_debian-installer b/scripts/build/installer_debian-installer
index ec931fa..2c1927b 100755
--- a/scripts/build/installer_debian-installer
+++ b/scripts/build/installer_debian-installer
@@ -2,6 +2,7 @@
 
 ## live-build(7) - System Build Scripts
 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+## Copyright (C) 2017 Deb McLemore <debmc@linux.vnet.ibm.com>
 ##
 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 ## This is free software, and you are welcome to redistribute it
@@ -124,7 +125,7 @@ case "${LB_ARCHITECTURES}" in
 		DI_REMOTE_BASE_GTK="${DI_REMOTE_BASE}/gtk"
 		;;
 
-	powerpc)
+	powerpc|ppc64el)
 		case "${DI_IMAGE_TYPE}" in
 			cdrom)
 				DI_REMOTE_BASE="${LB_ARCHITECTURES}/cdrom"
@@ -289,7 +290,7 @@ then
 			DOWNLOAD_GTK_INSTALLER=1
 			;;
 
-		powerpc)
+		powerpc|ppc64el)
 			if [ "${LB_DEBIAN_INSTALLER}" = "netboot" ]
 			then
 				DOWNLOAD_GTK_INSTALLER=1
@@ -329,6 +330,7 @@ then
 			DI_REQ_PACKAGES="yaboot"
 			DI_PACKAGES="${DI_REQ_PACKAGES} linux-image-powerpc linux-image-powerpc64 linux-image-powerpc-smp"
 			;;
+
 	esac
 
 	DI_PACKAGES="${DI_PACKAGES} busybox cryptsetup mdadm lvm2 xfsprogs jfsutils"
-- 
2.7.4


Reply to: