Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Feb 2018 19:45:24 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r328991 - stable/11/tools/boot
Message-ID:  <201802071945.w17JjORS086216@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Wed Feb  7 19:45:23 2018
New Revision: 328991
URL: https://svnweb.freebsd.org/changeset/base/328991

Log:
  MFC r326873,r326874,r326875,r326883,r326884,r326885,r326954,r328865
  
  r326873: Script that knows how to put boot blocks onto a device.
  
  r326874: Script to generate minimal boot images for each of the 24 supported
  
  r326875: Add missing of=/dev/${dev}s${s} when installing zfsboot.
  
  r326883: For now, make the gpart commands verbose
  
  r326884: Be a little verbose and list the loader files we're putting on
  
  r326885: Use -h -D in preference to -D so that the serial port gets the
  interactive console.
  
  r326954: Support more images (but still no geli)
  
  r328865: Flesh out the creation of sparc64 UFS images.

Added:
  stable/11/tools/boot/install-boot.sh
     - copied, changed from r326873, head/tools/boot/install-boot.sh
  stable/11/tools/boot/rootgen.sh
     - copied, changed from r326874, head/tools/boot/rootgen.sh
Modified:
Directory Properties:
  stable/11/   (props changed)

Copied and modified: stable/11/tools/boot/install-boot.sh (from r326873, head/tools/boot/install-boot.sh)
==============================================================================
--- head/tools/boot/install-boot.sh	Fri Dec 15 06:34:11 2017	(r326873, copy source)
+++ stable/11/tools/boot/install-boot.sh	Wed Feb  7 19:45:23 2018	(r328991)
@@ -15,6 +15,11 @@ die() {
     exit 1
 }
 
+doit() {
+    echo $*
+    eval $*
+}
+
 find-part() {
     dev=$1
     part=$2
@@ -30,7 +35,7 @@ boot_nogeli_gpt_zfs_legacy() {
     if [ -z "$idx" ] ; then
 	die "No freebsd-boot partition found"
     fi
-    gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev
+    doit gpart bootcode -b ${gpt0} -p ${gptzfs2} -i $idx $dev
     exit 0
 }
 
@@ -42,7 +47,7 @@ boot_nogeli_gpt_ufs_legacy() {
     if [ -z "$idx" ] ; then
 	die "No freebsd-boot partition found"
     fi
-    gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev
+    doit gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev
     exit 0
 }
 
@@ -58,9 +63,9 @@ boot_nogeli_mbr_zfs_legacy() {
     # search to find the freebsd-zfs partition within the slice
     # Or just assume it is 'a' because it has to be since it fails otherwise
     dd if=${dst}/boot/zfsboot of=/tmp/zfsboot1 count=1
-    gpart bootcode -b /tmp/zfsboo1 ${dev}s${s}	# Put boot1 into the start of part
-    sysctl kern.geom.debugflags=0x10
-    dd if=${dst}/boot/zfsboot iseek=1 seek=1024	# Put boot2 into ZFS boot slot
+    doit gpart bootcode -b /tmp/zfsboo1 ${dev}s${s}	# Put boot1 into the start of part
+    sysctl kern.geom.debugflags=0x10		# Put boot2 into ZFS boot slot
+    doit dd if=${dst}/boot/zfsboot of=/dev/${dev}s${s} iseek=1 seek=1024
     sysctl kern.geom.debugflags=0x0
 
     exit 0
@@ -70,15 +75,25 @@ boot_nogeli_mbr_ufs_legacy() {
     dev=$1
     dst=$2
 
-    gpart bootcode -b ${mbr0} ${dev}
+    doit gpart bootcode -b ${mbr0} ${dev}
     s=$(findpart $dev "freebsd-ufs")
     if [ -z "$s" ] ; then
-	die "No freebsd-zfs slice found"
+	die "No freebsd-ufs slice found"
     fi
-    gpart bootcode -p ${mbr2} ${dev}s${s}
+    doit gpart bootcode -p ${mbr2} ${dev}s${s}
     exit 0
 }
 
+boot_nogeli_vtoc8_ufs_ofw() {
+    dev=$1
+    dst=$2
+
+    # For non-native builds, ensure that geom_part(4) supports VTOC8.
+    kldload geom_part_vtoc8.ko
+    doit gpart bootcode -p ${vtoc8} ${dev}
+    exit 0
+}
+
 DESTDIR=/
 
 # Note: we really don't support geli boot in this script yet.
@@ -122,6 +137,9 @@ gptzfs2=${DESTDIR}/boot/gptzfsboot
 # For MBR, we have lots of choices, but select boot0
 mbr0=${DESTDIR}/boot/boot0
 mbr2=${DESTDIR}/boot/boot
+
+# VTOC8
+vtoc8=${DESTDIR}/boot/boot1
 
 # sanity check here
 

Copied and modified: stable/11/tools/boot/rootgen.sh (from r326874, head/tools/boot/rootgen.sh)
==============================================================================
--- head/tools/boot/rootgen.sh	Fri Dec 15 06:34:27 2017	(r326874, copy source)
+++ stable/11/tools/boot/rootgen.sh	Wed Feb  7 19:45:23 2018	(r328991)
@@ -33,28 +33,41 @@ mk_nogeli_gpt_ufs_legacy() {
     src=$1
     img=$2
 
-    rm -f ${img} ${img}.p2
+    cat > ${src}/etc/fstab <<EOF
+/dev/ada0p2	/		ufs	rw	1	1
+EOF
     makefs -t ffs -B little -s 200m ${img}.p2 ${src}
     mkimg -s gpt -b ${src}/boot/pmbr \
 	  -p freebsd-boot:=${src}/boot/gptboot \
 	  -p freebsd-ufs:=${img}.p2 -o ${img}
+    rm -f ${src}/etc/fstab
 }
 
 mk_nogeli_gpt_ufs_uefi() {
     src=$1
     img=$2
 
-    rm -f ${img} ${img}.p2
+    cat > ${src}/etc/fstab <<EOF
+/dev/ada0p2	/		ufs	rw	1	1
+EOF
+# XXX need to make msdos part for this to work XXXX
+    cp ${src}/boot/boot.efifat ${img}.p1
     makefs -t ffs -B little -s 200m ${img}.p2 ${src}
     mkimg -s gpt -b ${src}/boot/pmbr \
-	  -p freebsd-boot:=${src}/boot/gptboot \
+	  -p efi:=${img}.p1 \
 	  -p freebsd-ufs:=${img}.p2 -o ${img}
+    rm -f ${src}/etc/fstab
 }
 
 mk_nogeli_gpt_ufs_both() {
     src=$1
     img=$2
 
+    cat > ${src}/etc/fstab <<EOF
+/dev/ada0p3	/		ufs	rw	1	1
+EOF
+    # XXX need to make msdos part for this to work XXXX
+    cp ${src}/boot/boot.efifat ${img}.p1
     makefs -t ffs -B little -s 200m ${img}.p3 ${src}
     # p1 is boot for uefi, p2 is boot for gpt, p3 is /
     mkimg -b ${src}/boot/pmbr -s gpt \
@@ -62,6 +75,7 @@ mk_nogeli_gpt_ufs_both() {
 	  -p freebsd-boot:=${src}/boot/gptboot \
 	  -p freebsd-ufs:=${img}.p3 \
 	  -o ${img}
+    rm -f ${src}/etc/fstab
 }
 
 mk_nogeli_gpt_zfs_legacy() {
@@ -74,7 +88,6 @@ mk_nogeli_gpt_zfs_legacy() {
     bios=$7
     pool=nogeli-gpt-zfs-legacy
 
-    rm -f ${img}
     dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
     md=$(mdconfig -f ${img})
     gpart create -s gpt ${md}
@@ -94,6 +107,7 @@ opensolaris_load=YES
 EOF
     cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
     cp /boot/kernel/opensolaris.ko ${mntpt}/boot/kernel/opensolaris.ko
+    ls -las ${mntpt}/boot
     # end tweaks
     zfs umount -f ${pool}/ROOT
     zfs set mountpoint=none ${pool}/ROOT
@@ -111,6 +125,16 @@ mk_nogeli_gpt_zfs_both() {
 }
 
 mk_nogeli_mbr_ufs_legacy() {
+    src=$1
+    img=$2
+
+    cat > ${src}/etc/fstab <<EOF
+/dev/ada0s1a	/		ufs	rw	1	1
+EOF
+    makefs -t ffs -B little -s 200m ${img}.s1a ${src}
+    mkimg -s bsd -b ${src}/boot/boot -p freebsd-ufs:=${img}.s1a -o ${img}.s1
+    mkimg -a 1 ${bootmbr} -s mbr -b ${src}/boot/boot0sio -p freebsd:=${img}.s1 -o ${img}
+    rm -f ${src}/etc/fstab
 }
 
 mk_nogeli_mbr_ufs_uefi() {
@@ -167,7 +191,116 @@ mk_geli_mbr_zfs_both() {
 # iso
 # pxeldr
 # u-boot
+# powerpc
 
+mk_sparc64_nogeli_vtoc8_ufs_ofw() {
+    src=$1
+    img=$2
+    mntpt=$3
+    geli=$4
+    scheme=$5
+    fs=$6
+    bios=$7
+
+    cat > ${src}/etc/fstab <<EOF
+/dev/ada0a	/		ufs	rw	1	1
+EOF
+    makefs -t ffs -B big -s 200m ${img} ${src}
+    md=$(mdconfig -f ${img})
+    # For non-native builds, ensure that geom_part(4) supports VTOC8.
+    kldload geom_part_vtoc8.ko
+    gpart create -s VTOC8 ${md}
+    gpart add -t freebsd-ufs ${md}
+    ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
+    mdconfig -d -u ${md}
+    rm -f ${src}/etc/fstab
+}
+
+qser="-serial telnet::4444,server -nographic"
+
+# https://wiki.freebsd.org/QemuRecipes
+# aarch64
+qemu_aarch64_uefi()
+{
+    img=$1
+    sh=$2
+
+    echo "qemu-system-aarch64 -m 4096M -cpu cortex-a57 -M virt  \
+        -bios QEMU_EFI.fd ${qser} \
+        -drive if=none,file=${img},id=hd0 \
+        -device virtio-blk-device,drive=hd0" > $sh
+# https://wiki.freebsd.org/arm64/QEMU also has
+#       -device virtio-net-device,netdev=net0
+#       -netdev user,id=net0
+}
+
+# Amd64 qemu
+qemu_amd64_legacy()
+{
+    img=$1
+    sh=$2
+
+    echo "qemu-system-x86_64 --drive file=${img},format=raw ${qser}" > $sh
+}
+
+qemu_amd64_uefi()
+{
+    img=$1
+    sh=$2
+
+    echo "qemu-system-x86_64 -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser}" > $sh
+}
+
+qemu_amd64_both()
+{
+    img=$1
+    sh=$2
+
+    echo "qemu-system-x86_64 --drive file=${img},format=raw ${qser}" > $sh
+    echo "qemu-system-x86_64 -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser}" > $sh
+}
+
+# arm
+# nothing listed?
+
+# i386
+qemu_i386_legacy()
+{
+    img=$1
+    sh=$2
+
+    echo "qemu-system-i386 --drive file=${img},format=raw ${qser}" > $sh
+}
+
+# Not yet supported
+qemu_i386_uefi()
+{
+    img=$1
+    sh=$2
+
+    echo "qemu-system-i386 -bios ~/bios/OVMF-X32.fd --drive file=${img},format=raw ${qser}" > $sh
+}
+
+# Needs UEFI to be supported
+qemu_i386_both()
+{
+    img=$1
+    sh=$2
+
+    echo "qemu-system-i386 --drive file=${img},format=raw ${qser}" > $sh
+    echo "qemu-system-i386 -bios ~/bios/OVMF-X32.fd --drive file=${img},format=raw ${qser}" > $sh
+}
+
+# mips
+# qemu-system-mips -kernel /path/to/rootfs/boot/kernel/kernel -nographic -hda /path/to/disk.img -m 2048
+
+# Powerpc -- doesn't work but maybe it would enough for testing -- needs details
+# powerpc64
+# qemu-system-ppc64 -drive file=/path/to/disk.img,format=raw
+
+# sparc64
+# qemu-system-sparc64 -drive file=/path/to/disk.img,format=raw
+
 # Misc variables
 SRCTOP=$(make -v SRCTOP)
 cd ${SRCTOP}/stand
@@ -181,33 +314,127 @@ DESTDIR=${OBJDIR}/boot-tree
 rm -rf ${DESTDIR}
 mkdir -p ${DESTDIR}/boot/defaults
 mkdir -p ${DESTDIR}/boot/kernel
+# XXX boot1 exists only on sparc64
+cp /boot/boot1 ${DESTDIR}/boot
+cp /boot/loader ${DESTDIR}/boot
 cp /boot/kernel/kernel ${DESTDIR}/boot/kernel
-echo -D -S115200 > ${DESTDIR}/boot.config
+echo -h -D -S115200 > ${DESTDIR}/boot.config
 # XXX
 cp /boot/device.hints ${DESTDIR}/boot/device.hints
 # Assume we're already built
 make install DESTDIR=${DESTDIR} MK_MAN=no MK_INSTALL_AS_USER=yes
-# Copy init, /bin/sh and minimal libraries
-mkdir -p ${DESTDIR}/sbin ${DESTDIR}/bin ${DESTDIR}/lib ${DESTDIR}/libexec
-for f in /sbin/init /bin/sh $(ldd /bin/sh | awk 'NF == 4 { print $3; }') /libexec/ld-elf.so.1; do
+# Copy init, /bin/sh, minimal libraries and testing /etc/rc
+mkdir -p ${DESTDIR}/sbin ${DESTDIR}/bin \
+      ${DESTDIR}/lib ${DESTDIR}/libexec \
+      ${DESTDIR}/etc ${DESTDIR}/dev
+for f in /sbin/halt /sbin/init /bin/sh $(ldd /bin/sh | awk 'NF == 4 { print $3; }') /libexec/ld-elf.so.1; do
     cp $f ${DESTDIR}/$f
 done
-mkdir ${DESTDIR}/dev
+cat > ${DESTDIR}/etc/rc <<EOF
+#!/bin/sh
 
+echo "RC COMMAND RUNNING -- SUCCESS!!!!!"
+halt -p
+EOF
+
 # OK. Let the games begin
 
-for geli in nogeli geli; do
-    for scheme in gpt mbr; do
-	for fs in ufs zfs; do
-	    for bios in legacy uefi both; do
-		# Create sparse file and mount newly created filesystem(s) on it
-		img=${IMGDIR}/${geli}-${scheme}-${fs}-${bios}.img
-		echo "vvvvvvvvvvvvvvvvvvvvvv   Creating $img  vvvvvvvvvvvvvvvvvvvvvvv"
-		eval mk_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} ${img} ${MNTPT} ${geli} ${scheme} ${fs} ${bios}
-		echo "^^^^^^^^^^^^^^^^^^^^^^   Creating $img  ^^^^^^^^^^^^^^^^^^^^^^^"
+for arch in amd64; do
+    for geli in nogeli geli; do
+	for scheme in gpt mbr; do
+	    for fs in ufs zfs; do
+		for bios in legacy uefi both; do
+		    # Create sparse file and mount newly created filesystem(s) on it
+		    img=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.img
+		    sh=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.sh
+		    echo "vvvvvvvvvvvvvvvvvvvvvv   Creating $img  vvvvvvvvvvvvvvvvvvvvvvv"
+		    rm -f ${img}*
+		    eval mk_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} ${img} ${MNTPT} ${geli} ${scheme} ${fs} ${bios}
+		    eval qemu_${arch}_${bios} ${img} ${sh}
+		    [ -n "${SUDO_USER}" ] && chown ${SUDO_USER} ${img}*
+		    echo "^^^^^^^^^^^^^^^^^^^^^^   Creating $img  ^^^^^^^^^^^^^^^^^^^^^^^"
+		done
 	    done
 	done
     done
 done
 
 rmdir ${MNTPT}
+
+exit 0
+
+# Notes for the future
+
+for arch in i386; do
+    for geli in nogeli geli; do
+	for scheme in gpt mbr; do
+	    for fs in ufs zfs; do
+		for bios in legacy; do
+		    # Create sparse file and mount newly created filesystem(s) on it
+		    img=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.img
+		    sh=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.sh
+		    echo "vvvvvvvvvvvvvvvvvvvvvv   Creating $img  vvvvvvvvvvvvvvvvvvvvvvv"
+		    rm -f ${img}*
+		    eval mk_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} ${img} ${MNTPT} ${geli} ${scheme} ${fs} ${bios}
+		    eval qemu_${arch}_${bios} ${img} ${sh}
+		    [ -n "${SUDO_USER}" ] && chown ${SUDO_USER} ${img}*
+		    echo "^^^^^^^^^^^^^^^^^^^^^^   Creating $img  ^^^^^^^^^^^^^^^^^^^^^^^"
+		done
+	    done
+	done
+    done
+done
+
+for arch in arm aarch64; do
+    for scheme in gpt mbr; do
+	fs=ufs
+	for bios in uboot efi; do
+	    # Create sparse file and mount newly created filesystem(s) on it
+	    img=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.img
+	    sh=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.sh
+	    echo "vvvvvvvvvvvvvvvvvvvvvv   Creating $img  vvvvvvvvvvvvvvvvvvvvvvv"
+	    rm -f ${img}*
+	    eval mk_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} ${img} ${MNTPT} ${geli} ${scheme} ${fs} ${bios}
+	    eval qemu_${arch}_${bios} ${img} ${sh}
+	    [ -n "${SUDO_USER}" ] && chown ${SUDO_USER} ${img}*
+	    echo "^^^^^^^^^^^^^^^^^^^^^^   Creating $img  ^^^^^^^^^^^^^^^^^^^^^^^"
+	done
+    done
+done
+
+for arch in powerpc powerpc64; do
+    for scheme in ppc-wtf; do
+	fs=ufs
+	for bios in ofw uboot chrp; do
+	    # Create sparse file and mount newly created filesystem(s) on it
+	    img=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.img
+	    sh=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.sh
+	    echo "vvvvvvvvvvvvvvvvvvvvvv   Creating $img  vvvvvvvvvvvvvvvvvvvvvvv"
+	    rm -f ${img}*
+	    eval mk_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} ${img} ${MNTPT} ${geli} ${scheme} ${fs} ${bios}
+	    eval qemu_${arch}_${bios} ${img} ${sh}
+	    [ -n "${SUDO_USER}" ] && chown ${SUDO_USER} ${img}*
+	    echo "^^^^^^^^^^^^^^^^^^^^^^   Creating $img  ^^^^^^^^^^^^^^^^^^^^^^^"
+	done
+    done
+done
+
+for arch in sparc64; do
+    for geli in nogeli; do
+	for scheme in vtoc8; do
+	    for fs in ufs; do
+		for bios in ofw; do
+		    # Create sparse file and mount newly created filesystem(s) on it
+		    img=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.img
+		    sh=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.sh
+		    echo "vvvvvvvvvvvvvvvvvvvvvv   Creating $img  vvvvvvvvvvvvvvvvvvvvvvv"
+		    rm -f ${img}*
+		    eval mk_${arch}_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} ${img} ${MNTPT} ${geli} ${scheme} ${fs} ${bios}
+		    eval qemu_${arch}_${bios} ${img} ${sh}
+		    [ -n "${SUDO_USER}" ] && chown ${SUDO_USER} ${img}*
+		    echo "^^^^^^^^^^^^^^^^^^^^^^   Creating $img  ^^^^^^^^^^^^^^^^^^^^^^^"
+		done
+	    done
+	done
+    done
+done



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802071945.w17JjORS086216>