Author: nwhitehorn Date: Tue Jan 2 05:27:24 2018 New Revision: 327487 URL: https://svnweb.freebsd.org/changeset/base/327487
Log: Add installer support for PS3 and PowerNV systems, also laying the foundation for invoking efibootmgr as part of new-style EFI booting on x86. On PS3 and PowerNV, which are booted using Linux kexec from petitboot rather than by loader(8), install the kernel and the rest of /boot to a FAT partition and set up the appropriate petitboot configuration file there. The new bootconfig installer stage can do platform-dependent modifications more complex than partition layout and installation of boot blocks and can be used to (as here) set up some special configuration files, run efibootmgr, or boot0cfg. MFC after: 1 month Added: head/usr.sbin/bsdinstall/scripts/bootconfig (contents, props changed) Modified: head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c head/usr.sbin/bsdinstall/scripts/Makefile head/usr.sbin/bsdinstall/scripts/auto head/usr.sbin/bsdinstall/scripts/script Modified: head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c Tue Jan 2 05:22:54 2018 (r327486) +++ head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c Tue Jan 2 05:27:24 2018 (r327487) @@ -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 **mountpo 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_ty 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); } Modified: head/usr.sbin/bsdinstall/scripts/Makefile ============================================================================== --- head/usr.sbin/bsdinstall/scripts/Makefile Tue Jan 2 05:22:54 2018 (r327486) +++ head/usr.sbin/bsdinstall/scripts/Makefile Tue Jan 2 05:27:24 2018 (r327487) @@ -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= Modified: head/usr.sbin/bsdinstall/scripts/auto ============================================================================== --- head/usr.sbin/bsdinstall/scripts/auto Tue Jan 2 05:22:54 2018 (r327486) +++ head/usr.sbin/bsdinstall/scripts/auto Tue Jan 2 05:27:24 2018 (r327487) @@ -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 Added: head/usr.sbin/bsdinstall/scripts/bootconfig ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/bsdinstall/scripts/bootconfig Tue Jan 2 05:27:24 2018 (r327487) @@ -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? + Modified: head/usr.sbin/bsdinstall/scripts/script ============================================================================== --- head/usr.sbin/bsdinstall/scripts/script Tue Jan 2 05:22:54 2018 (r327486) +++ head/usr.sbin/bsdinstall/scripts/script Tue Jan 2 05:27:24 2018 (r327487) @@ -116,8 +116,15 @@ 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 _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"