diff --git a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c index c74c9354c19..403ef70a874 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c +++ b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c @@ -44,10 +44,10 @@ default_scheme(void) { if (strcmp(platform, "powermac") == 0) return ("APM"); - if (strcmp(platform, "chrp") == 0) + if (strcmp(platform, "chrp") == 0 || strcmp(platform, "ps3") == 0) return ("MBR"); - /* Pick GPT (bootable on PS3) as a generic default */ + /* Pick GPT as a generic default */ return ("GPT"); } @@ -59,9 +59,9 @@ is_scheme_bootable(const char *part_type) { if (strcmp(platform, "powermac") == 0 && strcmp(part_type, "APM") == 0) return (1); - if (strcmp(platform, "ps3") == 0 && strcmp(part_type, "GPT") == 0) + if (strcmp(platform, "powernv") == 0 && strcmp(part_type, "GPT") == 0) return (1); - if (strcmp(platform, "chrp") == 0 && + if ((strcmp(platform, "chrp") == 0 || strcmp(platform, "ps3") == 0) && (strcmp(part_type, "MBR") == 0 || strcmp(part_type, "BSD") == 0 || strcmp(part_type, "GPT") == 0)) return (1); @@ -79,20 +79,26 @@ is_fs_bootable(const char *part_type, const char *fs) } size_t -bootpart_size(const char *part_type) { +bootpart_size(const char *part_type) +{ size_t platlen = sizeof(platform); if (strlen(platform) == 0) sysctlbyname("hw.platform", platform, &platlen, NULL, -1); - if (strcmp(part_type, "APM") == 0 || strcmp(part_type, "MBR") == 0) + if (strcmp(part_type, "APM") == 0) return (800*1024); - if (strcmp(platform, "chrp") == 0 && strcmp(part_type, "GPT") == 0) + if (strcmp(part_type, "BSD") == 0) /* Nothing for nested */ + return (0); + if (strcmp(platform, "chrp") == 0) return (800*1024); + if (strcmp(platform, "ps3") == 0 || strcmp(platform, "powernv") == 0) + return (512*1024*1024); return (0); } const char * -bootpart_type(const char *scheme, const char **mountpoint) { +bootpart_type(const char *scheme, const char **mountpoint) +{ size_t platlen = sizeof(platform); if (strlen(platform) == 0) sysctlbyname("hw.platform", platform, &platlen, NULL, -1); @@ -101,6 +107,13 @@ bootpart_type(const char *scheme, const char **mountpoint) { return ("prep-boot"); if (strcmp(platform, "powermac") == 0) return ("apple-boot"); + if (strcmp(platform, "powernv") == 0 || strcmp(platform, "ps3") == 0) { + *mountpoint = "/boot"; + if (strcmp(scheme, "GPT") == 0) + return ("ms-basic-data"); + else if (strcmp(scheme, "MBR") == 0) + return ("fat32"); + } return ("freebsd-boot"); } @@ -118,8 +131,7 @@ partcode_path(const char *part_type, const char *fs_type) { if (strcmp(part_type, "APM") == 0) return ("/boot/boot1.hfs"); - if (strcmp(part_type, "MBR") == 0 || - (strcmp(platform, "chrp") == 0 && strcmp(part_type, "GPT") == 0)) + if (strcmp(platform, "chrp") == 0) return ("/boot/boot1.elf"); return (NULL); } diff --git a/usr.sbin/bsdinstall/scripts/Makefile b/usr.sbin/bsdinstall/scripts/Makefile index 163929ab574..11c4564ea90 100644 --- a/usr.sbin/bsdinstall/scripts/Makefile +++ b/usr.sbin/bsdinstall/scripts/Makefile @@ -1,8 +1,9 @@ # $FreeBSD$ -SCRIPTS= auto adduser checksum config docsinstall entropy hardening hostname jail \ - keymap mirrorselect mount netconfig netconfig_ipv4 netconfig_ipv6 \ - rootpass script services time umount wlanconfig zfsboot +SCRIPTS= auto adduser bootconfig checksum config docsinstall entropy hardening \ + hostname jail keymap mirrorselect mount netconfig netconfig_ipv4 \ + netconfig_ipv6 rootpass script services time umount wlanconfig \ + zfsboot BINDIR= ${LIBEXECDIR}/bsdinstall MAN= diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto index 02323bbee42..41951f02f42 100755 --- a/usr.sbin/bsdinstall/scripts/auto +++ b/usr.sbin/bsdinstall/scripts/auto @@ -377,6 +377,10 @@ fi bsdinstall checksum || error "Distribution checksum failed" bsdinstall distextract || error "Distribution extract failed" + +# Set up boot loader +bsdinstall bootconfig || error "Failed to configure bootloader" + bsdinstall rootpass || error "Could not set root password" trap true SIGINT # This section is optional diff --git a/usr.sbin/bsdinstall/scripts/bootconfig b/usr.sbin/bsdinstall/scripts/bootconfig new file mode 100755 index 00000000000..c6294852897 --- /dev/null +++ b/usr.sbin/bsdinstall/scripts/bootconfig @@ -0,0 +1,40 @@ +#!/bin/sh +#- +# Copyright (c) 2017 Nathan Whitehorn +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ + +if [ `uname -m` == powerpc ]; then + platform=`sysctl -n hw.platform` + if [ "$platform" == ps3 -o "$platform" == powernv ]; then + rootpart=$(awk '{ if($2 == "/") printf("%s:%s\n", $3, $1); }' $PATH_FSTAB) + mkdir -p $BSDINSTALL_CHROOT/boot/etc/ + echo FreeBSD=\'/kernel/kernel vfs.root.mountfrom=${rootpart}\' > $BSDINSTALL_CHROOT/boot/etc/kboot.conf + fi +fi + +# For new-style EFI booting, add code here +# Add boot0cfg for MBR BIOS booting? + diff --git a/usr.sbin/bsdinstall/scripts/script b/usr.sbin/bsdinstall/scripts/script index bb295b4b5a5..a633554b943 100755 --- a/usr.sbin/bsdinstall/scripts/script +++ b/usr.sbin/bsdinstall/scripts/script @@ -116,9 +116,16 @@ fi bsdinstall checksum for set in $DISTRIBUTIONS; do f_dprintf "Extracting $BSDINSTALL_DISTDIR/$set" + # XXX: this will fail if any mountpoints are FAT, due to inability to + # set ctime/mtime on the root of FAT partitions. tar has no option to + # ignore this. We probably need to switch back to distextract here + # to properly support EFI. tar -xf "$BSDINSTALL_DISTDIR/$set" -C $BSDINSTALL_CHROOT done +# Configure bootloader if needed +bsdinstall bootconfig + # Finalize install bsdinstall config